Skip to content

Commit 964c531

Browse files
john-westcott-ivClaude
andauthored
[AAP-54064] Allowing for RBAC to not be installed in the JWT consumer (#848)
## Description <!-- Mandatory: Provide a clear, concise description of the changes and their purpose --> - What is being changed? Moves an import for rbac into an rbac specific function to allow for a jwt_consumer to not import the RBAC application. - Why is this change needed? For lighspeed. - How does this change address the issue? We should now be able to overide the process_rbac method without importing the RBAC app. ## Type of Change <!-- Mandatory: Check one or more boxes that apply --> - [X] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update - [ ] Test update - [ ] Refactoring (no functional changes) - [ ] Development environment change - [ ] Configuration change ## Self-Review Checklist <!-- These items help ensure quality - they complement our automated CI checks --> - [ ] I have performed a self-review of my code - [ ] I have added relevant comments to complex code sections - [ ] I have updated documentation where needed - [ ] I have considered the security impact of these changes - [ ] I have considered performance implications - [ ] I have thought about error handling and edge cases - [ ] I have tested the changes in my local environment ## Testing Instructions <!-- Optional for test-only changes. Mandatory for all other changes --> <!-- Must be detailed enough for reviewers to reproduce --> ### Prerequisites <!-- List any specific setup required --> ### Steps to Test 1. 2. 3. ### Expected Results <!-- Describe what should happen after following the steps --> ## Additional Context <!-- Optional but helpful information --> ### Required Actions <!-- Check if changes require work in other areas --> <!-- Remove section if no external actions needed --> - [ ] Requires documentation updates <!-- API docs, feature docs, deployment guides --> - [ ] Requires downstream repository changes <!-- Specify repos: django-ansible-base, eda-server, etc. --> - [ ] Requires infrastructure/deployment changes <!-- CI/CD, installer updates, new services --> - [ ] Requires coordination with other teams <!-- UI team, platform services, infrastructure --> - [ ] Blocked by PR/MR: #XXX <!-- Reference blocking PRs/MRs with brief context --> ### Screenshots/Logs <!-- Add if relevant to demonstrate the changes --> Co-authored-by: Claude <[email protected]>
1 parent 2486153 commit 964c531

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ansible_base/jwt_consumer/common/auth.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from ansible_base.lib.logging.runtime import log_excess_runtime
1717
from ansible_base.lib.utils.auth import get_user_by_ansible_id
1818
from ansible_base.lib.utils.translations import translatableConditionally as _
19-
from ansible_base.rbac.claims import get_claims_hash, get_user_claims, get_user_claims_hashable_form, save_user_claims
2019
from ansible_base.resource_registry.models import Resource, ResourceType
2120
from ansible_base.resource_registry.rest_client import get_resource_server_client
2221
from ansible_base.resource_registry.signals.handlers import no_reverse_sync
@@ -230,6 +229,8 @@ def process_rbac_permissions(self):
230229
"""
231230
Process RBAC permissions using claims hash logic
232231
"""
232+
from ansible_base.rbac.claims import get_claims_hash, get_user_claims, get_user_claims_hashable_form, save_user_claims
233+
233234
if self.token is None or self.user is None:
234235
logger.error("Unable to process rbac permissions because user or token is not defined")
235236
return

test_app/tests/jwt_consumer/common/test_auth.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,11 +480,11 @@ def test_process_rbac_permissions_cache_scenarios(
480480
with (
481481
mock.patch.object(authentication.cache, 'get_cached_claims_hash') as mock_get_cache,
482482
mock.patch.object(authentication.cache, 'cache_claims_hash') as mock_set_cache,
483-
mock.patch('ansible_base.jwt_consumer.common.auth.get_user_claims') as mock_get_claims,
484-
mock.patch('ansible_base.jwt_consumer.common.auth.get_user_claims_hashable_form') as mock_get_hashable,
485-
mock.patch('ansible_base.jwt_consumer.common.auth.get_claims_hash') as mock_get_hash,
483+
mock.patch('ansible_base.rbac.claims.get_user_claims') as mock_get_claims,
484+
mock.patch('ansible_base.rbac.claims.get_user_claims_hashable_form') as mock_get_hashable,
485+
mock.patch('ansible_base.rbac.claims.get_claims_hash') as mock_get_hash,
486486
mock.patch.object(authentication, '_fetch_jwt_claims_from_gateway') as mock_gateway,
487-
mock.patch('ansible_base.jwt_consumer.common.auth.save_user_claims') as mock_apply,
487+
mock.patch('ansible_base.rbac.claims.save_user_claims') as mock_apply,
488488
):
489489

490490
# Setup mocks

0 commit comments

Comments
 (0)