Skip to content

Commit 70c7758

Browse files
committed
feat(settings): Add gui settings for passthrough parameters
Signed-off-by: Micke Nordin <kano@sunet.se>
1 parent 8f0693a commit 70c7758

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

lib/Controller/SAMLController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,16 @@ public function login(int $idp = 1): Http\RedirectResponse {
150150
$type = $this->config->getAppValue($this->appName, 'type');
151151
switch ($type) {
152152
case 'saml':
153-
$auth = new Auth($this->samlSettings->getOneLoginSettingsArray($idp));
154-
$passthroughParams = $this->config->getSystemValue('user_saml.passthrough_parameters', []);
153+
$settings= $this->samlSettings->getOneLoginSettingsArray($idp);
154+
$auth = new Auth($settings);
155+
$passthroughParamsString = trim($settings['passthroughParameters'] ?? '') ;
156+
$passthroughParams = array_map('trim', explode(',', $passthroughParamsString));
157+
155158
$passthroughValues = [];
156159
foreach ($passthroughParams as $passthroughParam) {
157160
$value = (string)$this->request->getParam($passthroughParam, '');
158161
if ($value !== '') {
162+
$this->logger->info('Passthrough parameters: ' . $passthroughParam . ' : ' . $value);
159163
$passthroughValues[$passthroughParam] = $value;
160164
}
161165
}

lib/Controller/SettingsController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public function getSamlProviderSettings(int $providerId): array {
5757
'singleSignOnService.url' => ['required' => false],
5858
'entityId' => ['required' => false],
5959
'x509cert' => ['required' => false],
60+
'passthroughParameters' => ['required' => false],
6061
];
6162
/* Fetch all config values for the given providerId */
6263

lib/SAMLSettings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class SAMLSettings {
3030
'idp-singleLogoutService.responseUrl',
3131
'idp-singleLogoutService.url',
3232
'idp-singleSignOnService.url',
33+
'passthroughParameters',
3334
'idp-x509cert',
3435
'security-authnRequestsSigned',
3536
'security-general',
@@ -133,6 +134,7 @@ public function getOneLoginSettingsArray(int $idp): array {
133134
'strict' => true,
134135
'debug' => $this->config->getSystemValue('debug', false),
135136
'baseurl' => $this->urlGenerator->linkToRouteAbsolute('user_saml.SAML.base'),
137+
'passthroughParameters' => $this->configurations[$idp]['passthroughParameters'] ?? '',
136138
'security' => [
137139
'nameIdEncrypted' => ($this->configurations[$idp]['security-nameIdEncrypted'] ?? '0') === '1',
138140
'authnRequestsSigned' => ($this->configurations[$idp]['security-authnRequestsSigned'] ?? '0') === '1',

templates/admin.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@
153153
<label class="user-saml-standalone-label" for="user-saml-x509cert"><?php p($l->t('Public X.509 certificate of the IdP')) ?></label><br/>
154154
<textarea id="user-saml-x509cert" name="x509cert"><?php p($_['config']['idp-x509cert'] ?? '') ?></textarea>
155155
</p>
156+
<p>
157+
<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/>
158+
<input id="user-saml-passthroughParameters" name="passthroughParameters" value="<?php p($_['config']['passthroughParameters'] ?? '') ?>" type="text" placeholder="idp_hint,extra_parameter"/>
159+
</p>
156160
</div>
157161
</div>
158162

0 commit comments

Comments
 (0)