Loading .gitignore +1 −0 Original line number Diff line number Diff line Loading @@ -5,3 +5,4 @@ logs/ vendor/ client-icons/ /nbproject/ *.pem classes/CallbackHandler.php +15 −10 Original line number Diff line number Diff line Loading @@ -29,14 +29,10 @@ namespace RAP; */ class CallbackHandler { private $dao; private $basePath; private $callbacks; private $locator; public function __construct(DAO $dao, $basePath, $callbacks) { $this->dao = $dao; $this->basePath = $basePath; $this->callbacks = $callbacks; public function __construct(Locator $locator) { $this->locator = $locator; } /** Loading Loading @@ -91,7 +87,16 @@ class CallbackHandler { return null; } public function manageLoginRedirect($user, SessionData $session) { public function manageLoginRedirect(User $user, SessionData $session) { if($session->getOAuth2Data() !== null) { $session->user = $user; $session->save(); $redirectUrl = $this->locator->getOAuth2RequestHandler()->getCodeResponseUrl(); $session->setOAuth2Data(null); header('Location: ' . $redirectUrl); die(); } if ($session->getCallbackURL() === null) { http_response_code(401); Loading classes/DAO.php +8 −10 Original line number Diff line number Diff line Loading @@ -40,22 +40,20 @@ interface DAO { * @param type $token login token * @param type $userId */ function createLoginToken($token, $userId); function createAccessToken(string $token, string $code, string $userId): string; /** * Retrieve the user ID from the login token. * @param type $token * @return type user ID * Retrieve the access token value from the code. */ function findLoginToken($token); function findAccessToken(string $code): ?string; /** * Delete a login token from the database. This happens when the caller * Delete an access token from the database. This happens when the caller * application has received the token and used it for retrieving user * information from the token using the RAP REST web service. * @param type $token login token */ function deleteLoginToken($token); function deleteAccessToken(string $token): void; /** * Create a new identity. Loading classes/JWKSHandler.php 0 → 100644 +14 −0 Original line number Diff line number Diff line <?php namespace RAP; /** * Manages the JWT Key Sets. */ class JWKSHandler { public function generateKeyPair() { } } classes/Locator.php +7 −3 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ class Locator { } public function getCallbackHandler(): CallbackHandler { return new \RAP\CallbackHandler($dao, $this->getBasePath()); return new \RAP\CallbackHandler($this); } public function getUserHandler(): UserHandler { Loading @@ -50,6 +50,10 @@ class Locator { return new \RAP\MailSender($_SERVER['HTTP_HOST'], $this->getBasePath()); } public function getOAuth2RequestHandler(): OAuth2RequestHandler { return new \RAP\OAuth2RequestHandler($this); } /** * Retrieve the SessionData object from the $_SESSION PHP variable. Create a * new one if it is necessary. Loading @@ -64,11 +68,11 @@ class Locator { return $this->session; } public function getServiceLogger() { public function getServiceLogger(): \Monolog\Logger { return $this->serviceLogger; } public function getAuditLogger() { public function getAuditLogger(): \Monolog\Logger { return $this->auditLogger; } Loading Loading
.gitignore +1 −0 Original line number Diff line number Diff line Loading @@ -5,3 +5,4 @@ logs/ vendor/ client-icons/ /nbproject/ *.pem
classes/CallbackHandler.php +15 −10 Original line number Diff line number Diff line Loading @@ -29,14 +29,10 @@ namespace RAP; */ class CallbackHandler { private $dao; private $basePath; private $callbacks; private $locator; public function __construct(DAO $dao, $basePath, $callbacks) { $this->dao = $dao; $this->basePath = $basePath; $this->callbacks = $callbacks; public function __construct(Locator $locator) { $this->locator = $locator; } /** Loading Loading @@ -91,7 +87,16 @@ class CallbackHandler { return null; } public function manageLoginRedirect($user, SessionData $session) { public function manageLoginRedirect(User $user, SessionData $session) { if($session->getOAuth2Data() !== null) { $session->user = $user; $session->save(); $redirectUrl = $this->locator->getOAuth2RequestHandler()->getCodeResponseUrl(); $session->setOAuth2Data(null); header('Location: ' . $redirectUrl); die(); } if ($session->getCallbackURL() === null) { http_response_code(401); Loading
classes/DAO.php +8 −10 Original line number Diff line number Diff line Loading @@ -40,22 +40,20 @@ interface DAO { * @param type $token login token * @param type $userId */ function createLoginToken($token, $userId); function createAccessToken(string $token, string $code, string $userId): string; /** * Retrieve the user ID from the login token. * @param type $token * @return type user ID * Retrieve the access token value from the code. */ function findLoginToken($token); function findAccessToken(string $code): ?string; /** * Delete a login token from the database. This happens when the caller * Delete an access token from the database. This happens when the caller * application has received the token and used it for retrieving user * information from the token using the RAP REST web service. * @param type $token login token */ function deleteLoginToken($token); function deleteAccessToken(string $token): void; /** * Create a new identity. Loading
classes/JWKSHandler.php 0 → 100644 +14 −0 Original line number Diff line number Diff line <?php namespace RAP; /** * Manages the JWT Key Sets. */ class JWKSHandler { public function generateKeyPair() { } }
classes/Locator.php +7 −3 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ class Locator { } public function getCallbackHandler(): CallbackHandler { return new \RAP\CallbackHandler($dao, $this->getBasePath()); return new \RAP\CallbackHandler($this); } public function getUserHandler(): UserHandler { Loading @@ -50,6 +50,10 @@ class Locator { return new \RAP\MailSender($_SERVER['HTTP_HOST'], $this->getBasePath()); } public function getOAuth2RequestHandler(): OAuth2RequestHandler { return new \RAP\OAuth2RequestHandler($this); } /** * Retrieve the SessionData object from the $_SESSION PHP variable. Create a * new one if it is necessary. Loading @@ -64,11 +68,11 @@ class Locator { return $this->session; } public function getServiceLogger() { public function getServiceLogger(): \Monolog\Logger { return $this->serviceLogger; } public function getAuditLogger() { public function getAuditLogger(): \Monolog\Logger { return $this->auditLogger; } Loading