Repository navigation
feat: cap role description length and update timestamp on permission drops - #679
wgu-taylor-payne wants to merge 1 commit into
Conversation
|
Thanks for the pull request, @wgu-taylor-payne! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
9184a1a to
898089e
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Regression tests do not cover the POST/PATCH description limits or verify that grant drops advance timestamps only for affected custom roles.
2 open issues
What changed in this PR
Addresses #667’s follow-up to #647 by tightening custom-role validation and keeping role timestamps current after permission drops.
Changes:
- Limits descriptions to 500 characters on create and update.
- Updates affected roles’
updated_atusing database time when schema application drops grants.
| File | Description |
|---|---|
src/openedx_authz/rest_api/v1/serializers.py |
Adds description limits to both serializers. |
src/openedx_authz/engine/renderer.py |
Refreshes timestamps for roles whose grants are dropped. |
Review effort: Balanced
898089e to
104e051
Compare
…drops Addresses issue openedx#667 (follow-up from PR openedx#647 review): 1. Cap role description length at 500 characters in both CreateCustomRoleSerializer and UpdateCustomRoleSerializer. The field previously had no max length; a 10k+ character value was accepted during review. The longest existing role description is 201 characters, so 500 is a reasonable limit. 2. Update custom role updated_at timestamp when load_authz_schema --drop-custom-role-permissions removes grants. Previously the command deleted permission grants without touching the role row, so updated_at stayed old and GET /roles/ sorted by a stale timestamp. Per ADR 0036, permission changes should update the role's timestamp. Closes openedx#667
104e051 to
21e709b
Compare
rodmgwgu
left a comment
There was a problem hiding this comment.
Thanks for this, looking good, just a couple of nits to discuss.
|
|
||
| display_name = StrictCharField() | ||
| description = serializers.CharField(required=False, default="", allow_blank=True) | ||
| description = serializers.CharField(required=False, default="", allow_blank=True, max_length=500) |
There was a problem hiding this comment.
Should we also enforce this limit at the python API level at create_custom_role and update_custom_role in api/custom_roles.py? what do you think?
| FIXED_FIELDS = ("display_name", "scope_types") | ||
|
|
||
| description = serializers.CharField(required=False, allow_blank=True) | ||
| description = serializers.CharField(required=False, allow_blank=True, max_length=500) |
There was a problem hiding this comment.
Also, should we make this 500 a constant to avoid repeating it several times?

Follow-up to the #647 review. Closes #667.
Problem
descriptionhad no length limit, so the API accepted a 10,000+ character value.load_authz_schema --drop-custom-role-permissionsremoved grants from custom roles without touching the role row.updated_atstayed stale, soGET /roles/sorted those roles as if they had not changed. ADR 0036 treats a permission change as a change to the role.Changes
CreateCustomRoleSerializerandUpdateCustomRoleSerializercapdescriptionat 500 characters, and the API docs note the limit. The longest existing role description is 201 characters.SchemaApplier._drop_unlinked_custom_grantscollects the roles that lose a grant and sets theirupdated_atwith oneUPDATE ... SET updated_at = NOW(). It usesNow()becauseauto_nowdoes not fire onQuerySet.update(). The update runs inside the same apply transaction as the grant deletion, and roles that keep all their grants are left alone.Testing
updated_at, and a second custom role whose grants all stay keeps its old timestamp.max_lengthor theupdated_atupdate makes the matching tests fail.Manual check:
POST /api/authz/v1/roles/with a 501-characterdescription: expect 400 namingdescription.load_authz_schema --drop-custom-role-permissions. The role'supdated_atinGET /api/authz/v1/roles/should advance.Rollback
Revert this commit. There are no migrations. Descriptions stored before the revert stay valid either way.
Merge checklist:
AI Usage
Kiro was used to aid development and testing.