lyseontech / drupal-external-auth
外部认证用户进入 Drupal
0.2.1
2019-04-09 22:19 UTC
Requires
- php: >=7.2
- drupal/core-utility: ^8.6
- symfony/http-foundation: ^4.2
- wikimedia/php-session-serializer: ^1.0
Requires (Dev)
- overtrue/phplint: ^0.2.1
- phpstan/phpstan: ^0.7.0
- phpunit/phpunit: ^6.1
- satooshi/php-coveralls: ^2.1
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-08-29 05:00:32 UTC
README
Drupal External Auth
Composer 包,用于外部认证 Drupal 用户
如果用户已在 Drupal 中存在,则认证该用户。
如果用户在 Drupal 中不存在,则创建该用户并认证。
如何使用?
composer require lyseontech/drupal-external-auth
登录
$response = new Response(); $pdo = new PDO(...); (new \DrupalExternalAuth\Auth($response, $pdo))->auth([ 'name' => 'username', 'pass' => 'PrefixHash$' . 'hashOfPassord', 'timezone' => 'America/Sao_Paulo', 'langcode' => 'pt-br', 'roles' => ['administrator'] ]); foreach ($response->headers->getCookies() as $cookie) { header('Set-Cookie: '.$cookie->getName().strstr($cookie, '=')); }
在 PrefixHash 中,放入用于识别系统哈希密码的前缀哈希。
在 hashPassord 中放入用户的哈希,如果没有则不需要,用户可以通过 Drupal 默认登录页面在 Drupal 中认证,在此字段中输入任何内容。
如果您没有在 Drupal 中实现自定义验证哈希,用户只能通过您的系统访问 Drupal。
登出
$response = new Response(); $pdo = new PDO(...); (new \DrupalExternalAuth\Auth($response, $pdo))->logout(); foreach ($response->headers->getCookies() as $cookie) { header('Set-Cookie: '.$cookie->getName().strstr($cookie, '=')); }