Skip to content

Commit 5c52b8c

Browse files
authored
Merge pull request #932 from sniegel-mind4bytes/master
feat(settings): optional config option for sp entityId
2 parents 028ded2 + 5250160 commit 5c52b8c

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

lib/SAMLSettings.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class SAMLSettings {
5959
'saml-attribute-mapping-group_mapping_prefix',
6060
'saml-user-filter-reject_groups',
6161
'saml-user-filter-require_groups',
62+
'sp-entityId',
6263
'sp-x509cert',
6364
'sp-name-id-format',
6465
'sp-privateKey',
@@ -141,7 +142,9 @@ public function getOneLoginSettingsArray(int $idp): array {
141142
// "sloWebServerDecode" is not expected to be passed to the OneLogin class
142143
],
143144
'sp' => [
144-
'entityId' => $this->urlGenerator->linkToRouteAbsolute('user_saml.SAML.getMetadata'),
145+
'entityId' => (array_key_exists('sp-entityId', $this->configurations[$idp]) && trim($this->configurations[$idp]['sp-entityId']) != '')
146+
? $this->configurations[$idp]['sp-entityId']
147+
: $this->urlGenerator->linkToRouteAbsolute('user_saml.SAML.getMetadata'),
145148
'assertionConsumerService' => [
146149
'url' => $this->urlGenerator->linkToRouteAbsolute('user_saml.SAML.assertionConsumerService'),
147150
],

lib/Settings/Admin.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,21 @@ public function getForm() {
3838
];
3939
}
4040
$serviceProviderFields = [
41-
'x509cert' => $this->l10n->t('X.509 certificate of the Service Provider'),
42-
'privateKey' => $this->l10n->t('Private key of the Service Provider'),
41+
'x509cert' => [
42+
'text' => $this->l10n->t('X.509 certificate of the Service Provider'),
43+
'type' => 'text',
44+
'required' => false,
45+
],
46+
'privateKey' => [
47+
'text' => $this->l10n->t('Private key of the Service Provider'),
48+
'type' => 'text',
49+
'required' => false,
50+
],
51+
'entityId' => [
52+
'text' => $this->l10n->t('Service Provider EntityId (optional)'),
53+
'type' => 'line',
54+
'required' => false,
55+
]
4356
];
4457
$securityOfferFields = [
4558
'nameIdEncrypted' => $this->l10n->t('Indicates that the nameID of the <samlp:logoutRequest> sent by this SP will be encrypted.'),

templates/admin.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,14 @@
121121
} ?> ><?php p($value['label']) ?></option>
122122
<?php endforeach; ?>
123123
</select>
124-
<?php foreach ($_['sp'] as $key => $text): ?>
124+
<?php foreach ($_['sp'] as $key => $attribute): ?>
125125
<p>
126-
<label class="user-saml-standalone-label" for="user-saml-<?php p($key) ?>"><?php p($text) ?></label><br/>
127-
<textarea id="user-saml-<?php p($key) ?>" name="<?php p($key) ?>"><?php p($_['config']['sp-' . $key] ?? '') ?></textarea>
126+
<label class="user-saml-standalone-label" for="user-saml-<?php p($key) ?>"><?php p($attribute['text']) ?></label><br/>
127+
<?php if ($attribute['type'] === 'line'): ?>
128+
<input id="user-saml-<?php p($key) ?>" name="<?php p($key) ?>" value="<?php p($_['config']['sp-' . $key] ?? '') ?>" type="text" <?php if (isset($attribute['required']) && $attribute['required'] === true): ?>class="required"<?php endif;?>/>
129+
<?php else: ?>
130+
<textarea id="user-saml-<?php p($key) ?>" name="<?php p($key) ?>" <?php if (isset($attribute['required']) && $attribute['required'] === true): ?>class="required"<?php endif;?>><?php p($_['config']['sp-' . $key] ?? '') ?></textarea>
131+
<?php endif; ?>
128132
</p>
129133
<?php endforeach; ?>
130134
</div>

tests/unit/Settings/AdminTest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,21 @@ public function formDataProvider() {
5353
});
5454

5555
$serviceProviderFields = [
56-
'x509cert' => 'X.509 certificate of the Service Provider',
57-
'privateKey' => 'Private key of the Service Provider',
56+
'x509cert' => [
57+
'text' => 'X.509 certificate of the Service Provider',
58+
'type' => 'text',
59+
'required' => false,
60+
],
61+
'privateKey' => [
62+
'text' => 'Private key of the Service Provider',
63+
'type' => 'text',
64+
'required' => false,
65+
],
66+
'entityId' => [
67+
'text' => 'Service Provider EntityId (optional)',
68+
'type' => 'line',
69+
'required' => false,
70+
]
5871
];
5972
$securityOfferFields = [
6073
'nameIdEncrypted' => 'Indicates that the nameID of the <samlp:logoutRequest> sent by this SP will be encrypted.',

0 commit comments

Comments
 (0)