Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logout: make logout code more similar to upstream & fix logout redirects #245

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function boot(IBootContext $context): void
$altLoginPage = $this->config->getSystemValue('oidc_login_alt_login_page', false);

// URL for login without redirecting forcefully, false if we are not doing that
$noRedirLoginUrl = $useLoginRedirect ? $this->url->linkToRouteAbsolute('core.login.showLoginForm').'?noredir=1' : false;
$noRedirLoginUrl = $useLoginRedirect ? $this->url->linkToRouteAbsolute('core.login.showLoginForm').'?noredir=1&clear=1' : false;

// Get logged in user's session
$userSession = $container->get(IUserSession::class);
Expand All @@ -93,17 +93,20 @@ public function boot(IBootContext $context): void
/* Redirect to logout URL on completing logout
If do not have logout URL, go to noredir on logout */
if ($logoutUrl = $session->get('oidc_logout_url', $noRedirLoginUrl)) {
$userSession->listen('\OC\User', 'postLogout', function () use ($logoutUrl, $session) {
$userSession->listen('\OC\User', 'postLogout', function () use ($logoutUrl, $session, $request) {
// Do nothing if this is a CORS request
if ($this->getContainer()->get(ControllerMethodReflector::class)->hasAnnotation('CORS')) {
return;
}

// Properly close the session and clear the browsers storage data before
// redirecting to the logout url.
$session->set('clearingExecutionContexts', '1');
$session->close();
header('Clear-Site-Data: "cache", "storage"');

if ($request->getServerProtocol() === 'https') {
// This feature is available only in secure contexts
header('Clear-Site-Data: "cache", "storage"');
}

header('Location: '.$logoutUrl);

Expand Down
Loading