Skip to content
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
20 changes: 20 additions & 0 deletions lib/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ public function code(string $state = '', string $code = '', string $scope = '',
$this->logger->debug('Code login with core: ' . $code . ' and state: ' . $state);

if ($error !== '') {
if (!$this->isMobileDevice()) {
$cancelRedirectUrl = $this->config->getSystemValue('user_oidc.cancel_redirect_url', 'https://cloud.telekom-dienste.de/');
return new RedirectResponse($cancelRedirectUrl);
}
$this->logger->warning('Code login error', ['error' => $error, 'error_description' => $error_description]);
if ($this->isDebugModeEnabled()) {
return new JSONResponse([
Expand Down Expand Up @@ -901,6 +905,22 @@ private function getBackchannelLogoutErrorResponse(
);
}

private function isMobileDevice(): bool {
$mobileKeywords = $this->config->getSystemValue('user_oidc.mobile_keywords', ['Android', 'iPhone', 'iPad', 'iPod', 'Windows Phone', 'Mobile', 'webOS', 'BlackBerry', 'Opera Mini', 'IEMobile']);

if (!isset($_SERVER['HTTP_USER_AGENT'])) {
return false; // if no user-agent is set, assume desktop
}

foreach ($mobileKeywords as $keyword) {
if (stripos($_SERVER['HTTP_USER_AGENT'], $keyword) !== false) {
return true; // device is mobile
}
}

return false; // device is desktop
}

private function toCodeChallenge(string $data): string {
// Basically one big work around for the base64url decode being weird
$h = pack('H*', hash('sha256', $data));
Expand Down
Loading