Repository navigation
feat(domain): add permission_grant validation and principal existence check (BDMS-1534) - #1039
Open
likithabommasani21 wants to merge 1 commit into
Open
likithabommasani21 wants to merge 1 commit into
likithabommasani21 wants to merge 1 commit into
Conversation
… check (BDMS-1534)
Contributor
Coverage✅ 81.81% total — gate is 75%. Coverage for the Python files changed in this PR
|
likithabommasani21
requested review from
jacob-a-brown,
jirhiker and
ksmuczynski
November 4, 2026 23:21
This branch has not been deployed
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.
BDMS-1534: Add permission_grant validation and principal existence check
Why
This PR addresses the following problem / context:
permission_grant(BDMS-1532) needs validation before a grant is persisted: thatcapability/scope_type/principal_typeare real values, and that the principal being granted access actually exists where that's checkable.How
Implementation summary: the following was changed / added / removed:
domain/permission_grant.py: pure functionsvalidate_capability,validate_scope_type,validate_principal_type-- check a value againstcore/enums.py(lexicon-backed), no database.services/permission_grant_helper.py:principal_exists(), the one DB-dependent check. Onlyapi_keyhas a local table to check against;user/principal_grouppass through unchecked today.tests/test_permission_grant.py: 10 tests covering both the domain validators andprincipal_exists.Author Checklist
Reviewer Checklist
validate_capability/validate_scope_type/validate_principal_typecorrectly reject invalid values and accept all current lexicon terms.principal_existshandles a non-numericapi_keyid without raising (returnsFalse).user/principal_grouppassing through unchecked is acceptable for now, given no local table exists for either.domain/permission_grant.pystays free of database/service imports.Notes
Any special considerations, known limitations, risks, workarounds, or follow-up work to note?
principal_existscurrently assumes Authentik is the sole owner ofuser/principal_groupmembership, and that no local table for either exists in our database -- so there's nothing to check them against, and they pass through unchecked.api_keyhas one; if not, no change needed.