lyseontech / drupal-external-auth
External authenticator user into 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-11-29 05:56:56 UTC
README
Drupal External Auth
Composer package to externally authenticate Drupal users
If the user exists in Drupal, authenticates the user.
If the user does not exist in Drupal, it creates the user and authenticates.
How to use?
composer require lyseontech/drupal-external-auth
Login
$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, '=')); }
In PrefixHash, put the prefix hash to identify the hash password from your system.
In hashPassord put the hash for user, if don't is necessary the user authenticate in Drupal by default login page of Drupal, put anything in this field.
If you dont implement custom validation hash in Drupal, the user can only access Drupal through your system.
Logout
$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, '=')); }