mirror of
https://github.com/netzbegruenung/user_saml.git
synced 2024-04-26 06:20:08 +02:00
Add mapping editor
Fixes https://github.com/nextcloud/user_saml/issues/4
This commit is contained in:
parent
c942f6826b
commit
99bbde20dc
|
@ -34,6 +34,18 @@ $(function() {
|
|||
}
|
||||
});
|
||||
|
||||
$('#user-saml-general input[type="text"], #user-saml-general textarea').change(function(e) {
|
||||
var el = $(this);
|
||||
$.when(el.focusout()).then(function() {
|
||||
var key = $(this).attr('name');
|
||||
setSAMLConfigValue('general', key, $(this).val());
|
||||
});
|
||||
if (e.keyCode === 13) {
|
||||
var key = $(this).attr('name');
|
||||
setSAMLConfigValue('general', key, $(this).val());
|
||||
}
|
||||
});
|
||||
|
||||
$('#user-saml-security input[type="checkbox"]').change(function(e) {
|
||||
var el = $(this);
|
||||
$.when(el.focusout()).then(function() {
|
||||
|
|
|
@ -64,10 +64,20 @@ class SettingsController extends Controller {
|
|||
'wantNameIdEncrypted' => $this->l10n->t('Indicates a requirement for the NameID received by this SP to be encrypted.'),
|
||||
'wantXMLValidation' => $this->l10n->t('Indicates if the SP will validate all received XMLs.'),
|
||||
];
|
||||
$generalSettings = [
|
||||
'uid_mapping' => [
|
||||
'text' => $this->l10n->t('Attribute to map the UID to.'),
|
||||
'type' => 'line',
|
||||
'required' => true,
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
$params = [
|
||||
'sp' => $serviceProviderFields,
|
||||
'security-offer' => $securityOfferFields,
|
||||
'security-required' => $securityRequiredFields,
|
||||
'general' => $generalSettings,
|
||||
];
|
||||
|
||||
return new Http\TemplateResponse($this->appName, 'settings', $params, 'blank');
|
||||
|
|
|
@ -43,8 +43,8 @@ class SAMLSettings {
|
|||
|
||||
public function getOneLoginSettingsArray() {
|
||||
$settings = [
|
||||
//'debug' => true,
|
||||
'strict' => true,
|
||||
// 'debug' => true,
|
||||
// 'strict' => true,
|
||||
'security' => [
|
||||
'nameIdEncrypted' => ($this->config->getAppValue('user_saml', 'security-nameIdEncrypted', '0') === '1') ? true : false,
|
||||
'authnRequestsSigned' => ($this->config->getAppValue('user_saml', 'security-authnRequestsSigned', '0') === '1') ? true : false,
|
||||
|
@ -94,6 +94,8 @@ class SAMLSettings {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ class UserBackend implements IApacheBackend, UserInterface, IUserBackend {
|
|||
* @since 6.0.0
|
||||
*/
|
||||
public function isSessionActive() {
|
||||
if($this->session->exists('user_saml.samlUserData')) {
|
||||
if($this->getCurrentUserId() !== '') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -164,8 +164,14 @@ class UserBackend implements IApacheBackend, UserInterface, IUserBackend {
|
|||
* @since 6.0.0
|
||||
*/
|
||||
public function getCurrentUserId() {
|
||||
// FIXME: Don't harcode
|
||||
return $this->session->get('user_saml.samlUserData')['urn:oid:0.9.2342.19200300.100.1.1'][0];
|
||||
$samlData = $this->session->get('user_saml.samlUserData');
|
||||
$uidMapping = $this->config->getAppValue('user_saml', 'general-uid_mapping', '');
|
||||
|
||||
if($uidMapping !== '' && isset($samlData[$uidMapping])) {
|
||||
return $samlData[$uidMapping][0];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,7 +43,15 @@ style('user_saml', 'settings');
|
|||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div id="user-saml-general">
|
||||
<!-- FIXME: Add mapping editor -->
|
||||
<?php foreach($_['general'] as $key => $attribute): ?>
|
||||
<?php if($attribute['type'] === 'checkbox'): ?>
|
||||
<input type="checkbox" id="user-saml-general-<?php p($key)?>" name="<?php p($key)?>" value="<?php p(\OC::$server->getConfig()->getAppValue('user_saml', 'general-'.$key, '0')) ?>">
|
||||
<label for="user-saml-general-<?php p($key)?>"><?php p($attribute['text']) ?></label><br/>
|
||||
<?php elseif($attribute['type'] === 'line'): ?>
|
||||
<input name="<?php p($key) ?>" value="<?php p(\OC::$server->getConfig()->getAppValue('user_saml', 'general-'.$key, '')) ?>" type="text" <?php if(isset($attribute['required']) && $attribute['required'] === true): ?>class="required"<?php endif;?> placeholder="<?php p($attribute['text']) ?>"/>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<!-- FIXME: Add "Disable timeout from SAML" switch (checked by default)-->
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue