fphammerle / yii2-client-cert-auth
用于通过TLS/SSL/HTTPS客户端证书自动登录的yii2扩展
1.0.0-alpha
2017-07-16 22:31 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: ^2.0
Requires (Dev)
- fphammerle/helpers: ^1.2
- phpunit/phpunit: ^4.8
This package is not auto-updated.
Last update: 2024-09-15 03:13:49 UTC
README
用于通过TLS/SSL/HTTPS客户端证书自动登录的yii2扩展
设置
1. 配置Web服务器
apache
<VirtualHost example.hammerle.me:443>
# ...
SSLEngine on
SSLCertificateFile /etc/somewhere/example-server-cert.pem
SSLCertificateKeyFile /etc/restricted/example-server-key.pem
SSLVerifyClient optional
SSLVerifyDepth 1
SSLCACertificateFile /etc/somewhere/example-client-cert-ca.pem
SSLOptions +StdEnvVars
</VirtualHost>
2. 安装扩展
composer require fphammerle/yii2-client-cert-auth
3. 创建表
./yii migrate --migrationPath=./vendor/fphammerle/yii2-client-cert-auth/migrations
4. 在Yii的应用程序配置中启用扩展
$config = [
// ...
'bootstrap' => ['clientCertAuth'],
'components' => [
// ...
'clientCertAuth' => \fphammerle\yii2\auth\clientcert\Authenticator::className(),
],
// ...
];
5. 注册客户端证书
$subj = new \fphammerle\yii2\auth\clientCert\Subject;
$subj->identity = \Yii::$app->user->identity;
$subj->distinguished_name = "CN=Fabian,C=AT";
$subj->save();