Repository navigation
feat(permission-profiles): enforce per-screen authorization and check the account on every request - #49
Merged
Conversation
The group filter reads the user from the database on each request and answers 401 account_inactive or session_expired (AUTH-18, AUTH-27). It runs before the password-change filter, so a deactivated account is refused as inactive first (AUTH-30).
RequireScreenAccess declares the screen and the minimum level of an endpoint; its filter reads the effective level from the database on each request and answers 403 forbidden below it (PERM-03, PERM-12, API-11).
…ry route RequireScreenAccess takes a second screen for the exception of PERM-04. A guard test fails the build when a /api/v1 route declares no screen and level and is neither anonymous nor on the signed-in-only list (API-11).
A pending account counts as not active, as in RefreshSessionHandler (AUTH-18, decision 21). Updates the test count of decision 26.
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.
Closes #9
What
Puts the authorization barrier on the server: a group filter checks on every authenticated request that the account exists and is active, and
RequireScreenAccess(screen, level)makes each endpoint declare the minimum level its operation needs (with an optional alternative screen for PERM-04). Both read the database on each request, with no cache.Why
PERM-03, PERM-12, PERM-13 (the server decides, and a profile change counts from the next request), AUTH-18 (a deactivated account is refused even with a valid token), AUTH-27, API-11 (every endpoint declares screen and level), and the new rules AUTH-30 (order of refusals) and PERM-26 (the 403 message). Decision 24.
Tests
me, sair e trocar a senha/api/v1declare tela e nível, seja anônima ou esteja na lista de "só logado"CheckScreenAccessHandlerwritten with the others)Pendingbranch ofCheckAccountHandlerhad no test; Red shown by changing!= Activeto== Inactive)T01, T02, T04, T05 and T14 had a Red (a compile error for a type that did not exist, or a wrong response). T03, T06–T13, T15–T18 and T20 passed at their first run, because an earlier cycle had already built the rule; the final report lists them as "sem Red", and mutations of the code (comparison operator, always allow, filter removed, alternative screen ignored) made the expected ones fail. T19 is a guard test and was born green; its Red was shown by removing
mefrom the list.How to test
From
backend/ControlService, with Docker Desktop running:Result: 0 warnings, 267 tests, 0 failures. No new endpoint is delivered, so the behavior is checked through the real pipeline by the integration tests, under
/api/v1/test-only/routes.Checklist
check.ps1passes locally: build without warnings and all testsdocs/, README) when behavior or decisions changed