Skip to content

Commit

Permalink
Fix cs
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelWei authored and pizkaz committed Nov 4, 2024
1 parent b5d5f97 commit 8104fba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
10 changes: 7 additions & 3 deletions app/Auth/OIDC/OIDCController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function callback(Request $request)
$this->oidc->authenticate();
} catch (OpenIDConnectClientException $e) {
Log::error($e);

return redirect('/external_login');
}

Expand Down Expand Up @@ -82,14 +83,16 @@ public function logout(Request $request)
{
Log::debug('OIDC backchannel logout handler called');

if (!$this->oidc->verifyLogoutToken()) {
if (! $this->oidc->verifyLogoutToken()) {
Log::warning('Logout token verification failed');

return;
}

$sub = $this->oidc->getSubjectFromBackChannel();
if (!isset($sub)) {
if (! isset($sub)) {
Log::warning('Getting subject from backchannel failed');

return;
}

Expand All @@ -111,14 +114,15 @@ public function signout(Request $request)

public function signoutRedirectURL(string $logout_url)
{
if(!$this->oidc->hasEndSessionEndpoint()) {
if (! $this->oidc->hasEndSessionEndpoint()) {
return false;
}

$params = [
'id_token' => session('oidc_id_token'),
'logout_url' => $logout_url,
];

return route('auth.oidc.signout', $params);
}
}
14 changes: 6 additions & 8 deletions app/Auth/OIDC/OpenIDConnectClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,28 @@ protected function commitSession(): void
}

/**
* @param string $key
* @param string $key
*/
protected function getSessionKey($key): mixed
{
if (!Session::has($key)) {
if (! Session::has($key)) {
return false;
}

return Session::get($key);
}

/**
* @param string $key
* @param mixed $value mixed
* @param string $key
* @param mixed $value mixed
*/
protected function setSessionKey($key, $value): void
{
Session::put($key, $value);
}

/**
* @param string $key
* @param string $key
*/
protected function unsetSessionKey($key): void
{
Expand All @@ -54,8 +54,6 @@ protected function unsetSessionKey($key): void
* 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
{
Expand All @@ -64,11 +62,11 @@ public function redirect(string $url): void

/**
* 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);
}

}
4 changes: 2 additions & 2 deletions app/Http/Controllers/api/v1/auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function logout(Request $request)
break;
case 'oidc':
$redirect = app(OIDCController::class)->signoutRedirectURL(url('/logout'));
if (!$redirect) {
if (! $redirect) {
$message = 'oidc_incomplete';
}
break;
Expand All @@ -86,7 +86,7 @@ public function logout(Request $request)

return response()->json([
'redirect' => $redirect,
'message' => $message
'message' => $message,
]);
}
}

0 comments on commit 8104fba

Please sign in to comment.