diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2018-03-16 18:51:29 +0300 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2018-03-19 14:51:30 +0300 |
commit | 7daab97aced6b02411fa1b0ea71a97c5e4e53fc7 (patch) | |
tree | d06e9e072c691608be83af142308ebaff6e1f940 /lib | |
parent | cc361cc4092e5453017c5b2678a8672c83a1778e (diff) |
add landing page to chose between SSO and direct login
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Controller/SAMLController.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/Controller/SAMLController.php b/lib/Controller/SAMLController.php index b3e53d4d..90b6a963 100644 --- a/lib/Controller/SAMLController.php +++ b/lib/Controller/SAMLController.php @@ -309,4 +309,57 @@ class SAMLController extends Controller { } return new Http\TemplateResponse($this->appName, 'error', ['message' => $message], 'guest'); } + + /** + * @PublicPage + * @NoCSRFRequired + * @OnlyUnauthenticatedUsers + * @param string $redirectUrl + * @return Http\TemplateResponse + */ + public function selectUserBackEnd($redirectUrl) { + $loginUrls = [ + 'directLogin' => $this->getDirectLoginUrl(), + 'ssoLogin' => $this->getSSOUrl($redirectUrl) + ]; + return new Http\TemplateResponse($this->appName, 'selectUserBackEnd', $loginUrls, 'guest'); + } + + /** + * get SSO URL + * + * @param $redirectUrl + * @return string + */ + private function getSSOUrl($redirectUrl) { + + $originalUrl = ''; + if(!empty($redirectUrl)) { + $originalUrl = $this->urlGenerator->getAbsoluteURL($redirectUrl); + } + + + $csrfToken = \OC::$server->getCsrfTokenManager()->getToken(); + $ssoUrl = $this->urlGenerator->linkToRouteAbsolute( + 'user_saml.SAML.login', + [ + 'requesttoken' => $csrfToken->getEncryptedValue(), + 'originalUrl' => $originalUrl, + ] + ); + + return $ssoUrl; + + } + + /** + * get SSO URL + * + * @return string + */ + private function getDirectLoginUrl() { + $directUrl = $this->urlGenerator->linkToRouteAbsolute('core.login.tryLogin', ['direct' => '1']); + return $directUrl; + } + } |