Skip to content

Remote-Name header returns capitalized uid instead of LDAP cn — cn attribute never fetched - #1072

Open
tsushanth wants to merge 1 commit into
tinyauthapp:mainfrom
tsushanth:fix/Remote-Name-header-returns-capitalized-u-1786208583
Open

Remote-Name header returns capitalized uid instead of LDAP cn — cn attribute never fetched#1072
tsushanth wants to merge 1 commit into
tinyauthapp:mainfrom
tsushanth:fix/Remote-Name-header-returns-capitalized-u-1786208583

Conversation

@tsushanth

@tsushanth tsushanth commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Add "cn" to LDAP GetUserInfo attributes, propagate it through UserSearch.Name, and use it instead of Capitalize(username) when setting the LDAP user's display name in basicAuth, cookieAuth, and session creation

Found via automated repo scanning, fix written and reviewed before opening.

Summary by CodeRabbit

  • Bug Fixes
    • LDAP-authenticated users now see their directory name when available.
    • Improved name handling across session-cookie and basic authentication.
    • Added a fallback display name when no directory name is provided.

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 60d8b446-34dd-4d6a-a1ec-713c19f97526

📥 Commits

Reviewing files that changed from the base of the PR and between ad700e7 and e550f55.

📒 Files selected for processing (5)
  • internal/controller/user_controller.go
  • internal/middleware/context_middleware.go
  • internal/model/users.go
  • internal/service/auth_service.go
  • internal/service/ldap_service.go

📝 Walkthrough

Walkthrough

LDAP lookups now retrieve the LDAP cn attribute. The value flows through UserSearch.Name into session-cookie authentication, basic authentication, and LDAP session creation, with a capitalized username fallback.

Changes

LDAP Directory Name Propagation

Layer / File(s) Summary
Retrieve and expose LDAP common names
internal/model/users.go, internal/service/ldap_service.go, internal/service/auth_service.go
GetUserInfo retrieves cn and returns it through UserSearch.Name with the existing DN and email values.
Use directory names in authentication sessions
internal/middleware/context_middleware.go, internal/controller/user_controller.go
LDAP authentication contexts and sessions use search.Name when available. They otherwise use a capitalized username.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AuthService
  participant LDAPService
  participant ContextMiddleware
  participant UserController
  LDAPService-->>AuthService: Return dn, email, cn
  AuthService->>ContextMiddleware: Provide UserSearch.Name
  ContextMiddleware->>ContextMiddleware: Select directory name or capitalized username
  ContextMiddleware-->>UserController: Provide authenticated user context
  UserController->>UserController: Set session name when Name is available
Loading

Possibly related PRs

Suggested labels: lgtm

Suggested reviewers: steveiliop56

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the LDAP cn retrieval issue and the incorrect capitalized uid returned in the Remote-Name header.
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.
✨ 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.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/middleware/context_middleware.go 0.00% 8 Missing ⚠️
internal/service/ldap_service.go 0.00% 5 Missing ⚠️
internal/controller/user_controller.go 0.00% 2 Missing ⚠️
internal/service/auth_service.go 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant