fix(auth): honor prefix in 'prefix:attr' regex field syntax#39
Merged
Conversation
Previously, get_attributes_regex_field returned the prefix as the attribute name to request from LDAP, and process_regex_field only used the prefix as a key — the value was never prefixed. For UCA's 'alumno:alumno' / 'pas:pas' / 'pdi:pdi' mappings this meant the wrong attribute was fetched and the role string was missing its prefix, so group matching silently failed. - get_attributes_regex_field: return the right-hand side of ':' as the attribute to look up. - process_regex_field: when 'prefix:attr' is used, look up 'attr' and prepend 'prefix' to each value (alumno + 'S' -> 'alumnoS'). Existing '+' concat and '**' prepend syntax are unchanged. Adds unit tests covering the colon prefix, the self-rename case, and the pre-existing syntaxes.
dkmstr
approved these changes
Jul 22, 2026
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.
Port of v4.0 fix (commits a470dba19 + 583d4b13c) to 5.0.
Problem
get_attributes_regex_fieldreturned the prefix as the LDAP attribute name, andprocess_regex_fieldonly used the prefix as a key — the value was never prefixed. For UCA'salumno:alumno/pas:pas/pdi:pdimappings this meant the wrong attribute was fetched and the role string was missing its prefix, so group matching silently failed.Fix
get_attributes_regex_field: return the right-hand side of:as the attribute to look up. Also add a**branch soattr**prefixrequests the actual attribute too.process_regex_field: whenprefix:attris used, look upattrand prependprefixto each value (e.g.alumno:alumno+S->alumnoS).Existing
+concat and**prepend syntax are unchanged.Tests
New
tests/core/util/test_auth_regex.pycovering colon prefix, self-rename,**prepend,+concat, plain attr, regex groups, andget_attributes_regex_fieldLDAP-request side.Rebuilt on current master (merge of master, ruff-format conflicts resolved).