Skip to content

Commit

Permalink
feat(settings): Add gui settings for passthrough parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Micke Nordin <[email protected]>
  • Loading branch information
mickenordin committed Nov 5, 2024
1 parent bdcd6dd commit cc50500
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Controller/SAMLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,16 @@ public function login(int $idp = 1): Http\RedirectResponse {
$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;
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public function getSamlProviderSettings(int $providerId): array {
'singleSignOnService.url' => ['required' => false],
'entityId' => ['required' => false],
'x509cert' => ['required' => false],
'passthroughParameters' => ['required' => false],
];
/* Fetch all config values for the given providerId */

Expand Down
2 changes: 2 additions & 0 deletions lib/SAMLSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SAMLSettings {
'idp-singleLogoutService.responseUrl',
'idp-singleLogoutService.url',
'idp-singleSignOnService.url',
'idp-passthroughParameters',
'idp-x509cert',
'security-authnRequestsSigned',
'security-general',
Expand Down Expand Up @@ -133,6 +134,7 @@ public function getOneLoginSettingsArray(int $idp): array {
'strict' => true,
'debug' => $this->config->getSystemValue('debug', false),
'baseurl' => $this->urlGenerator->linkToRouteAbsolute('user_saml.SAML.base'),
'passthroughParameters' => $this->configurations[$idp]['idp-passthroughParameters'] ?? '',
'security' => [
'nameIdEncrypted' => ($this->configurations[$idp]['security-nameIdEncrypted'] ?? '0') === '1',
'authnRequestsSigned' => ($this->configurations[$idp]['security-authnRequestsSigned'] ?? '0') === '1',
Expand Down
4 changes: 4 additions & 0 deletions templates/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@
<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']['idp-passthroughParameters'] ?? '') ?>" type="text" placeholder="idp_hint,extra_parameter"/>
</p>
</div>
</div>

Expand Down

0 comments on commit cc50500

Please sign in to comment.