Skip to content

Commit

Permalink
fix: Sorts group mappings in ldap.toml by org_role
Browse files Browse the repository at this point in the history
  • Loading branch information
Simen Andrè Vikestrand Skogum committed Oct 15, 2024
1 parent 2cc9769 commit 231244f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This file is used to list changes made in each version of grafana.

## Unreleased

- Fix: Sorts group mappings in ldap.toml by org_role

## 10.8.0 - *2024-09-27*

- Added org_ids to ldap_mapping functions
Expand Down
10 changes: 9 additions & 1 deletion resources/config_ldap_group_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,23 @@ def remove_group_mapping
next if nil_or_empty?(new_resource.send(rp))

[rp.to_s, new_resource.send(rp)]
end.compact.sort.to_h
end.compact.to_h

# Fjern eksisterende gruppemapping om den finnes
remove_group_mapping if group_mapping_exist?

# Hent eksisterende group_mappings eller opprett en tom liste hvis ingen finnes
ldap_server_config(new_resource.host)['group_mappings'] ||= []

# Legg til den nye gruppemappingen
ldap_server_config(new_resource.host)['group_mappings'].push(mapping)

# Sorter group_mappings etter org_role
ldap_server_config(new_resource.host)['group_mappings'].sort_by! { |gm| gm['org_role'] }
end
end


action :delete do
converge_by("Remove LDAP server #{new_resource.host} group mapping for #{new_resource.group_dn} from OrgID #{new_resource.org_id}") { remove_group_mapping } if group_mapping_exist?
end

0 comments on commit 231244f

Please sign in to comment.