mirror of
https://github.com/netzbegruenung/user_saml.git
synced 2024-05-04 10:03:42 +02:00
add landing page to chose between SSO and direct login
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
parent
cc361cc409
commit
7daab97ace
|
@ -94,6 +94,10 @@ if(!$cli &&
|
|||
!$userSession->isLoggedIn() &&
|
||||
\OC::$server->getRequest()->getPathInfo() === '/login' &&
|
||||
$type !== '') {
|
||||
$params = $request->getParams();
|
||||
if (isset($params['direct'])) {
|
||||
return;
|
||||
}
|
||||
$redirectSituation = true;
|
||||
}
|
||||
|
||||
|
@ -114,6 +118,26 @@ if($useSamlForDesktopClients === '1') {
|
|||
}
|
||||
}
|
||||
|
||||
$multipleUserBackEnds = $config->getAppValue('user_saml', 'general-allow_multiple_user_back_ends', '0');
|
||||
|
||||
if ($redirectSituation === true && $multipleUserBackEnds === '1') {
|
||||
$params = $request->getParams();
|
||||
$redirectUrl = '';
|
||||
if(isset($params['redirect_url'])) {
|
||||
$redirectUrl = $params['redirect_url'];
|
||||
}
|
||||
|
||||
$targetUrl = $urlGenerator->linkToRouteAbsolute(
|
||||
'user_saml.SAML.selectUserBackEnd',
|
||||
[
|
||||
'redirectUrl' => $redirectUrl
|
||||
]
|
||||
);
|
||||
header('Location: '.$targetUrl);
|
||||
exit();
|
||||
|
||||
}
|
||||
|
||||
if($redirectSituation === true) {
|
||||
$params = $request->getParams();
|
||||
$originalUrl = '';
|
||||
|
|
|
@ -53,5 +53,10 @@ return [
|
|||
'url' => '/saml/error',
|
||||
'verb' => 'GET',
|
||||
],
|
||||
[
|
||||
'name' => 'SAML#selectUserBackEnd',
|
||||
'url' => '/saml/selectUserBackEnd',
|
||||
'verb' => 'GET',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
36
css/selectUserBackEnd.css
Normal file
36
css/selectUserBackEnd.css
Normal file
|
@ -0,0 +1,36 @@
|
|||
#saml-select-user-back-end {
|
||||
color: white;
|
||||
}
|
||||
|
||||
#saml-select-user-back-end h1 {
|
||||
font-size: 16px;
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
.login-option {
|
||||
background-color: #0082c9;
|
||||
border: 1px solid #fff;
|
||||
font-weight: 600;
|
||||
/*padding: 13px 20px;*/
|
||||
height: 40px;
|
||||
|
||||
margin: 15px 0;
|
||||
min-width: 269px;
|
||||
border-radius: 3px;
|
||||
font-size: 20px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.login-option a {
|
||||
display:inline-block;
|
||||
width:100%;
|
||||
line-height:40px;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.login-option .icon-confirm-white {
|
||||
float: right;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
20
templates/selectUserBackEnd.php
Normal file
20
templates/selectUserBackEnd.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
style('user_saml', 'selectUserBackEnd');
|
||||
|
||||
/** @var array $_ */
|
||||
/** @var $l \OCP\IL10N */
|
||||
?>
|
||||
|
||||
<div id="saml-select-user-back-end">
|
||||
|
||||
<h1>Chose login option:</h1>
|
||||
|
||||
<div class="login-option">
|
||||
<a href="<?php p($_['directLogin']); ?>"><?php p($l->t('Direct log in')); ?></a>
|
||||
</div>
|
||||
|
||||
<div class="login-option">
|
||||
<a href="<?php p($_['ssoLogin']); ?>"><?php p($l->t('SSO & SAML log in')); ?></a>
|
||||
</div>
|
||||
|
||||
</div>
|
Loading…
Reference in a new issue