Skip to content

Commit f4195f3

Browse files
authored
Merge pull request #401 from nextcloud/backport/396/stable-2.4
[stable-2.4] Add setting to specify a different signature algorithm
2 parents ee15d4a + 053f851 commit f4195f3

File tree

5 files changed

+36
-6
lines changed

5 files changed

+36
-6
lines changed

js/admin.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,18 @@ $(function() {
322322
});
323323
});
324324

325+
$('#user-saml-security input[type="text"], #user-saml-security textarea').change(function(e) {
326+
var el = $(this);
327+
$.when(el.focusout()).then(function() {
328+
var key = $(this).attr('name');
329+
OCA.User_SAML.Admin.setSamlConfigValue('security', key, $(this).val());
330+
});
331+
if (e.keyCode === 13) {
332+
var key = $(this).attr('name');
333+
OCA.User_SAML.Admin.setSamlConfigValue('security', key, $(this).val());
334+
}
335+
});
336+
325337
$('#user-saml-attribute-mapping input[type="text"], #user-saml-attribute-mapping textarea').change(function(e) {
326338
var el = $(this);
327339
$.when(el.focusout()).then(function() {

lib/SAMLSettings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public function getOneLoginSettingsArray($idp) {
119119
'wantXMLValidation' => ($this->config->getAppValue('user_saml', $prefix . 'security-wantXMLValidation', '0') === '1') ? true : false,
120120
'requestedAuthnContext' => false,
121121
'lowercaseUrlencoding' => ($this->config->getAppValue('user_saml', $prefix . 'security-lowercaseUrlencoding', '0') === '1') ? true : false,
122+
'signatureAlgorithm' => $this->config->getAppValue('user_saml', $prefix . 'security-signatureAlgorithm', null)
122123
],
123124
'sp' => [
124125
'entityId' => $this->urlGenerator->linkToRouteAbsolute('user_saml.SAML.getMetadata'),

lib/Settings/Admin.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function getForm() {
7575
'authnRequestsSigned' => $this->l10n->t('Indicates whether the <samlp:AuthnRequest> messages sent by this SP will be signed. [Metadata of the SP will offer this info]'),
7676
'logoutRequestSigned' => $this->l10n->t('Indicates whether the <samlp:logoutRequest> messages sent by this SP will be signed.'),
7777
'logoutResponseSigned' => $this->l10n->t('Indicates whether the <samlp:logoutResponse> messages sent by this SP will be signed.'),
78-
'signMetadata' => $this->l10n->t('Whether the metadata should be signed.'),
78+
'signMetadata' => $this->l10n->t('Whether the metadata should be signed.')
7979
];
8080
$securityRequiredFields = [
8181
'wantMessagesSigned' => $this->l10n->t('Indicates a requirement for the <samlp:Response>, <samlp:LogoutRequest> and <samlp:LogoutResponse> elements received by this SP to be signed.'),
@@ -87,6 +87,10 @@ public function getForm() {
8787
];
8888
$securityGeneral = [
8989
'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.'),
90+
'signatureAlgorithm' => [
91+
'type' => 'line',
92+
'text' => $this->l10n->t('Algorithm that the toolkit will use on signing process.')
93+
]
9094
];
9195
$generalSettings = [
9296
'uid_mapping' => [

templates/admin.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,20 @@
177177
</p>
178178
<?php endforeach; ?>
179179
<h4><?php p($l->t('General')) ?></h4>
180-
<?php foreach($_['security-general'] as $key => $text): ?>
181-
<p>
182-
<input type="checkbox" id="user-saml-<?php p($key)?>" name="<?php p($key)?>" value="<?php p(\OC::$server->getConfig()->getAppValue('user_saml', 'security-'.$key, '0')) ?>" class="checkbox">
183-
<label for="user-saml-<?php p($key)?>"><?php p($text) ?></label>
184-
</p>
180+
<?php foreach($_['security-general'] as $key => $attribute): ?>
181+
<?php if (is_array($attribute) && $attribute['type'] === 'line') { ?>
182+
<?php $text = $attribute['text'] ?>
183+
<p>
184+
<label><?php p($attribute['text']) ?></label><br />
185+
<input data-key="<?php p($key)?>" name="<?php p($key) ?>" value="<?php p(\OC::$server->getConfig()->getAppValue('user_saml', 'security-'.$key, '')) ?>" type="text" <?php if(isset($attribute['required']) && $attribute['required'] === true): ?>class="required"<?php endif;?> placeholder="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
186+
</p>
187+
<?php } else { ?>
188+
<?php $text = $attribute ?>
189+
<p>
190+
<input type="checkbox" id="user-saml-<?php p($key)?>" name="<?php p($key)?>" value="<?php p(\OC::$server->getConfig()->getAppValue('user_saml', 'security-'.$key, '0')) ?>" class="checkbox">
191+
<label for="user-saml-<?php p($key)?>"><?php p($text) ?></label><br/>
192+
</p>
193+
<?php } ?>
185194
<?php endforeach; ?>
186195
</div>
187196
</div>

tests/unit/Settings/AdminTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ public function formDataProvider() {
8080
];
8181
$securityGeneral = [
8282
'lowercaseUrlencoding' => 'ADFS URL-Encodes SAML data as lowercase, and the toolkit by default uses uppercase. Enable for ADFS compatibility on signature verification.',
83+
'signatureAlgorithm' => [
84+
'type' => 'line',
85+
'text' => 'Algorithm that the toolkit will use on signing process.'
86+
]
8387
];
8488
$generalSettings = [
8589
'idp0_display_name' => [

0 commit comments

Comments
 (0)