-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat: split read vs write authz checks for group configurations #39010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ | |
| COURSES_PUBLISH_COURSE_CONTENT, | ||
| COURSES_VIEW_COURSE, | ||
| COURSES_VIEW_COURSE_UPDATES, | ||
| COURSES_VIEW_GROUP_CONFIGURATIONS, | ||
| COURSES_VIEW_PAGES_AND_RESOURCES, | ||
| ) | ||
| from organizations.api import add_organization_course, ensure_organization | ||
|
|
@@ -185,6 +186,21 @@ def get_course_and_check_manage_group_configurations_access(course_key, user, de | |
| return _get_course_block(course_key, depth) | ||
|
|
||
|
|
||
| def get_course_and_check_view_group_configurations_access(course_key, user, depth=0): | ||
| """ | ||
| Function used to validate read permission and return a course block | ||
| for group configurations list/detail GET requests. | ||
| """ | ||
| if not user_has_course_permission( | ||
| user=user, | ||
| authz_permission=COURSES_VIEW_GROUP_CONFIGURATIONS.identifier, | ||
| course_key=course_key, | ||
| legacy_permission=LegacyAuthoringPermission.READ | ||
| ): | ||
| raise PermissionDenied() | ||
| return _get_course_block(course_key, depth) | ||
|
|
||
|
|
||
| def reindex_course_and_check_access(course_key, user): | ||
| """ | ||
| Internal method used to restart indexing on a course. | ||
|
|
@@ -1915,7 +1931,10 @@ def group_configurations_list_handler(request, course_key_string): | |
| course_key = CourseKey.from_string(course_key_string) | ||
| store = modulestore() | ||
| with store.bulk_operations(course_key): | ||
| course = get_course_and_check_manage_group_configurations_access(course_key, request.user) | ||
| if request.method == 'GET': | ||
| course = get_course_and_check_view_group_configurations_access(course_key, request.user) | ||
| else: | ||
| course = get_course_and_check_manage_group_configurations_access(course_key, request.user) | ||
|
Comment on lines
+1934
to
+1937
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not to block this PR but I'm a bit concerned about adding more and more code branches when checking for permissions. I understand it's best to be surgical about the changes to not break other unrelated code sections but I'm not sure about the maintainability long-term. At least we should ensure that all the branches are thoroughly tested. Can we review testing and make sure we are?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might be missing L200 but that might be related to when this was introduced? |
||
|
|
||
| if 'text/html' in request.META.get('HTTP_ACCEPT', 'text/html'): | ||
| return redirect(get_group_configurations_url(course_key)) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the edit (POST) in group_configurations_list_handler ever tested?