p4bgroup / ldap-jwt-authentication
JWT Authentication using LDAP connections
v1.1.1
2022-03-30 13:46 UTC
Requires
- php: >=7.2.0
- ext-json: *
- ext-ldap: *
- firebase/php-jwt: ^6.0
- laminas/laminas-ldap: ^2.10.3
Requires (Dev)
- phpunit/phpunit: ^8.1
README
JWT Authentication service using LDAP connections for Phalcon Projects
Usage
$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"));