Skip to content

outposts/ldap: Handle comma-separated attributes in LDAP search requests#15000

Merged
BeryJu merged 1 commit into
goauthentik:mainfrom
dominic-r:sdko/comma-seperated-ldap-attr
Jun 11, 2025
Merged

outposts/ldap: Handle comma-separated attributes in LDAP search requests#15000
BeryJu merged 1 commit into
goauthentik:mainfrom
dominic-r:sdko/comma-seperated-ldap-attr

Conversation

@dominic-r
Copy link
Copy Markdown
Member

@dominic-r dominic-r commented Jun 11, 2025

Closes #13539

When LDAP clients like Jira submit search requests with comma-separated attributes (e.g., ["uid,cn,sn"] instead of ["uid", "cn", "sn"]), the LDAP outpost would return an "Operations Error". Ths fix adds attribute normalization to properly handle both formats by splitting comma separated attributes into individual entries.

(happy pr 15k hehe)

Details

REPLACE ME


Checklist

  • Local tests pass (ak test authentik/)
  • The code has been formatted (make lint-fix)

If an API change has been made

  • The API schema has been updated (make gen-build)

If changes to the frontend have been made

  • The code has been formatted (make web)

If applicable

  • The documentation has been updated
  • The documentation has been formatted (make website)

Closes #13539

When LDAP clients like Jira submit search requests with comma-separated attributes
(e.g., ["uid,cn,sn"] instead of ["uid", "cn", "sn"]), the LDAP outpost would return
an "Operations Error". Ths fix adds attribute normalization to properly handle
both formats by splitting comma separated attributes into individual entries.

Tests pass:
```
=== RUN   TestNormalizeAttributes
=== RUN   TestNormalizeAttributes/Empty_input
=== RUN   TestNormalizeAttributes/No_commas
=== RUN   TestNormalizeAttributes/Single_comma-separated_string
=== RUN   TestNormalizeAttributes/Mixed_input
=== RUN   TestNormalizeAttributes/With_spaces
=== RUN   TestNormalizeAttributes/Empty_parts
=== RUN   TestNormalizeAttributes/Single_element
=== RUN   TestNormalizeAttributes/Only_commas
=== RUN   TestNormalizeAttributes/Multiple_comma-separated_attributes
=== RUN   TestNormalizeAttributes/Case_preservation
=== RUN   TestNormalizeAttributes/Leading_and_trailing_spaces
=== RUN   TestNormalizeAttributes/Real-world_LDAP_attribute_examples
=== RUN   TestNormalizeAttributes/Jira-style_attribute_format
=== RUN   TestNormalizeAttributes/Single_string_with_single_attribute
=== RUN   TestNormalizeAttributes/Mix_of_standard_and_operational_attributes
--- PASS: TestNormalizeAttributes (0.00s)
    --- PASS: TestNormalizeAttributes/Empty_input (0.00s)
    --- PASS: TestNormalizeAttributes/No_commas (0.00s)
    --- PASS: TestNormalizeAttributes/Single_comma-separated_string (0.00s)
    --- PASS: TestNormalizeAttributes/Mixed_input (0.00s)
    --- PASS: TestNormalizeAttributes/With_spaces (0.00s)
    --- PASS: TestNormalizeAttributes/Empty_parts (0.00s)
    --- PASS: TestNormalizeAttributes/Single_element (0.00s)
    --- PASS: TestNormalizeAttributes/Only_commas (0.00s)
    --- PASS: TestNormalizeAttributes/Multiple_comma-separated_attributes (0.00s)
    --- PASS: TestNormalizeAttributes/Case_preservation (0.00s)
    --- PASS: TestNormalizeAttributes/Leading_and_trailing_spaces (0.00s)
    --- PASS: TestNormalizeAttributes/Real-world_LDAP_attribute_examples (0.00s)
    --- PASS: TestNormalizeAttributes/Jira-style_attribute_format (0.00s)
    --- PASS: TestNormalizeAttributes/Single_string_with_single_attribute (0.00s)
    --- PASS: TestNormalizeAttributes/Mix_of_standard_and_operational_attributes (0.00s)
PASS
ok      goauthentik.io/internal/outpost/ldap/search     0.194s
```
@dominic-r dominic-r requested a review from a team as a code owner June 11, 2025 03:31
@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 11, 2025

Deploy Preview for authentik-docs canceled.

Name Link
🔨 Latest commit 22c0884
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6848f8ae936a460008a0d5c1

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 11, 2025

Deploy Preview for authentik-storybook canceled.

Name Link
🔨 Latest commit 22c0884
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/6848f8ae936a460008a0d5bf

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.81%. Comparing base (9ffb244) to head (22c0884).
Report is 12 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15000   +/-   ##
=======================================
  Coverage   92.81%   92.81%           
=======================================
  Files         815      815           
  Lines       42105    42105           
=======================================
  Hits        39080    39080           
  Misses       3025     3025           
Flag Coverage Δ
e2e 47.74% <ø> (-0.01%) ⬇️
integration 24.33% <ø> (ø)
unit 90.65% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

