Skip to content

Commit

Permalink
Add specific redirect url if force authentication is on (redirect to …
Browse files Browse the repository at this point in the history
…CAS instance, not oc login), add specific error message for ECAS instance
  • Loading branch information
felixrupp committed Jun 19, 2018
1 parent 24d2e6e commit db6902a
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions lib/Controller/AuthenticationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function casLogin()

$url = urldecode($_COOKIE['user_cas_redirect_url']);

if(strpos($url, 'http') !== FALSE || strpos($url, 'https') !== FALSE) {
if (strpos($url, 'http') !== FALSE || strpos($url, 'https') !== FALSE) {

$location = $url;
} else {
Expand Down Expand Up @@ -210,8 +210,15 @@ private function casError(\Exception $exception = NULL, $additionalErrorCode = 0

if ($additionalErrorCode === \OCP\AppFramework\Http::STATUS_FORBIDDEN) {

$params['errorCode'] = $additionalErrorCode;
$params['errorMessage'] = "Forbidden. You do not have access to this application. Please refer to your administrator if something feels wrong to you.";
if (boolval($this->config->getAppValue('user_cas', 'cas_ecas_attributeparserenabled', false))) {

$params['errorCode'] = '';
$params['errorMessage'] = "You do not have access to the JRCbox application. Please contact the JRCbox administrator if something feels wrong to you.";
} else {

$params['errorCode'] = $additionalErrorCode;
$params['errorMessage'] = "Forbidden. You do not have access to this application. Please refer to your administrator if something feels wrong to you.";
}
}

if ($additionalErrorCode === \OCP\AppFramework\Http::STATUS_INTERNAL_SERVER_ERROR) {
Expand All @@ -225,7 +232,20 @@ private function casError(\Exception $exception = NULL, $additionalErrorCode = 0
$params['errorMessage'] = $exception->getMessage();
}

$params['backUrl'] = $this->appService->getAbsoluteURL('/');
if ($this->config->getAppValue($this->appName, 'cas_force_login') === '1') {

$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('/');
}

$response = new TemplateResponse($this->appName, 'cas-error', $params, 'guest');

Expand Down

0 comments on commit db6902a

Please sign in to comment.