Skip to content

OSAC-1663: Add LDAP + Keycloak integration setup guide - #38

Open
obochan-rh wants to merge 2 commits into
osac-project:mainfrom
obochan-rh:OSAC-1663-ldap-documentation
Open

OSAC-1663: Add LDAP + Keycloak integration setup guide#38
obochan-rh wants to merge 2 commits into
osac-project:mainfrom
obochan-rh:OSAC-1663-ldap-documentation

Conversation

@obochan-rh

@obochan-rh obochan-rh commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a comprehensive guide for integrating LDAP with Keycloak in OSAC deployments
  • Covers prerequisites, LDAP server setup (389 Directory Server), Keycloak federation configuration, user/group mapping, and token flow
  • Documents current limitations (single-realm multi-tenant gap) and planned improvements

Test plan

  • Review guide accuracy against live edge-04 deployment
  • Verify all CLI commands and configuration snippets are correct
  • Confirm Keycloak admin console steps match current version

Summary by CodeRabbit

Documentation

  • Added a comprehensive setup guide for integrating LDAP directories with Keycloak for authentication. The guide includes step-by-step configuration instructions, verification procedures, user lifecycle management, and known limitations for production deployments.

Signed-off-by: Ofer Bochan <obochan@obochan-thinkpadp1gen7.rmtil.csb>
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@obochan-rh, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 17 minutes and 9 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: osac-project/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: c5738678-d166-47c1-b01d-c18cb59d8662

📥 Commits

Reviewing files that changed from the base of the PR and between 0a399d2 and 2e09d61.

📒 Files selected for processing (1)
  • guides/ldap-keycloak-integration.md

Walkthrough

Adds guides/ldap-keycloak-integration.md, a 589-line setup guide documenting the LDAP–Keycloak integration for OSAC. It covers architecture, component responsibilities, a login flow diagram, step-by-step 389-ds and Keycloak configuration, verification procedures, user lifecycle operations, sync behavior modes, and a limitations matrix.

Changes

LDAP–Keycloak Integration Guide

Layer / File(s) Summary
Guide scope, TOC, and architecture overview
guides/ldap-keycloak-integration.md
Title, date, scope, table of contents, auth/authz component roles, login flow sequence diagram, and key behavioral rules (per-login LDAP bind, user import/update, JWT signed by Keycloak).
LDAP server setup and configuration
guides/ldap-keycloak-integration.md
Prerequisites, 389-ds installation and directory instance creation, user/group LDIF entries, required vs optional attributes table, LDAP verification commands, directory structure summary, and Keycloak-to-LDAP network requirements.
Keycloak federation setup and OAuth client
guides/ldap-keycloak-integration.md
Admin token retrieval, LDAP user storage federation provider creation with all config parameters, key settings explanation table, initial sync trigger, fulfillment-cli OAuth client creation with Direct Access Grants, and auto-created attribute mapper descriptions.
Verification, user lifecycle, and sync behavior
guides/ldap-keycloak-integration.md
LDAP connectivity test from Keycloak, password-grant token acquisition (success and failure examples), federation status check, add/delete/password-change user procedures, and sync modes (on-login, full, changed-user) with attribute sync vs password non-sync notes.
Limitations and constraint matrix
guides/ldap-keycloak-integration.md
Realm-wide LDAP federation scope, disabled org behavior, username uniqueness, delayed deprovisioning, absent group-to-role JWT mapping, READ_ONLY mode, and no LDAPS by default — each with severity and resolution path in a summary matrix.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

📂 An LDAP tree, a Keycloak realm,
A bind on each login at the helm.
The JWT flows, Envoy inspects,
OPA decides what to accept.
589 lines of truth — no more guessing,
A federated future, thoroughly blessing. 🔐

