p4bgroup/ldap-jwt-authentication

JWT Authentication using LDAP connections

1.0.2 2019-04-06 17:31 UTC

This package is auto-updated.

Last update: 2022-01-23 18:25:49 UTC


README

JWT Authentication service using LDAP connections for Phalcon Projects

Latest Stable Version License Maintainability Total Downloads Test Coverage Build Status composer.lock

Usage

$ldap = new Zend\Ldap\Ldap([..]);
$authService = new AuthenticationService($ldap);
$jwtTokensService = new JWTTokensService();

/** @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->withSubject(Claims::SUBJECT_REFRESH)->withExpirationTime(new DateTime("+1 hour"));