Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/user_saml.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-06-29 11:25:09 +0300
committerLukas Reschke <lukas@owncloud.com>2016-06-29 11:25:09 +0300
commit99bbde20dc9926519ee3492be2edc060b9824133 (patch)
tree80439b11e875a47e1393cb7b53114b2535fc191c /lib
parentc942f6826bee2b43efd8f767761c52b1f6e013a1 (diff)
Add mapping editor
Fixes https://github.com/nextcloud/user_saml/issues/4
Diffstat (limited to 'lib')
-rw-r--r--lib/controller/settingscontroller.php10
-rw-r--r--lib/samlsettings.php6
-rw-r--r--lib/userbackend.php12
3 files changed, 23 insertions, 5 deletions
diff --git a/lib/controller/settingscontroller.php b/lib/controller/settingscontroller.php
index ed2de2b0..5ccbeb84 100644
--- a/lib/controller/settingscontroller.php
+++ b/lib/controller/settingscontroller.php
@@ -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');
diff --git a/lib/samlsettings.php b/lib/samlsettings.php
index dcb387b2..07adddd9 100644
--- a/lib/samlsettings.php
+++ b/lib/samlsettings.php
@@ -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;
}
}
diff --git a/lib/userbackend.php b/lib/userbackend.php
index f5b4086b..0679d788 100644
--- a/lib/userbackend.php
+++ b/lib/userbackend.php
@@ -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 '';
}