-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(OIDC): Extend OpenIDConnectClient for better integration
* Uses Laravel session management instead of default handler * Checks if a well-known end_session_endpoint is available in sign out. If it is not available, informs the user that she/he is still logged in at the IDP.
- Loading branch information
Showing
6 changed files
with
91 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/** | ||
* Heavily inspired by https://github.com/jumbojett/OpenID-Connect-PHP/issues/374#issuecomment-1559028131 | ||
*/ | ||
|
||
namespace App\Auth\OIDC; | ||
|
||
use App; | ||
use Jumbojett\OpenIDConnectClient as OpenIDConnectClientBase; | ||
use Session; | ||
|
||
class OpenIDConnectClient extends OpenIDConnectClientBase | ||
{ | ||
protected function startSession(): void | ||
{ | ||
// Nothing to do here, as Laravel does the magic | ||
} | ||
|
||
protected function commitSession(): void | ||
{ | ||
Session::save(); | ||
} | ||
|
||
/** | ||
* @param string $key | ||
*/ | ||
protected function getSessionKey($key): mixed | ||
{ | ||
if (!Session::has($key)) { | ||
return false; | ||
} | ||
|
||
return Session::get($key); | ||
} | ||
|
||
/** | ||
* @param string $key | ||
* @param mixed $value mixed | ||
*/ | ||
protected function setSessionKey($key, $value): void | ||
{ | ||
Session::put($key, $value); | ||
} | ||
|
||
/** | ||
* @param string $key | ||
*/ | ||
protected function unsetSessionKey($key): void | ||
{ | ||
Session::remove($key); | ||
} | ||
|
||
/** | ||
* Overwrite the redirect method to use Laravel abort method. | ||
* Sometimes the error 'Cannot modify header information - headers already sent' was thrown. | ||
* By using Laravel abort method, this error is prevented. | ||
* @param string $url | ||
* @return void | ||
*/ | ||
public function redirect(string $url): void | ||
{ | ||
App::abort(302, '', ['Location' => $url]); | ||
} | ||
|
||
/** | ||
* Checks if an end_session_endpoint is available in the OIDC provider's well-known configuration. | ||
* @return {boolean} | ||
*/ | ||
public function hasEndSessionEndpoint(): bool | ||
{ | ||
return (bool) $this->getProviderConfigValue('end_session_endpoint', false); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters