lyseontech/drupal-external-auth

外部身份验证用户进入Drupal

0.2.1 2019-04-09 22:19 UTC

This package is auto-updated.

Last update: 2024-08-29 05:00:32 UTC


README

Build Status Coverage Status PHPStan Latest Stable Version Minimum PHP Version License

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, '='));
}