Repository navigation
fix: system portal permission error - #7808
Merged
Merged
Conversation
shaohuzhang1
commented
Nov 10, 2026
| @has_permissions(PermissionConstants.PORTAL_READ, RoleConstants.ADMIN) | ||
| def get(self, request: Request): | ||
| return result.success(PortalSerializer().one()) | ||
|
|
Contributor
Author
There was a problem hiding this comment.
The diff itself looks correct and is a good security/permission fix: a read-only GET should require PORTAL_READ, not PORTAL_EDIT. No syntax or obvious functional irregularity is introduced by this change.
Things to verify:
-
@has_permissionssemantics- If it requires all arguments, then
PORTAL_READandADMINare both required. That may be intentional, but confirm it does not accidentally restrict access to admins only. - If it uses OR semantics, then any
ADMINbypassesPORTAL_READ. Confirm that is acceptable. - Mixing a permission constant and a role constant in the same decorator should be checked against the decorator implementation.
- If it requires all arguments, then
-
PermissionConstants.PORTAL_READexists and is registered- Ensure the constant is defined, included in migrations/seeding, and recognized by the permission-checking backend.
-
Read permission is sufficient
PortalSerializer().one()should be truly read-only. If it has side effects such as writes, cache invalidation, audit logging, or lazy creation, thenPORTAL_READmay be semantically wrong.
-
Sensitive data exposure
- Confirm that users with
PORTAL_READare allowed to see all fields returned byPortalSerializer.
- Confirm that users with
-
Tests
Add/update tests for:- Admin access
- User with
PORTAL_READaccess - User with only
PORTAL_EDITdenied - Anonymous/unauthenticated denied
- OpenAPI/schema generation still works
Optimization suggestions, if applicable:
- If
PortalSerializer().one()is called frequently and returns a singleton portal configuration, consider caching it. - If the serializer accesses related models, use
select_related/prefetch_relatedto avoid N+1 queries. - Ensure the permission decorator preserves function metadata for schema generation, especially with
@extend_schema.
Overall: the change is appropriate. The main risk is only in the exact semantics of @has_permissions and whether mixing PORTAL_READ with RoleConstants.ADMIN matches the intended access policy.
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.
fix: system portal permission error