Skip to content

Commit

Permalink
[Web] rename role mapping to attribute mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
FreddleSpl0it authored and DerLinkman committed Feb 8, 2024
1 parent 1c73a16 commit b7a1825
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
30 changes: 15 additions & 15 deletions data/web/inc/functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand All @@ -2126,32 +2126,32 @@ 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){
if ($template){
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);
Expand Down
4 changes: 2 additions & 2 deletions data/web/lang/lang.en-gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions data/web/templates/admin/tab-config-identity-provider.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}>
Expand All @@ -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>
Expand Down

0 comments on commit b7a1825

Please sign in to comment.