Add Active Directory (LDAP) auth provider with role/group#2223
Open
Add Active Directory (LDAP) auth provider with role/group#2223
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Active Directory (LDAP) auth provider with role/group mapping and settings persistence safeguards
Summary
This PR adds a pluggable AD authentication provider (ad / ad-ldap) to FUXA, keeps local auth fallback, normalizes mapped roles to FUXA role IDs in userRole mode.
What’s included
server/runtime/auth.localad(ad-ldap)auth.fallbackLocal).rolesgroupsuserRolemodePOST /api/settings/auth/test-adadGroups.supertestAPI tests for/api/settingsauth persistence and authorization checks.New/updated settings
{ "auth": { "provider": "local", "fallbackLocal": true, "adminRoleNames": ["admin", "administrator"], "ad": { "enabled": false, "url": "", "baseDN": "", "bindDN": "", "bindPassword": "", "userFilter": "(&(objectClass=user)(|(sAMAccountName={{username}})(userPrincipalName={{username}})))", "userAttributes": ["dn", "cn", "displayName", "memberOf", "mail", "userPrincipalName", "sAMAccountName"], "groupAttribute": "memberOf", "refreshIdentity": false, "rejectUnauthorized": true, "timeoutMs": 5000, "connectTimeoutMs": 5000, "groupToRoles": {}, "groupToMask": {}, "defaultRoles": [], "defaultGroup": 0 } } }Settings meaning (AD block)
enabled: enables AD provider config.url: LDAP/LDAPS endpoint (ldap://...:389orldaps://...:636).baseDN: root search DN.bindDN/bindPassword: service account for user lookup.userFilter: LDAP filter; supports{{username}}.userAttributes: attributes fetched from LDAP.groupAttribute: group attribute name (usuallymemberOf).refreshIdentity: iftrue,/api/refreshre-resolves identity from AD.rejectUnauthorized: TLS certificate validation forldaps://.timeoutMs/connectTimeoutMs: LDAP operation/connect timeouts.groupToRoles: map AD group (DN or CN) -> role name(s)/id(s).groupToMask: map AD group (DN or CN) -> legacy group mask number(s).defaultRoles: roles always added when no match.defaultGroup: fallback mask when nogroupToMaskmatch.provider: selected provider (local,ad).fallbackLocal: use local auth when selected provider fails.adminRoleNames: role names treated as admin for legacy checks.Example (roles + groups mapping)
{ "userRole": true, "auth": { "provider": "ad", "fallbackLocal": true, "ad": { "enabled": true, "url": "ldap://dc01.lab.local:389", "baseDN": "DC=lab,DC=local", "bindDN": "svc_fuxa_ldap@lab.local", "bindPassword": "********", "groupToRoles": { "CN=GG_Admins,OU=Groups,DC=lab,DC=local": ["admin"], "GG_Admins": ["admin"], "CN=GG_Operators,OU=Groups,DC=lab,DC=local": ["operator"], "GG_Operators": ["operator"] }, "groupToMask": { "CN=GG_Admins,OU=Groups,DC=lab,DC=local": -1, "GG_Admins": -1, "CN=GG_Operators,OU=Groups,DC=lab,DC=local": 2, "GG_Operators": 2 }, "defaultRoles": [], "defaultGroup": 0 } } }Expected results:
GG_Operators->roles=["operator"],groups=2GG_Admins->roles=["admin"],groups=-1Security note
ldap://...:389is acceptable for testing.ldaps://...:636with valid certs andrejectUnauthorized: true.