AAP-45047: Fix allow map to process grant case in create_claims#959
AAP-45047: Fix allow map to process grant case in create_claims#959doziedotdev wants to merge 5 commits intoansible:develfrom
Conversation
The allow map type only handled the deny case (has_permission=False). When a trigger fired and has_permission=True, the code fell through to the catch-all else branch, logging "does not know how to be processed" and never setting access_allowed back to True. This broke the documented deny-all + allow-override pattern (the AAP 2.5+ equivalent of AUTH_LDAP_REQUIRE_GROUP). Fixes: AAP-45047, AAP-45394
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro Cache: Disabled due to data retention organization setting Knowledge base: Disabled due to 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe pull request modifies the authentication access control logic for 'allow' type maps, changing from conditionally updating access only when permission is False to always setting access_allowed based on the map's permission result. Comprehensive regression tests are added to cover allow/deny map interactions and edge cases. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
|
Hi @john-westcott-iv sorry about the ping Could you help review this when you get a chance? You identified the root cause line in AAP-45394. This PR fixes the allow map handling so it correctly grants access instead of only processing the deny case. 6+ support cases linked across AAP-45047 and AAP-45394, both open ~10 months. |
john-westcott-iv
left a comment
There was a problem hiding this comment.
📋 Code Review Summary
This PR fixes a bug where map_type='allow' in create_claims() only handled the deny case (has_permission=False). When a trigger fired and granted permission (has_permission=True), the code fell through to the catch-all else branch, logging an erroneous "does not know how to be processed" error and never setting access_allowed = True. This broke the documented deny-all + allow-override pattern (equivalent to AUTH_LDAP_REQUIRE_GROUP).
Files Reviewed: 2 files
Comments Posted: 2 review comments
🔍 Issues Found
- 0 security/safety issues
- 0 correctness/logic issues
- 1 minor suggestion (non-blocking)
- 1 positive observation
Overall Assessment
LGTM — This is a clean, minimal, and correct fix. The code change is a single-line semantic improvement that makes allow map handling consistent with is_superuser. The tests are comprehensive, covering the main fix scenario, the inverse (deny not overridden without match), group-based matching, and error-log regression. Well done.
General Feedback
- The fix correctly implements "last evaluated map wins" semantics for
allowmaps, which is consistent with howis_superusermaps already work (line 127:is_superuser = has_permission) - Test coverage is thorough: basic parametrized case, error-log regression (AAP-45047), deny-all override (AAP-45394), group-based positive and negative cases
- The removed comment ("If any rule does not allow we don't want to return this to true") was documenting the buggy one-way-deny-only behavior — removing it is the right call
- 6+ support cases across two JIRA tickets — great to see this finally fixed
| # If any rule does not allow we don't want to return this to true | ||
| access_allowed = False | ||
| if auth_map.map_type == 'allow': | ||
| access_allowed = has_permission |
There was a problem hiding this comment.
Clean fix. This now mirrors the is_superuser pattern on line 127 (is_superuser = has_permission), making the handling consistent across map types. The "last evaluated map wins" semantic is correct for ordered map evaluation.
The old code's and not has_permission guard meant allow maps could only deny — they could never grant access back. This simple change restores the intended bidirectional behavior.
| authenticator = local_authenticator_map.authenticator | ||
| res = claims.create_claims(authenticator, "username", {}, []) | ||
|
|
||
| assert res["access_allowed"] is True |
There was a problem hiding this comment.
Nit (non-blocking): Consider adding a reverse-order test — "allow-all (order=1) then deny-all (order=2)" — to verify that a later deny still correctly overrides an earlier allow. This would complete the ordering matrix:
| Map 1 | Map 2 | Expected |
|---|---|---|
| deny-all | allow-override | True ✅ (this test) |
| allow-all | deny-override | False (not tested) |
This is minor since the deny path was already working before this fix, but it would document the expected bidirectional "last map wins" contract and guard against future regressions.
|
DVCS PR Check Results: PR appears valid (JIRA key(s) found) |
Description
create_claims()function inclaims.pynow correctly handlesmap_type=allowwhen the trigger fires (has_permission=True), allowing a later allow map to override an earlier deny.has_permission=False). When a trigger fired andhas_permission=True, the code fell through to the catch-all else branch, logging "does not know how to be processed" and never settingaccess_allowed = True. This broke the documented deny-all + allow-override pattern.if auth_map.map_type == 'allow' and not has_permission:toif auth_map.map_type == 'allow':and setsaccess_allowed = has_permission. This handles both grant and deny cases and respects map ordering (later maps override earlier ones).Fixes: AAP-45047, AAP-45394
Type of Change
Self-Review Checklist
Testing Instructions
Prerequisites
Any authenticator (LDAP or Local Database).
Steps to Test
Expected Results
Before this fix
ERROR Map type allow of rule Allow Override does not know how to be processedWARNING User <username> failed an allow map and was denied accessSummary by CodeRabbit
Bug Fixes
Tests