-
Notifications
You must be signed in to change notification settings - Fork 95
fix widget permission issue (No. 290, 303, 304) #1930
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
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 |
|---|---|---|
|
|
@@ -21,6 +21,9 @@ | |
| from sqlalchemy.orm.exc import NoResultFound | ||
| from werkzeug.exceptions import NotFound | ||
| from invenio_db import db | ||
| from weko_accounts.utils import roles_required | ||
| from weko_admin.config import WEKO_ADMIN_PERMISSION_ROLE_REPO, \ | ||
| WEKO_ADMIN_PERMISSION_ROLE_SYSTEM, WEKO_ADMIN_PERMISSION_ROLE_COMMUNITY | ||
|
|
||
| from .api import WidgetItems | ||
| from .config import WEKO_GRIDLAYOUT_ACCESS_COUNTER_TYPE | ||
|
|
@@ -296,6 +299,9 @@ def delete_widget_design_page(): | |
|
|
||
| @blueprint_api.route('/load_widget_type', methods=['GET']) | ||
| @login_required | ||
| @roles_required([WEKO_ADMIN_PERMISSION_ROLE_SYSTEM, | ||
|
Contributor
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. fix no.290 |
||
| WEKO_ADMIN_PERMISSION_ROLE_REPO, | ||
| WEKO_ADMIN_PERMISSION_ROLE_COMMUNITY]) | ||
|
Comment on lines
+302
to
+304
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. 🚨 issue (security): Triggers: When either widget endpoint is accessed with GET. Suggested fix: Use an authorization decorator that does not exempt GET requests, or explicitly enforce authentication and the allowed roles inside these views. |
||
| def load_widget_type(): | ||
| """Get Widget Type List.""" | ||
| results = get_widget_type_list() | ||
|
|
@@ -592,6 +598,9 @@ def upload_file(community_id): | |
| @blueprint.route('/widget/uploaded/<string:filename>/<string:community_id>', | ||
| methods=["GET"] | ||
| ) | ||
| @roles_required([WEKO_ADMIN_PERMISSION_ROLE_SYSTEM, | ||
|
Contributor
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. fix no.303, 304 |
||
| WEKO_ADMIN_PERMISSION_ROLE_REPO, | ||
| WEKO_ADMIN_PERMISSION_ROLE_COMMUNITY]) | ||
| def uploaded_file(filename, community_id=0): | ||
| """Get widget static file. | ||
|
|
||
|
|
||
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.
issue (testing): The
test_load_widget_typetest logs in withusers[id]['obj'].email, but the fixture's entry at index 4 hasemailset togeneraluser.emailwhileobjis incorrectly set tosysadmin; the case expecting a 403 therefore logs in as a system administrator and does not test the general user's permission.Triggers: When the parameterized case uses
id == 4.Suggested fix: Log in with
users[id]['email'], as the uploaded-file test does, or correct the fixture'sobjvalue before using it.