[Web] rename role mapping to attribute mapping

This commit is contained in:
FreddleSpl0it 2023-03-17 13:14:36 +01:00
parent c25e597b21
commit ace5440c0d
No known key found for this signature in database
GPG Key ID: 00E14E7634F4BEC5
3 changed files with 22 additions and 22 deletions

View File

@ -1909,8 +1909,8 @@ function identity_provider($_action, $_data = null, $hide_secret = false) {
$stmt->execute(); $stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($rows as $row){ foreach($rows as $row){
if ($row["key"] == 'roles'){ if ($row["key"] == 'mappers'){
$settings['roles'] = json_decode($row["value"]); $settings['mappers'] = json_decode($row["value"]);
} else if ($row["key"] == 'templates'){ } else if ($row["key"] == 'templates'){
$settings['templates'] = json_decode($row["value"]); $settings['templates'] = json_decode($row["value"]);
} else { } else {
@ -1948,7 +1948,7 @@ function identity_provider($_action, $_data = null, $hide_secret = false) {
} }
} }
foreach($_data as $key => $value){ foreach($_data as $key => $value){
if (!in_array($key, $required_settings) || $key == 'roles' || $key == 'templates'){ if (!in_array($key, $required_settings) || $key == 'mappers' || $key == 'templates'){
continue; continue;
} }
@ -1957,19 +1957,19 @@ function identity_provider($_action, $_data = null, $hide_secret = false) {
$stmt->execute(); $stmt->execute();
} }
// add role mappings // add mappers
if ($_data['roles'] && $_data['templates']){ if ($_data['mappers'] && $_data['templates']){
if (!is_array($_data['roles'])){ if (!is_array($_data['mappers'])){
$_data['roles'] = array($_data['roles']); $_data['mappers'] = array($_data['mappers']);
} }
if (!is_array($_data['templates'])){ if (!is_array($_data['templates'])){
$_data['templates'] = array($_data['templates']); $_data['templates'] = array($_data['templates']);
} }
$roles = array(); $mappers = array();
$templates = array(); $templates = array();
foreach($_data['roles'] as $role){ foreach($_data['mappers'] as $mapper){
if ($role){ if ($mapper){
array_push($roles, $role); array_push($mappers, $mapper);
} }
} }
foreach($_data['templates'] as $template){ foreach($_data['templates'] as $template){
@ -1977,12 +1977,12 @@ function identity_provider($_action, $_data = null, $hide_secret = false) {
array_push($templates, $template); array_push($templates, $template);
} }
} }
if (count($roles) == count($templates)){ if (count($mappers) == count($templates)){
$roles = json_encode($roles); $mappers = json_encode($mappers);
$templates = json_encode($templates); $templates = json_encode($templates);
$stmt = $pdo->prepare("INSERT INTO identity_provider (`key`, `value`) VALUES ('roles', :value) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`);"); $stmt = $pdo->prepare("INSERT INTO identity_provider (`key`, `value`) VALUES ('mappers', :value) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`);");
$stmt->bindParam(':value', $roles); $stmt->bindParam(':value', $mappers);
$stmt->execute(); $stmt->execute();
$stmt = $pdo->prepare("INSERT INTO identity_provider (`key`, `value`) VALUES ('templates', :value) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`);"); $stmt = $pdo->prepare("INSERT INTO identity_provider (`key`, `value`) VALUES ('templates', :value) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`);");
$stmt->bindParam(':value', $templates); $stmt->bindParam(':value', $templates);

View File

@ -203,10 +203,10 @@
"iam": "Identity Provider", "iam": "Identity Provider",
"iam_client_id": "Client Id", "iam_client_id": "Client Id",
"iam_client_secret": "Client Secret", "iam_client_secret": "Client Secret",
"iam_description": "Here, you can configure the integration with an external Keycloak service. The Keycloak user's mailboxes will be automatically created upon their first login, provided that a role mapping has been set.", "iam_description": "Here, you can configure the integration with an external Keycloak service. The Keycloak user's mailboxes will be automatically created upon their first login, provided that a attribute mapping has been set.",
"iam_realm": "Realm", "iam_realm": "Realm",
"iam_redirect_url": "Redirect Url", "iam_redirect_url": "Redirect Url",
"iam_rolemapping": "Role Mapping", "iam_mapping": "Attribute Mapping",
"iam_server_url": "Server Url", "iam_server_url": "Server Url",
"iam_sso": "SSO", "iam_sso": "SSO",
"iam_test_connection": "Test Connection", "iam_test_connection": "Test Connection",

View File

@ -50,15 +50,15 @@
</div> </div>
</div> </div>
<div class="row mb-2"> <div class="row mb-2">
<label class="control-label col-sm-3 text-sm-end" for="iam_version">{{ lang.admin.iam_rolemapping }}:</label> <label class="control-label col-sm-3 text-sm-end" for="iam_version">{{ lang.admin.iam_mapping }}:</label>
<div class="col-4 d-flex mb-2"> <div class="col-4 d-flex mb-2">
<span class="w-100 me-2">Role</span> <span class="w-100 me-2">Attribute</span>
<span class="w-100 ms-2">Template</span> <span class="w-100 ms-2">Template</span>
<button id="iam_rolemap_add" class="btn btn-sm d-block d-sm-inline btn-secondary ms-2"><i class="bi bi-plus-lg"></i></button> <button id="iam_rolemap_add" class="btn btn-sm d-block d-sm-inline btn-secondary ms-2"><i class="bi bi-plus-lg"></i></button>
</div> </div>
{% for key, role in identity_provider_settings.roles %} {% for key, role in identity_provider_settings.mappers %}
<div class="offset-sm-3 col-4 d-flex mb-2"> <div class="offset-sm-3 col-4 d-flex mb-2">
<input type="text" class="form-control me-2" name="roles" value="{{ identity_provider_settings.roles[key] }}"> <input type="text" class="form-control me-2" name="mappers" value="{{ identity_provider_settings.mappers[key] }}">
<select data-live-search="true" name="templates" class="form-control" title="{{ lang.mailbox.template }}"> <select data-live-search="true" name="templates" class="form-control" title="{{ lang.mailbox.template }}">
{% for mbox_template in mbox_templates %} {% for mbox_template in mbox_templates %}
<option{% if mbox_template.template == identity_provider_settings.templates[key] %} selected{% endif %}> <option{% if mbox_template.template == identity_provider_settings.templates[key] %} selected{% endif %}>
@ -70,7 +70,7 @@
</div> </div>
{% endfor %} {% endfor %}
<div class="offset-sm-3 col-4 d-flex mb-2"> <div class="offset-sm-3 col-4 d-flex mb-2">
<input type="text" class="form-control me-2" name="roles" value=""> <input type="text" class="form-control me-2" name="mappers" value="">
<select data-live-search="true" name="templates" class="form-control" title="{{ lang.mailbox.template }}"> <select data-live-search="true" name="templates" class="form-control" title="{{ lang.mailbox.template }}">
{% for mbox_template in mbox_templates %} {% for mbox_template in mbox_templates %}
<option> <option>