Skip to content

fix(auth): honor prefix in 'prefix:attr' regex field syntax#39

Merged
dkmstr merged 2 commits into
masterfrom
master-fix-auth-regex-colon-prefix
Jul 22, 2026
Merged

fix(auth): honor prefix in 'prefix:attr' regex field syntax#39
dkmstr merged 2 commits into
masterfrom
master-fix-auth-regex-colon-prefix

Conversation

@aschumann-virtualcable

Copy link
Copy Markdown
Contributor

Port of v4.0 fix (commits a470dba19 + 583d4b13c) to 5.0.

Problem

get_attributes_regex_field returned the prefix as the LDAP attribute name, 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.

Fix

  • get_attributes_regex_field: return the right-hand side of : as the attribute to look up. Also add a ** branch so attr**prefix requests the actual attribute too.
  • process_regex_field: when prefix:attr is used, look up attr and prepend prefix to each value (e.g. alumno:alumno + S -> alumnoS).

Existing + concat and ** prepend syntax are unchanged.

Tests

New tests/core/util/test_auth_regex.py covering colon prefix, self-rename, ** prepend, + concat, plain attr, regex groups, and get_attributes_regex_field LDAP-request side.

Rebuilt on current master (merge of master, ruff-format conflicts resolved).

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.
@github-actions
github-actions Bot requested a review from dkmstr July 22, 2026 09:13
@dkmstr
dkmstr merged commit cc527c2 into master Jul 22, 2026
5 checks passed
@aschumann-virtualcable
aschumann-virtualcable deleted the master-fix-auth-regex-colon-prefix branch July 22, 2026 14:50
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.

2 participants