🚥 Pre-merge checks | ✅ 11
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a comprehensive LDAP + Keycloak integration setup guide as a new documentation file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
No-Hardcoded-Secrets ✅ Passed File contains no hardcoded secrets. All credentials use angle-bracket placeholders (, , etc.). The only non-placeholder value, "secretpass", appears solely in a documentat...
No-Weak-Crypto ✅ Passed No weak cryptographic algorithms (MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB), custom crypto implementations, or unsafe secret comparisons found in the documentation guide.
No-Injection-Vectors ✅ Passed Documentation file contains no injection vectors: no SQL concatenation, eval/exec, unsafe shell variables in jq filters, pickle/yaml.load, os.system calls, or dangerouslySetInnerHTML. All jq filter...
Container-Privileges ✅ Passed PR adds only a markdown documentation guide (guides/ldap-keycloak-integration.md) with no container/K8s manifests, Dockerfiles, or privileged security configurations to check.
No-Sensitive-Data-In-Logs ✅ Passed All sensitive data in the guide uses proper placeholders (, , , , etc.) and example values (alice@example.com, example.com). No real credenti...
Ai-Attribution ✅ Passed No AI tool usage is mentioned in PR description or commits, so AI attribution verification is not applicable. Check passes by absence of AI disclosure.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@guides/ldap-keycloak-integration.md`:
- Around line 277-281: Remove the `-k` and `-ks` flags from all curl commands in
the Keycloak integration examples that disable TLS verification, particularly in
the token fetch command at the KC_TOKEN assignment and all subsequent curl
commands to the KC_URL endpoint. Either ensure proper trusted CA certificate
configuration is in place and documented, or explicitly mark these commands as
lab-only examples with appropriate warnings about security implications. The
affected sections include the token retrieval curl command and all admin API
calls throughout the guide at the specified line ranges.
- Around line 112-154: The prerequisites section lists OpenLDAP as a supported
LDAP Server Software option, but all the subsequent setup steps are specific to
389-ds/RHDS (using commands like dscreate, configuration parameters like
nsAccountLock and nsuniqueid, and references to RHDS). Remove OpenLDAP from the
supported LDAP server software list in the prerequisites section, or update it
to clarify that this guide provides setup instructions specifically for 389
Directory Server and Red Hat Directory Server only. This will prevent OpenLDAP
users from following an incomplete setup path.
- Around line 472-479: The recommended procedure in the LDAP removal section
incorrectly states that triggering a full sync will remove orphaned Keycloak
records for deleted LDAP users. This is factually incorrect. Keycloak's
full-sync does not automatically remove deleted LDAP users; orphan removal is
actually reactive and only occurs when "Remove invalid users during searches" is
enabled AND that specific user is accessed (login, admin search, or API lookup).
Rewrite the procedure section to accurately explain either the reactive "Remove
invalid users during searches" mechanism (noting it requires per-user access to
trigger removal), or document the manual "Remove imported" action in the Admin
Console (with a warning that this removes all imported users, not just deleted
ones), or provide the actual working procedure for achieving deletion.
Additionally, update the synchronization behavior table that follows to ensure
it correctly reflects Keycloak's actual LDAP federation behavior regarding
orphan handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: osac-project/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: a3b91352-b886-460c-978a-14a3ff30e57c

📥 Commits

Reviewing files that changed from the base of the PR and between 4996321 and 0a399d2.

📒 Files selected for processing (1)
  • guides/ldap-keycloak-integration.md

Comment thread guides/ldap-keycloak-integration.md
Comment on lines +277 to +281
KC_TOKEN=$(curl -ks "${KC_URL}/realms/master/protocol/openid-connect/token" \
-d 'client_id=admin-cli' \
-d 'grant_type=password' \
-d 'username=admin' \
-d 'password=<admin-password>' | jq -r '.access_token')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Stop using curl -k in the Keycloak examples.

These snippets disable TLS verification (-k/-ks) while fetching admin tokens and calling the admin API. That normalizes an avoidable MITM risk on the control plane; if these are lab-only commands, label them as such. Otherwise, show the same flow without -k and require a trusted CA.

Suggested fix
- KC_TOKEN=$(curl -ks "${KC_URL}/realms/master/protocol/openid-connect/token" \
+ KC_TOKEN=$(curl -s "${KC_URL}/realms/master/protocol/openid-connect/token" \

Also applies to: 289-319, 348-355, 362-372, 397-415, 438-441, 513-519

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@guides/ldap-keycloak-integration.md` around lines 277 - 281, Remove the `-k`
and `-ks` flags from all curl commands in the Keycloak integration examples that
disable TLS verification, particularly in the token fetch command at the
KC_TOKEN assignment and all subsequent curl commands to the KC_URL endpoint.
Either ensure proper trusted CA certificate configuration is in place and
documented, or explicitly mark these commands as lab-only examples with
appropriate warnings about security implications. The affected sections include
the token retrieval curl command and all admin API calls throughout the guide at
the specified line ranges.

Comment thread guides/ldap-keycloak-integration.md Outdated
- Remove OpenLDAP from supported LDAP software (guide is 389-ds specific)
- Add TLS note explaining -k flag is for lab/self-signed environments
- Fix incorrect claim that full sync removes orphaned users
- Document correct Keycloak behavior for LDAP user deletion

Signed-off-by: Ofer Bochan <obochan@obochan-thinkpadp1gen7.rmtil.csb>
obochan-rh pushed a commit to obochan-rh/docs that referenced this pull request Aug 18, 2026
* NO-ISSUE: Add baremetal fulfillment repos

* NO-ISSUE: Add new baremetal repos to CLAUDE.md

Assisted-by: Claude Code <noreply@anthropic.com>
Signed-off-by: Adrien Gentil <agentil@redhat.com>

---------

Signed-off-by: Adrien Gentil <agentil@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant