Chapter 16Lesson 01180–240 min

LDAP, SAML, OIDC, External Identity, Credential Rotation, and Authentication Troubleshooting: Concepts, Architecture, and Mental Model

Build a precise external-identity model for Nexus Repository across LDAP, SAML, OIDC, realm precedence, group-to-role mapping, browser SSO, package-client credentials, and recovery identities.

LDAPSAMLOIDCRealmsExternal identity

Learning objectives

  • Separate authentication protocol, identity source, session/token state, and Nexus authorization.
  • Explain LDAP bind/search/group membership, SAML assertions, and OIDC claims without treating them as equivalent.
  • Reason about realm enablement/order and preserve a local recovery path.
  • Distinguish browser SSO from noninteractive package-client authentication.
  • Identify which secrets, certificates, role mappings, and caches must be rotated or inspected.

Current support boundary. Use self-hosted Nexus Repository 3.95.0 as the reference line and record the actual running version. LDAP is available in Community and Pro. SAML is Pro-only. OIDC is supported for self-hosted Pro from 3.86 onward; custom certificate trust for the OIDC provider is available from 3.92. The mandatory chapter path therefore models LDAP/SAML/OIDC with local fixtures and requires no paid identity provider.

1. The practical problem: “who are you?” has several layers

Chapter 15 separated users, roles, privileges, anonymous access, and service identities. External identity adds another boundary: Nexus may no longer verify a password from its own local user database. Instead it can ask an LDAP directory, participate in a SAML browser flow, or redirect a browser to an OpenID Provider. Yet repository authorization still ends in the same place: Nexus roles and privileges decide whether an authenticated principal can read, publish, delete, or administer.

A production failure can therefore occur at several layers. A successful LDAP TCP connection does not prove that the user search base is correct. A valid SAML assertion does not prove its audience or group attribute matches Nexus configuration. A valid OIDC login does not prove the group claim maps to a Nexus role. And none of those browser-centric flows automatically tells Maven, npm, Docker, pip, or NuGet how to authenticate.

2. Three protocols, three mental models

External authentication paths converge on Nexus authorization
flowchart TD
LDAPC[Basic-auth client or UI] --> L[Nexus LDAP realm]
L --> D[LDAP bind and search]
D --> LG[Directory user and groups]
B[Browser] --> S[Nexus SAML SP]
S --> IDP[SAML IdP]
IDP --> AS[SAML assertion]
B --> O[Nexus OIDC relying party]
O --> OP[OpenID Provider]
OP --> TK[ID/access token claims]
LG --> MAP[External group to Nexus role mapping]
AS --> MAP
TK --> MAP
MAP --> P[Nexus privileges]
P --> R[Repository or administration action]
LOCAL[Local break-glass identity] --> P

The LDAP path is directory-oriented. Nexus uses connection/bind settings, searches for a user, resolves attributes and group membership, then maps external groups to Nexus roles. Nexus maintains a local LDAP authentication cache to reduce directory traffic.

SAML is browser SSO. Nexus acts as a SAML Service Provider (SP), the enterprise identity system is the Identity Provider (IdP), and a signed assertion returns identity attributes such as username and groups. The Assertion Consumer Service (ACS) is the Nexus endpoint that receives that response. Current Nexus SAML is Pro-only.

OIDC is an identity layer over OAuth 2.0. Nexus acts as a relying party, redirects the browser to an OpenID Provider, then validates tokens and maps configured claims to the Nexus user and groups. Current self-hosted OIDC is Pro-only and requires HTTPS.

3. Define the objects before configuring them

Object What it is Where failure appears
LDAP bind identity Account Nexus uses to query the directory when configured for simple authentication Connection succeeds/fails before end-user lookup; stale bind secret breaks directory queries.
User search base/filter Rules for locating the authenticating person entry Bind may work while login fails because zero or wrong users match.
Group membership mapping Directory relation used to derive external groups Authentication succeeds but expected Nexus roles are absent.
SAML Entity ID / ACS / audience Identifiers and callback boundary between SP and IdP Assertion rejected even though IdP login succeeded.
OIDC issuer / redirect URI / claims Trust identity, callback, and token fields used by Nexus Redirect loops, invalid token, or user gets no roles.
External role mapping Nexus rule that maps an external group name to Nexus roles/privileges Identity authenticates but authorization is wrong.
Realm Authentication source/protocol handler enabled in Nexus Wrong realm inactive or precedence collision resolves an unexpected source.
Break-glass local identity Deliberately protected local account retained for recovery Loss of external IdP should not make emergency administration impossible.

4. Realm order is authentication precedence, not authorization priority

When multiple realms can resolve the same username, active-realm order determines which source wins the name clash. It does not give that principal extra repository privileges. Authorization is still role/privilege driven.

Protocol-specific ordering matters. Current LDAP and SAML guides instruct keeping the Local Authenticating Realm ahead of those external realms. The current OIDC guide instructs placing the OAuth2 Realm above Local. Do not invent one universal ordering rule. Follow the guide for the protocol you deploy, preserve a tested local recovery account, and explicitly test duplicate usernames before production rollout.

Never remove every active realm. Sonatype warns that doing so prevents access for all users, including administrators.

5. Browser SSO is not package-client authentication

Caller Typical external identity path Important boundary
Human in Nexus UI SAML or OIDC browser redirect; LDAP/local username-password also possible Browser session/cookie state is not a package-manager credential.
Maven/npm/pip/NuGet client Usually Basic/token/API-key style credential supported by that format These clients do not perform SAML browser SSO.
Docker/OCI client Bearer-token protocol negotiated with Nexus realm Still needs an identity credential accepted by Nexus; SSO browser cookies are irrelevant.
CI agent Dedicated non-human credential or identity integration appropriate to client Do not reuse a human browser session or emergency admin credential.

Current SAML documentation explicitly says format clients such as Maven, Docker, and npm do not support SAML SSO and, in Pro, can use Nexus User Tokens. On Community, a dedicated local or LDAP-backed service identity can be the free-compatible noninteractive path when the client supports ordinary Nexus authentication.

6. Where identity state lives

State Owned by Backup/rotation implication
Local users/roles/realm configuration Nexus database/configuration Back up coherently with Nexus; change through supported UI/API.
LDAP directory users/groups External directory Nexus backup does not back up the directory.
LDAP bind secret Nexus configuration + external directory Rotate both sides with staged validation; never log the secret.
SAML IdP metadata/signing certificate Nexus SAML config + IdP Certificate/key rollover must update metadata/trust before cutover.
OIDC client secret/issuer/JWK trust Nexus OAuth2 config + OpenID Provider Coordinate secret rotation; keep old/new overlap only if the provider supports it.
Browser session Nexus/browser/IdP runtime state Existing sessions may survive some config changes; retest in a private browser.
Package-client credential Client secret store / CI secret manager Rotate separately from browser SSO.

7. Read-only inspection before mutation

export NX_URL="http://127.0.0.1:8081"
export LAB="$(mktemp -d)"
mkdir -p "$LAB/evidence"
export NX_USER="admin"
read -r -s -p 'Disposable Nexus admin password: ' NX_PASS; echo
export NX_AUTH_FILE="$(mktemp)"; chmod 600 "$NX_AUTH_FILE"
printf 'machine 127.0.0.1 login %s password %s
' "$NX_USER" "$NX_PASS" > "$NX_AUTH_FILE"
unset NX_PASS

curl -fsS --netrc-file "$NX_AUTH_FILE" "$NX_URL/service/rest/v1/status" > "$LAB/evidence/status.txt"
curl -fsS --netrc-file "$NX_AUTH_FILE" "$NX_URL/service/rest/v1/system/license" > "$LAB/evidence/license.json" || true
curl -fsS --netrc-file "$NX_AUTH_FILE" "$NX_URL/service/rest/v1/security/realms/active" > "$LAB/evidence/realms-active.json"
curl -fsS --netrc-file "$NX_AUTH_FILE" "$NX_URL/service/rest/v1/security/roles" > "$LAB/evidence/roles.json"
curl -fsS --netrc-file "$NX_AUTH_FILE" "$NX_URL/service/rest/v1/security/users" > "$LAB/evidence/users.json"

Then inspect Settings → Security → Realms and, if present for your edition, LDAP, SAML, or OAuth 2.0 settings. Do not enable a realm merely because it appears in documentation. Use the running instance's Swagger/OpenAPI page to confirm version-specific REST endpoints before automation.

8. Trust boundaries and rotation

External authentication introduces network trust (DNS, TLS, proxy), credential trust (bind/client secrets), assertion/token trust (signatures, issuer/audience), and authorization trust (group-to-role mapping). Rotating one layer does not automatically rotate the others. For example, replacing an LDAP server certificate can be independent of rotating the LDAP bind password; changing a SAML IdP signing key requires updated metadata; rotating an OIDC client secret must be synchronized with the provider and Nexus.

Fail closed. If identity validation is uncertain, the correct result is denied access—not anonymous fallback, not a broad local role, and not temporarily granting nx-admin to make the incident disappear.

9. Knowledge check

LDAP bind succeeds, but a user cannot log in. What should you inspect next?

Why can a successful OIDC login still end in 403 for a repository?

Can moving a realm higher grant more repository permissions?

Why must package clients be considered separately from browser SSO?

What is the purpose of a local break-glass account?

10. Production pattern and next step

A production identity design documents protocol, realm order, identity source, group/claim mapping, noninteractive client credentials, certificate/secret ownership, rotation procedure, and a tested recovery principal. Lesson 2 turns that model into a safe fixture-driven workflow so you can observe state transitions without requiring an enterprise IdP.

Official references and version notes

Version-sensitive statements were rechecked on 2026-08-26. The current official direct-download page lists Nexus Repository 3.95.0. Nexus 3.87+ on H2/PostgreSQL requires Java 21. The mandatory learning path is Community-compatible and models external identity with local fixtures; SAML and OIDC are optional Pro-only integrations for self-hosted Nexus.

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0 Send only Ethereum/ERC-20 compatible assets to this address.