Repository navigation
feat(auth): sign in with LDAP and SAML 2.0 - #119
Merged
Merged
Conversation
LDAP (Authentication:Ldap) works next to local accounts in Local and Hybrid mode, for the web sign-in form and Basic auth alike. PaGetto binds with a search account, finds the user, reads its groups from memberOf or GroupSearchFilter and binds as the user. A username of a local account is only checked locally, the typed name is escaped in the filter, and a success is remembered for CacheSeconds. Accounts are keyed by entryUUID or objectGUID. SAML (Mode Saml, or Hybrid with Authentication:Saml) goes through a RemoteAuthenticationHandler on ITfoxtec.Identity.Saml2: an authentication request with the HTTP-Redirect binding, and a signed response posted back, checked for its signature, audience, lifetime and InResponseTo against the request id kept in a cookie. The identity provider's metadata is read from MetadataUrl and refreshed daily. Entra ID, OIDC, SAML and LDAP users are provisioned by one ExternalAccountService, which refuses a new user whose username belongs to another account and syncs the Admin flag and role-linked groups. Startup validation covers both sections, and Hybrid mode accepts only one of the Entra, Oidc and Saml sections. Tests run LdapDirectoryTests against a test OpenLDAP server when PAGETTO_TEST_LDAP is set, which CI does on ubuntu. testenv gets a SAML client in the Keycloak realm and UI checks SM1-SM5 and LD1-LD6.
The image's own check searches cn=admin,dc=planetexpress,dc=com, which isn't an entry, so the container never became healthy and the ubuntu job failed to start it.
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.
Sign in with LDAP / Active Directory accounts and SAML 2.0 identity providers
Authentication:Ldap) works next to local accounts inLocalandHybridmode, for the web sign-in form and for Basic auth from client tools. PaGetto binds with a search account (or anonymously), finds the user withUserFilter, reads its groups frommemberOforGroupSearchFilter, then binds as the user. Accounts are keyed byentryUUID(objectGUIDin Active Directory), so a renamed or moved user keeps its account.admincan't take over the localadmin. The typed name is escaped in the filter, and an empty password is refused (it would be an anonymous bind).CacheSeconds(60 by default) inLdapSignInCache, keyed by an HMAC of the username and password with a per-process key, so client requests don't each bind.cnor full DN; a group namedAdminmakes its members administrators.Authentication:ModeSaml, orHybridwithAuthentication:Saml):SamlAuthenticationHandleris aRemoteAuthenticationHandleron ITfoxtec.Identity.Saml2. It sends an authentication request with the HTTP-Redirect binding and asks for an HTTP-POST response, keeps the request id in a cookie, and checks the response's signature (against the certificates of the IdP metadata), audience, lifetime andInResponseTo. The metadata is read fromMetadataUrland refreshed daily. Not supported: signed requests, encrypted assertions, single logout.ExternalAccountService(upsert, username clash refusal, Admin and group sync);SingleSignOnSyncServicemaps the claims onto it.Hybridmode now accepts only one ofEntra,OidcandSaml; the LDAP section is refused in modes without local accounts.User.AuthProvidergetsSaml(3) andLdap(4); no migration is needed.ldap.mdandsaml.md, config keys inconfiguration.md, and updates toauthentication.md,web-ui.md, the readme,appsettings.json, the Helm values andAGENTS.md.ghcr.io/rroemhild/docker-test-openldap, pinned by digest) forLdapDirectoryTests; they are skipped on windows.Testing:
LdapDirectoryTestsrun against the test OpenLDAP server, including filter injection and the group search.XunitLoggerno longer throws after its test has ended: Microsoft.IdentityModel logs through one process-wide logger, which made a SAML test fail randomly in the full run.Hybridmode with Keycloak 26 (SAML) and the test OpenLDAP: Keycloakalicebecame an administrator through SAML and the Keycloak useradminwas refused;frysigned in through LDAP and got the Default feed through a group linked toship_crew;curlwithfry:fry200, a wrong password 401,zoidberg(no permission) 404, andadminwith a wrong password was checked only against the local account (rows SM1, SM2, SM4, LD1 to LD4 and LD6 oftestenv/UI-TESTS.md).Addresses #91