https://github.com/librecodecoop/drupal-external-auth
Composer package to externally authenticate Drupal users
https://github.com/librecodecoop/drupal-external-auth
auth authenticator authentification composer-packages composer-project drupal drupal-8 drupal8 external php php7 php72
Last synced: 9 days ago
JSON representation
Composer package to externally authenticate Drupal users
- Host: GitHub
- URL: https://github.com/librecodecoop/drupal-external-auth
- Owner: LibreCodeCoop
- License: mit
- Created: 2019-04-08T22:10:34.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-09T22:29:23.000Z (almost 7 years ago)
- Last Synced: 2025-05-22T06:45:45.319Z (9 months ago)
- Topics: auth, authenticator, authentification, composer-packages, composer-project, drupal, drupal-8, drupal8, external, php, php7, php72
- Language: PHP
- Homepage:
- Size: 34.2 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/LyseonTech/drupal-external-auth)
[](https://coveralls.io/github/LyseonTech/drupal-external-auth?branch=master)
[](https://github.com/phpstan/phpstan)
[](https://packagist.org/packages/LyseonTech/drupal-external-auth)
[](https://php.net/)
[](https://packagist.org/packages/LyseonTech/drupal-external-auth)
# 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?
```bash
composer require lyseontech/drupal-external-auth
```
### Login
```php
$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
```php
$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, '='));
}
```