Repository navigation
sources/ldap: derive TLS SNI name from hostname, not full server URI - #22456
Merged
BeryJu merged 3 commits intoJul 13, 2026
Merged
Conversation
`LDAPSource.server()` built the TLS SNI server name from the raw `server_uri`, so an `ldaps://host` URI produced an SNI name of `ldaps://host` instead of the bare hostname `host`. ldap3 forwards that as `server_hostname` to the `ssl` module, and SNI-strict servers drop the handshake -- every LDAP sync and the connectivity check fail with `SSL: UNEXPECTED_EOF_WHILE_READING`. Build each `Server` first and take the SNI name from `server.host`, the hostname ldap3 has already parsed out of the URI (scheme and port stripped). Each server in a pool now gets its own SNI name instead of all sharing the first server's raw URI. closes goauthentik#7756 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
BeryJu
approved these changes
Jul 13, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #22456 +/- ##
==========================================
- Coverage 93.25% 93.21% -0.04%
==========================================
Files 1044 1045 +1
Lines 61191 61206 +15
Branches 424 424
==========================================
- Hits 57062 57054 -8
- Misses 4129 4152 +23
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
kensternberg-authentik
added a commit
that referenced
this pull request
Jul 13, 2026
* main: (30 commits) providers/saml: catch InvalidVersion from cryptography when parsing metadata (#21185) stages/user_login: refuse to log in an unsaved pending user (#21691) web/admin: hide previous loglist when no previous logs available (#23954) stages/email: fix ungrammatical expiry time in password reset templates (#22758) tests/openid_conformance: Add more conformance coverage (#22174) sources/ldap: derive TLS SNI name from hostname, not full server URI (#22456) core: bump github.com/grafana/pyroscope-go from 1.3.1 to 1.4.0 (#23885) web: Fix Log Viewer Intersection Observer. (#23861) web: bump the goauthentik group across 1 directory with 2 updates (#23926) ci: bump regclient/actions/regctl-login from 4b4db1dcc7dad75ad67a788a380f75a20cc8a040 to 39bf30ced4be9d147faaabbde2682e9725fb8bd1 (#23890) ci: bump regclient/actions/regctl-installer from 4b4db1dcc7dad75ad67a788a380f75a20cc8a040 to 39bf30ced4be9d147faaabbde2682e9725fb8bd1 (#23891) core: bump pnpm/pnpm from 11.10.0 to 11.11.0 in /website (#23930) core: bump pnpm/pnpm from 11.10.0 to 11.11.0 in /lifecycle/container (#23927) core: bump github.com/sethvargo/go-envconfig from 1.3.0 to 1.3.1 (#23921) core: bump goauthentik/selenium from 149.0-ak-0.50.1 to 149.0-ak-0.50.2 in /tests/e2e (#23924) core: bump uvicorn[standard] from 0.49.0 to 0.50.0 (#23925) core: bump ruff from 0.15.20 to 0.15.21 (#23928) core: bump goauthentik/fips-python from `aaaab46` to `0798f3b` in /lifecycle/container (#23929) ci: bump actions/stale from 10.3.0 to 10.4.0 (#23935) ci: bump github/codeql-action/autobuild from 4.36.3 to 4.37.0 (#23931) ...
kensternberg-authentik
added a commit
that referenced
this pull request
Jul 13, 2026
* main: (48 commits) web/bug: harmonize and make routine the display of tasks (part 2: description list abuse) (#23839) providers/oauth2: fix iframe logout stage progression (#23919) providers/scim: improve error display when error doesn't conform to scim schema (#23955) providers/saml: catch InvalidVersion from cryptography when parsing metadata (#21185) stages/user_login: refuse to log in an unsaved pending user (#21691) web/admin: hide previous loglist when no previous logs available (#23954) stages/email: fix ungrammatical expiry time in password reset templates (#22758) tests/openid_conformance: Add more conformance coverage (#22174) sources/ldap: derive TLS SNI name from hostname, not full server URI (#22456) core: bump github.com/grafana/pyroscope-go from 1.3.1 to 1.4.0 (#23885) web: Fix Log Viewer Intersection Observer. (#23861) web: bump the goauthentik group across 1 directory with 2 updates (#23926) ci: bump regclient/actions/regctl-login from 4b4db1dcc7dad75ad67a788a380f75a20cc8a040 to 39bf30ced4be9d147faaabbde2682e9725fb8bd1 (#23890) ci: bump regclient/actions/regctl-installer from 4b4db1dcc7dad75ad67a788a380f75a20cc8a040 to 39bf30ced4be9d147faaabbde2682e9725fb8bd1 (#23891) core: bump pnpm/pnpm from 11.10.0 to 11.11.0 in /website (#23930) core: bump pnpm/pnpm from 11.10.0 to 11.11.0 in /lifecycle/container (#23927) core: bump github.com/sethvargo/go-envconfig from 1.3.0 to 1.3.1 (#23921) core: bump goauthentik/selenium from 149.0-ak-0.50.1 to 149.0-ak-0.50.2 in /tests/e2e (#23924) core: bump uvicorn[standard] from 0.49.0 to 0.50.0 (#23925) core: bump ruff from 0.15.20 to 0.15.21 (#23928) ...
1 task
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.
Details
LDAPSource.server()builds the TLS SNI server name from the rawserver_uri:server_uriis a full LDAP URI (e.g.ldaps://ldap.example.com)..split(",")[0].strip()only handles the comma-separated multi-server case andtrims whitespace — it does not strip the
ldap:///ldaps://scheme or a:port. The resulting value is passed asTls(sni=...), which ldap3 forwardsas
server_hostnameto Python'ssslmodule.A TLS SNI name must be a bare DNS hostname. Sending
ldaps://ldap.example.comas the SNI name causes SNI-strict servers / load balancers (common for TLS 1.3
load-balanced endpoints) to drop the handshake, so every LDAP sync and the
connectivity check fail with:
This makes the "Use Server URI for SNI verification" toggle strictly worse than
leaving it off for any such endpoint.
Fix
Build each
Serverfirst and derive the SNI name fromserver.host— thehostname ldap3 has already parsed out of the URI (scheme and port stripped).
This also addresses a related point raised in #7756: every server in a
ServerPoolpreviously shared the first server's raw URI as its SNI name;each server now gets its own correct SNI name.
Verified against ldap3 2.9.1 —
Server(uri).hoststripsldap:///ldaps://and
:portforhost,host:port,ldap://host,ldaps://host, andldaps://host:port.closes #7756
Checklist
ak test authentik/)make lint-fix)