{
name: "Single comma-separated string",
input: []string{"uid,cn,sn"},
expectedOutput: []string{"uid", "cn", "sn"},
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

According to https://datatracker.ietf.org/doc/html/rfc4511, it should be SEQUENCE OF selector LDAPString and SEQUENCE is a list of strings so this expected output would be correct

@rissson rissson requested a review from BeryJu June 11, 2025 15:28
@BeryJu BeryJu merged commit 5af2378 into goauthentik:main Jun 11, 2025
99 checks passed
@dominic-r dominic-r deleted the sdko/comma-seperated-ldap-attr branch June 11, 2025 16:19
kensternberg-authentik added a commit that referenced this pull request Jun 19, 2025
* main:
  website/docs: also hide the postgres pool_options setting (#15023)
  blueprints: sort schema items (#15022)
  website: bump the build group in /website with 6 updates (#15027)
  core: bump astral-sh/uv from 0.7.12 to 0.7.13 (#15028)
  core: bump twilio from 9.6.2 to 9.6.3 (#15029)
  core: bump sentry-sdk from 2.29.1 to 2.30.0 (#15030)
  core: bump kubernetes from 32.0.1 to 33.1.0 (#15031)
  core, web: update translations (#15026)
  web: bump the sentry group across 1 directory with 2 updates (#15025)
  translate: Updates for file web/xliff/en.xlf in zh_CN (#15018)
  lifecycle/aws: bump aws-cdk from 2.1018.0 to 2.1018.1 in /lifecycle/aws (#15016)
  website: bump postcss from 8.5.4 to 8.5.5 in /website (#15013)
  website: bump @types/node from 24.0.0 to 24.0.1 in /website (#15014)
  core: fix transaction test case (#15021)
  translate: Updates for file web/xliff/en.xlf in zh-Hans (#15019)
  website/docs: correct minor version in release notes (#15012)
  root: test label handling and error reporting in PytestTestRunner (#14000)
  outposts/ldap: Handle comma-separated attributes in LDAP search requests (#15000)
  website/integrations: standardize application slug placeholder in docs (#15007)
  core: bump django from 5.1.10 to 5.1.11 (#14997)
cavefire pushed a commit to cavefire/authentik that referenced this pull request Jun 24, 2025
…sts (goauthentik#15000)

Closes goauthentik#13539

When LDAP clients like Jira submit search requests with comma-separated attributes
(e.g., ["uid,cn,sn"] instead of ["uid", "cn", "sn"]), the LDAP outpost would return
an "Operations Error". Ths fix adds attribute normalization to properly handle
both formats by splitting comma separated attributes into individual entries.

Tests pass:
```
=== RUN   TestNormalizeAttributes
=== RUN   TestNormalizeAttributes/Empty_input
=== RUN   TestNormalizeAttributes/No_commas
=== RUN   TestNormalizeAttributes/Single_comma-separated_string
=== RUN   TestNormalizeAttributes/Mixed_input
=== RUN   TestNormalizeAttributes/With_spaces
=== RUN   TestNormalizeAttributes/Empty_parts
=== RUN   TestNormalizeAttributes/Single_element
=== RUN   TestNormalizeAttributes/Only_commas
=== RUN   TestNormalizeAttributes/Multiple_comma-separated_attributes
=== RUN   TestNormalizeAttributes/Case_preservation
=== RUN   TestNormalizeAttributes/Leading_and_trailing_spaces
=== RUN   TestNormalizeAttributes/Real-world_LDAP_attribute_examples
=== RUN   TestNormalizeAttributes/Jira-style_attribute_format
=== RUN   TestNormalizeAttributes/Single_string_with_single_attribute
=== RUN   TestNormalizeAttributes/Mix_of_standard_and_operational_attributes
--- PASS: TestNormalizeAttributes (0.00s)
    --- PASS: TestNormalizeAttributes/Empty_input (0.00s)
    --- PASS: TestNormalizeAttributes/No_commas (0.00s)
    --- PASS: TestNormalizeAttributes/Single_comma-separated_string (0.00s)
    --- PASS: TestNormalizeAttributes/Mixed_input (0.00s)
    --- PASS: TestNormalizeAttributes/With_spaces (0.00s)
    --- PASS: TestNormalizeAttributes/Empty_parts (0.00s)
    --- PASS: TestNormalizeAttributes/Single_element (0.00s)
    --- PASS: TestNormalizeAttributes/Only_commas (0.00s)
    --- PASS: TestNormalizeAttributes/Multiple_comma-separated_attributes (0.00s)
    --- PASS: TestNormalizeAttributes/Case_preservation (0.00s)
    --- PASS: TestNormalizeAttributes/Leading_and_trailing_spaces (0.00s)
    --- PASS: TestNormalizeAttributes/Real-world_LDAP_attribute_examples (0.00s)
    --- PASS: TestNormalizeAttributes/Jira-style_attribute_format (0.00s)
    --- PASS: TestNormalizeAttributes/Single_string_with_single_attribute (0.00s)
    --- PASS: TestNormalizeAttributes/Mix_of_standard_and_operational_attributes (0.00s)
PASS
ok      goauthentik.io/internal/outpost/ldap/search     0.194s
```
@dominic-r dominic-r self-assigned this Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Jira LDAP Queries are not working due to the Attributes format

2 participants