Refactor LDAP config
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

* Move credentials to ENV vars in prod
* Use same configs in dev and prod
* Make UID attribute and admin DN configurable
This commit is contained in:
2025-05-06 15:32:59 +04:00
parent d56edb34f1
commit 3d8619532b
5 changed files with 21 additions and 18 deletions

View File

@@ -28,11 +28,11 @@ authorizations: &AUTHORIZATIONS
development:
host: <%= ENV["LDAP_HOST"] || "localhost" %>
port: <%= ENV["LDAP_PORT"] || "389" %>
attribute: cn
base: <%= ENV["LDAP_BASE"] || "ou=kosmos.org,cn=users,dc=kosmos,dc=org" %>
admin_user: "cn=Directory Manager"
admin_password: <%= ENV["LDAP_ADMIN_PASSWORD"] %>
ssl: <%= ENV["LDAP_USE_TLS"] || "false" %>
attribute: <%= ENV["LDAP_UID_ATTR"] || "cn" %>
base: <%= ENV["LDAP_BASE"] || "ou=kosmos.org,cn=users,dc=kosmos,dc=org" %>
admin_user: <%= ENV["LDAP_ADMIN_USER"] || "cn=Directory Manager" %>
admin_password: <%= ENV["LDAP_ADMIN_PASSWORD"] %>
# <<: *AUTHORIZATIONS
test:
@@ -46,11 +46,11 @@ test:
# <<: *AUTHORIZATIONS
production:
host: ldap.kosmos.local
port: 389
attribute: cn
base: ou=kosmos.org,cn=users,dc=kosmos,dc=org
admin_user: <%= Rails.application.credentials.ldap[:username] rescue nil %>
admin_password: <%= Rails.application.credentials.ldap[:password] rescue nil %>
# ssl: false
host: <%= ENV["LDAP_HOST"] || "localhost" %>
port: <%= ENV["LDAP_PORT"] || "389" %>
ssl: <%= ENV["LDAP_USE_TLS"] || "false" %>
attribute: <%= ENV["LDAP_UID_ATTR"] || "cn" %>
base: <%= ENV["LDAP_BASE"] || "ou=kosmos.org,cn=users,dc=kosmos,dc=org" %>
admin_user: <%= ENV["LDAP_ADMIN_USER"] || "cn=Directory Manager" %>
admin_password: <%= ENV["LDAP_ADMIN_PASSWORD"] %>
# <<: *AUTHORIZATIONS