mirror of
https://github.com/netzbegruenung/user_saml.git
synced 2024-04-27 23:04:53 +02:00
make display name of SSO identity provider configurable
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
parent
370594b439
commit
8bc343da6f
|
@ -319,8 +319,14 @@ class SAMLController extends Controller {
|
|||
*/
|
||||
public function selectUserBackEnd($redirectUrl) {
|
||||
$loginUrls = [
|
||||
'directLogin' => $this->getDirectLoginUrl(),
|
||||
'ssoLogin' => $this->getSSOUrl($redirectUrl)
|
||||
'directLogin' => [
|
||||
'url' => $this->getDirectLoginUrl(),
|
||||
'display-name' => $this->l->t('Direct log in')
|
||||
],
|
||||
'ssoLogin' => [
|
||||
'url' => $this->getSSOUrl($redirectUrl),
|
||||
'display-name' => $this->getSSODisplayName(),
|
||||
]
|
||||
];
|
||||
return new Http\TemplateResponse($this->appName, 'selectUserBackEnd', $loginUrls, 'guest');
|
||||
}
|
||||
|
@ -352,6 +358,20 @@ class SAMLController extends Controller {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* return the display name of the SSO identity provider
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getSSODisplayName() {
|
||||
$displayName = $this->config->getAppValue('user_saml', 'general-idp0_display_name');
|
||||
if (empty($displayName)) {
|
||||
$displayName = $this->l->t('SSO & SAML log in');
|
||||
}
|
||||
|
||||
return $displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* get SSO URL
|
||||
*
|
||||
|
|
|
@ -77,6 +77,11 @@ class Admin implements ISettings {
|
|||
'lowercaseUrlencoding' => $this->l10n->t('ADFS URL-Encodes SAML data as lowercase, and the toolkit by default uses uppercase. Enable for ADFS compatibility on signature verification.'),
|
||||
];
|
||||
$generalSettings = [
|
||||
'idp0_display_name' => [
|
||||
'text' => $this->l10n->t('Optional display name of the identity provider (default: "SSO & SAML log in")'),
|
||||
'type' => 'line',
|
||||
'required' => false,
|
||||
],
|
||||
'uid_mapping' => [
|
||||
'text' => $this->l10n->t('Attribute to map the UID to.'),
|
||||
'type' => 'line',
|
||||
|
|
|
@ -10,11 +10,11 @@ style('user_saml', 'selectUserBackEnd');
|
|||
<h1>Chose login option:</h1>
|
||||
|
||||
<div class="login-option">
|
||||
<a href="<?php p($_['directLogin']); ?>"><?php p($l->t('Direct log in')); ?></a>
|
||||
<a href="<?php p($_['directLogin']['url']); ?>"><?php p($_['directLogin']['display-name']); ?></a>
|
||||
</div>
|
||||
|
||||
<div class="login-option">
|
||||
<a href="<?php p($_['ssoLogin']); ?>"><?php p($l->t('SSO & SAML log in')); ?></a>
|
||||
<a href="<?php p($_['ssoLogin']['url']); ?>"><?php p($_['ssoLogin']['display-name']); ?></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -407,4 +407,27 @@ class SAMLControllerTest extends TestCase {
|
|||
['messageSend' => 'test message', 'messageExpected' => 'test message'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTestGetSSODisplayName
|
||||
*
|
||||
* @param string $configuredDisplayName
|
||||
* @param string $expected
|
||||
*/
|
||||
public function testGetSSODisplayName($configuredDisplayName, $expected) {
|
||||
$this->config->expects($this->any())->method('getAppValue')
|
||||
->with('user_saml', 'general-idp0_display_name')
|
||||
->willReturn($configuredDisplayName);
|
||||
|
||||
$result = $this->invokePrivate($this->samlController, 'getSSODisplayName');
|
||||
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
public function dataTestGetSSODisplayName() {
|
||||
return [
|
||||
['My identity provider', 'My identity provider'],
|
||||
['', 'SSO & SAML log in']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,6 +81,11 @@ class AdminTest extends \Test\TestCase {
|
|||
'lowercaseUrlencoding' => 'ADFS URL-Encodes SAML data as lowercase, and the toolkit by default uses uppercase. Enable for ADFS compatibility on signature verification.',
|
||||
];
|
||||
$generalSettings = [
|
||||
'idp0_display_name' => [
|
||||
'text' => $this->l10n->t('Optional display name of the identity provider (default: "SSO & SAML log in")'),
|
||||
'type' => 'line',
|
||||
'required' => false,
|
||||
],
|
||||
'uid_mapping' => [
|
||||
'text' => 'Attribute to map the UID to.',
|
||||
'type' => 'line',
|
||||
|
|
Loading…
Reference in a new issue