correstion CAS nextcloud

This commit is contained in:
2024-09-22 10:35:25 +02:00
parent 55e4226456
commit 2ca0cef4f6
8 changed files with 29 additions and 19 deletions

View File

@ -30,7 +30,7 @@
<dependencies>
<owncloud min-version="10.0" max-version="10.10"/>
<nextcloud min-version="14" max-version="27.1"/>
<nextcloud min-version="14" max-version="27.2"/>
</dependencies>
<commands>

View File

@ -123,7 +123,7 @@ class AuthenticationController extends Controller
$this->loggingService->write(\OCA\UserCas\Service\LoggingService::FATAL, 'Fatal error with code: ' . $e->getCode() . ' and message: ' . $e->getMessage());
header("Location: " . $this->appService->getAbsoluteURL('/'));
header("Location: " . this->getServiceBasedUrl());
die();
}
}
@ -217,7 +217,7 @@ class AuthenticationController extends Controller
$this->loggingService->write(\OCA\UserCas\Service\LoggingService::FATAL, 'Fatal error with code: ' . $e->getCode() . ' and message: ' . $e->getMessage());
header("Location: " . $this->appService->getAbsoluteURL('/'));
header("Location: " . this->getServiceBasedUrl());
die();
}
}
@ -278,19 +278,26 @@ class AuthenticationController extends Controller
$newProtocol = 'http://';
if (intval($this->config->getAppValue($this->appName, 'cas_server_port')) === 443) {
$newProtocol = 'https://';
}
$params['backUrl'] = $newProtocol . $this->config->getAppValue($this->appName, 'cas_server_hostname') . $this->config->getAppValue($this->appName, 'cas_server_path');
} else {*/
$params['backUrl'] = $this->appService->getAbsoluteURL('/');
$params['backUrl'] = this->getServiceBasedUrl();
//}
$response = new TemplateResponse($this->appName, 'cas-error', $params, 'guest');
return $response;
}
private function getServiceBasedUrl(): string {
$overwrite = \OC::$server->getConfig()->getSystemValue('overwrite.cli.url');
if($overwrite) return $overwrite;
$httpProtocol = \OC::$server->getConfig()->getSystemValue('protocol');
$currentUrl = $_SERVER['SERVER_NAME'];
return $httpProtocol . $currentUrl;
}
}

View File

@ -406,7 +406,7 @@ class UserHooks
# Reset cookie
setcookie("user_cas_redirect_url", '/', 0, '/');
\phpCAS::logout(array("service" => $this->appService->getAbsoluteURL('/')));
\phpCAS::logout(array("service" => $this->getServiceBasedUrl()));
} else {
@ -445,4 +445,14 @@ class UserHooks
return $attributes;
}
private function getServiceBasedUrl(): string {
$overwrite = \OC::$server->getConfig()->getSystemValue('overwrite.cli.url');
if($overwrite) return $overwrite;
$httpProtocol = \OC::$server->getConfig()->getSystemValue('protocol');
$currentUrl = $_SERVER['SERVER_NAME'];
return $httpProtocol . $currentUrl;
}
}