diff --git a/lib/Controller/SAMLController.php b/lib/Controller/SAMLController.php index 90b6a96..bdeae2c 100644 --- a/lib/Controller/SAMLController.php +++ b/lib/Controller/SAMLController.php @@ -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 * diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index 7bb9395..7ae9e9c 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -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', diff --git a/templates/selectUserBackEnd.php b/templates/selectUserBackEnd.php index 646284e..4c205a9 100644 --- a/templates/selectUserBackEnd.php +++ b/templates/selectUserBackEnd.php @@ -10,11 +10,11 @@ style('user_saml', 'selectUserBackEnd');

Chose login option:

- t('Direct log in')); ?> +
- t('SSO & SAML log in')); ?> +
diff --git a/tests/unit/Controller/SAMLControllerTest.php b/tests/unit/Controller/SAMLControllerTest.php index d0ad4e0..199e991 100644 --- a/tests/unit/Controller/SAMLControllerTest.php +++ b/tests/unit/Controller/SAMLControllerTest.php @@ -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'] + ]; + } } diff --git a/tests/unit/Settings/AdminTest.php b/tests/unit/Settings/AdminTest.php index ea64cbd..e42ebcd 100644 --- a/tests/unit/Settings/AdminTest.php +++ b/tests/unit/Settings/AdminTest.php @@ -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',