rocker / google-login
一个使您可以使用Google用户凭据对PHP-Rocker应用程序进行身份验证的包(https://github.com/victorjonsson/PHP-Rocker)
1.0.3
2013-06-11 17:43 UTC
Requires
- php: >=5.3.2
- rocker/server: 1.1.*
This package is not auto-updated.
Last update: 2024-09-23 14:54:43 UTC
README
在您的 Rocker应用程序 中安装此包,您的用户将能够使用他们的Google用户凭据进行身份验证。
本安装指南假设您对 composer 有一些先前的了解
1) 安装PHP-Rocker
在这里您可以了解更多关于如何开始使用PHP-Rocker的信息 如何开始
2) 添加Google登录包
将 "rocker/google-login" : "1.0.*" 添加到 composer.json 中的应用程序需求中,并在控制台中调用 composer update。
3) 编辑config.php
在config.php文件中,将身份验证类更改为Rocker\GoogleLogin\Authenticator。
return array( ... 'application.auth' => array( 'class' => '\\Rocker\\GoogleLogin\\Authenticator', 'mechanism' => 'google realm="your.website.com"' ), );
4) 实现
就这样!现在用户可以使用在Google注册的电子邮件和密码进行身份验证。当用户在数据库中不存在时,将创建用户。
$ curl -H 'Authorization: google shawn1980@gmail.com:google-password' https://www.website.com/api/me { "id" : 10341, "email" : "shawn1980@gmail.com", "nick" : "Shawn 1980", "meta" : { "created" : 1368864490 } }
提示!在PHP-Rocker中使用持久缓存(APC或基于文件的缓存)来加速请求需要身份验证的操作的服务器响应
可选配置
如果您想限制启用的身份验证机制或允许的电子邮件域名,可以将以下配置添加到config.php中。
'google.login' => array(
# Comma separated string telling PHP-Rocker that the user has to have an e-mail address
# at one of the declared domains
'allowed_domains' => 'somewebsite.com,otherwebsite.co.uk',
# Comma separated string with authentication mechanism that should be disabled
'disabled_auth_mechanisms' => 'basic,rc4',
# Whether or not the user credentials should be base64_decoded by the Authentication
# class. This option should be set to true in case your'e using rocker.js to
# communicate with your Rocker server
'base64_encoded' => true
)