mirror of
https://github.com/netzbegruenung/user_saml.git
synced 2024-04-28 07:14:52 +02:00
fix reading and updated name-id-format selection
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
ee8845252a
commit
4c97efc51b
|
@ -229,6 +229,8 @@ $(function() {
|
|||
} else if (htmlElement.tagName === 'INPUT' && htmlElement.getAttribute('type') === 'checkbox') {
|
||||
htmlElement.checked = entries[configKey] === '1';
|
||||
htmlElement.setAttribute('value', entries[configKey] === '1' ? '1' : '0');
|
||||
} else if (htmlElement.tagName === 'SELECT') {
|
||||
htmlElement.querySelector('[value="' + entries[configKey] + '"]').selected = true;
|
||||
} else {
|
||||
console.error("Could not handle " + configKey + " Tag is " + htmlElement.tagName + " and type is " + htmlElement.getAttribute("type"));
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ use OCP\AppFramework\Http\DataResponse;
|
|||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\IConfig;
|
||||
use OCP\IRequest;
|
||||
use OneLogin\Saml2\Constants;
|
||||
|
||||
class SettingsController extends Controller {
|
||||
|
||||
|
@ -76,7 +77,9 @@ class SettingsController extends Controller {
|
|||
'x509cert' => ['required' => false],
|
||||
];
|
||||
/* Fetch all config values for the given providerId */
|
||||
$settings = [];
|
||||
|
||||
// initialize settings with default value for option box (others are left empty)
|
||||
$settings['sp']['name-id-format'] = Constants::NAMEID_UNSPECIFIED;
|
||||
$storedSettings = $this->samlSettings->get($providerId);
|
||||
foreach ($params as $category => $content) {
|
||||
if (empty($content) || $category === 'providers' || $category === 'type') {
|
||||
|
@ -92,6 +95,12 @@ class SettingsController extends Controller {
|
|||
if (strpos($category, 'attribute-mapping') === 0) {
|
||||
$category = 'attribute-mapping';
|
||||
$key = 'saml-attribute-mapping' . '-' . $setting;
|
||||
} else if($category === 'name-id-formats') {
|
||||
if ($setting === $storedSettings['sp-name-id-format']) {
|
||||
$settings['sp']['name-id-format'] = $storedSettings['sp-name-id-format'];
|
||||
//continue 2;
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
$key = $category . '-' . $setting;
|
||||
}
|
||||
|
|
|
@ -138,6 +138,7 @@ class Admin implements ISettings {
|
|||
|
||||
];
|
||||
|
||||
$firstIdPConfig = isset($providers[0]) ? $this->samlSettings->get($providers[0]['id']) : null;
|
||||
$nameIdFormats = [
|
||||
Constants::NAMEID_EMAIL_ADDRESS => [
|
||||
'label' => $this->l10n->t('Email address'),
|
||||
|
@ -176,6 +177,11 @@ class Admin implements ISettings {
|
|||
'selected' => false,
|
||||
],
|
||||
];
|
||||
if ($firstIdPConfig !== null && isset($nameIdFormats[$firstIdPConfig['sp-name-id-format']])) {
|
||||
$nameIdFormats[$firstIdPConfig['sp-name-id-format']]['selected'] = true;
|
||||
} else {
|
||||
$nameIdFormats[Constants::NAMEID_UNSPECIFIED]['selected'] = true;
|
||||
}
|
||||
|
||||
$type = $this->config->getAppValue('user_saml', 'type');
|
||||
if ($type === 'saml') {
|
||||
|
@ -207,7 +213,7 @@ class Admin implements ISettings {
|
|||
'name-id-formats' => $nameIdFormats,
|
||||
'type' => $type,
|
||||
'providers' => $providers,
|
||||
'config' => isset($providers[0]) ? $this->samlSettings->get($providers[0]['id']) : null,
|
||||
'config' => $firstIdPConfig,
|
||||
];
|
||||
|
||||
return new TemplateResponse('user_saml', 'admin', $params);
|
||||
|
|
Loading…
Reference in a new issue