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