feat(settings): Add gui settings for passthrough parameters

Signed-off-by: Micke Nordin <kano@sunet.se>
This commit is contained in:
Micke Nordin 2024-11-05 12:59:38 +01:00 коммит произвёл Micke Nordin
Родитель 8f0693ae3c
Коммит 70c7758ccb
4 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -150,12 +150,16 @@ class SAMLController extends Controller {
$type = $this->config->getAppValue($this->appName, 'type');
switch ($type) {
case 'saml':
$auth = new Auth($this->samlSettings->getOneLoginSettingsArray($idp));
$passthroughParams = $this->config->getSystemValue('user_saml.passthrough_parameters', []);
$settings= $this->samlSettings->getOneLoginSettingsArray($idp);
$auth = new Auth($settings);
$passthroughParamsString = trim($settings['passthroughParameters'] ?? '') ;
$passthroughParams = array_map('trim', explode(',', $passthroughParamsString));
$passthroughValues = [];
foreach ($passthroughParams as $passthroughParam) {
$value = (string)$this->request->getParam($passthroughParam, '');
if ($value !== '') {
$this->logger->info('Passthrough parameters: ' . $passthroughParam . ' : ' . $value);
$passthroughValues[$passthroughParam] = $value;
}
}

Просмотреть файл

@ -57,6 +57,7 @@ class SettingsController extends Controller {
'singleSignOnService.url' => ['required' => false],
'entityId' => ['required' => false],
'x509cert' => ['required' => false],
'passthroughParameters' => ['required' => false],
];
/* Fetch all config values for the given providerId */

Просмотреть файл

@ -30,6 +30,7 @@ class SAMLSettings {
'idp-singleLogoutService.responseUrl',
'idp-singleLogoutService.url',
'idp-singleSignOnService.url',
'passthroughParameters',
'idp-x509cert',
'security-authnRequestsSigned',
'security-general',
@ -133,6 +134,7 @@ class SAMLSettings {
'strict' => true,
'debug' => $this->config->getSystemValue('debug', false),
'baseurl' => $this->urlGenerator->linkToRouteAbsolute('user_saml.SAML.base'),
'passthroughParameters' => $this->configurations[$idp]['passthroughParameters'] ?? '',
'security' => [
'nameIdEncrypted' => ($this->configurations[$idp]['security-nameIdEncrypted'] ?? '0') === '1',
'authnRequestsSigned' => ($this->configurations[$idp]['security-authnRequestsSigned'] ?? '0') === '1',

Просмотреть файл

@ -153,6 +153,10 @@ if (isset($_['general']['allow_multiple_user_back_ends']['text'])) {
<label class="user-saml-standalone-label" for="user-saml-x509cert"><?php p($l->t('Public X.509 certificate of the IdP')) ?></label><br/>
<textarea id="user-saml-x509cert" name="x509cert"><?php p($_['config']['idp-x509cert'] ?? '') ?></textarea>
</p>
<p>
<label class="user-saml-standalone-label" for="user-saml-passthroughParameters"><?php p($l->t('Request parameters to pass-through to IdP (comma separated list)')) ?></label><br/>
<input id="user-saml-passthroughParameters" name="passthroughParameters" value="<?php p($_['config']['passthroughParameters'] ?? '') ?>" type="text" placeholder="idp_hint,extra_parameter"/>
</p>
</div>
</div>