健康部门 / yii2-dohclient
doh oauth2 客户端
0.9.2
2017-02-21 04:07 UTC
Requires
- yiisoft/yii2: *
- yiisoft/yii2-authclient: ~2.1.0
This package is not auto-updated.
Last update: 2024-09-14 19:36:56 UTC
README
安装方法
可以通过运行 composer 命令来安装
php composer require --prefer-dist departmentofhealth/yii2-dohclient "*"
或者将以下命令添加到
"departmentofhealth/yii2-dohclient": "*"
文件 composer.json
中的 require 部分
注册 DOH SSO
- 在 http://sso.anamai.moph.go.th 注册
- 填写个人信息
- 创建应用程序并填写重定向 URL 将获得 clientID 和 clientSecret
与 yii2-user 一起使用
在 main.php 中 components 部分设置 authClientCollection
... 'authClientCollection' => [ 'class' => \yii\authclient\Collection::className(), 'httpClient' => [ 'transport' => 'yii\httpclient\CurlTransport', ], 'clients' => [ 'doh' => [ 'class' => 'departmentofhealth\yii2\dohclient\DohClientDektrium', 'clientId' => '<clientID>', 'clientSecret' => '<ClientSecret>', ], ], ], ...
重写 yii2-user 视图并在登录页面调用 widget
<?php $authAuthChoice = AuthChoice::begin([ 'baseAuthUrl' => ['/user/security/auth'], 'popupMode' => false, 'options'=>[ 'class'=>'auth-clients text-center', ] ]); echo 'Login with: '; foreach ($authAuthChoice->getClients() as $key => $client): ?> <?= $authAuthChoice->clientLink($client,strtoupper($key));?> <?php endforeach; ?> <?php AuthChoice::end(); ?>