1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2024-12-23 02:04:46 +02:00

[Web] rename role mapping to attribute mapping

This commit is contained in:
FreddleSpl0it 2023-03-17 13:14:36 +01:00 committed by DerLinkman
parent 1c73a16ca0
commit b7a18255fe
No known key found for this signature in database
GPG Key ID: F109FD97469550A2
3 changed files with 22 additions and 22 deletions

View File

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

View File

@ -214,10 +214,10 @@
"iam": "Identity Provider",
"iam_client_id": "Client Id",
"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_redirect_url": "Redirect Url",
"iam_rolemapping": "Role Mapping",
"iam_mapping": "Attribute Mapping",
"iam_server_url": "Server Url",
"iam_sso": "SSO",
"iam_test_connection": "Test Connection",

View File

@ -50,15 +50,15 @@
</div>
</div>
<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">
<span class="w-100 me-2">Role</span>
<span class="w-100 me-2">Attribute</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>
</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">
<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 }}">
{% for mbox_template in mbox_templates %}
<option{% if mbox_template.template == identity_provider_settings.templates[key] %} selected{% endif %}>
@ -70,7 +70,7 @@
</div>
{% endfor %}
<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 }}">
{% for mbox_template in mbox_templates %}
<option>