https://github.com/p4bgroup/ldap-jwt-authentication
A library to help with generating JWT tokens based on LDAP connection.
https://github.com/p4bgroup/ldap-jwt-authentication
jwt jwt-authentication ldap ldap-authentication
Last synced: 8 months ago
JSON representation
A library to help with generating JWT tokens based on LDAP connection.
- Host: GitHub
- URL: https://github.com/p4bgroup/ldap-jwt-authentication
- Owner: P4BGroup
- License: mit
- Created: 2019-04-06T14:45:26.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-03-30T13:47:38.000Z (about 4 years ago)
- Last Synced: 2025-05-05T20:16:54.528Z (about 1 year ago)
- Topics: jwt, jwt-authentication, ldap, ldap-authentication
- Language: PHP
- Size: 50.8 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.MD
- License: LICENSE
Awesome Lists containing this project
README
P4BGroup Authentication
---
JWT Authentication service using LDAP connections for Phalcon Projects
[](https://packagist.org/packages/p4bgroup/ldap-jwt-authentication) [](https://packagist.org/packages/p4bgroup/ldap-jwt-authentication) [](https://codeclimate.com/github/P4BGroup/ldap-jwt-authentication/maintainability) [](https://packagist.org/packages/p4bgroup/ldap-jwt-authentication) [](https://codeclimate.com/github/P4BGroup/ldap-jwt-authentication/test_coverage) [](https://travis-ci.com/P4BGroup/ldap-jwt-authentication) [](https://packagist.org/packages/p4bgroup/ldap-jwt-authentication)
Usage
---
```php
$ldap = new Laminas\Ldap\Ldap([..]);
$authService = new AuthenticationService($ldap);
$jwtTokensService = new JWTTokensService($algorithm, $encodeKey, $decodeKey);
/** @param P4BGroup\Authentication\User $user */
$user = $authService->authenticateUser($username, $password, $userBaseDn);
$claims = new P4BGroup\Authentication\Claims();
$claims->setData($user->toArray())
->setSubject(Claims::SUBJECT_REFRESH)
->setExpirationTime(new DateTime("+10 minutes"))
$accessToken = $jwtTokensService->encode($claims);
$refreshToken = $jwtTokensService->encode($claims->setSubject(Claims::SUBJECT_REFRESH)->setExpirationTime(new DateTime("+1 hour"));
```