-
Notifications
You must be signed in to change notification settings - Fork 0
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
Assign HQ-defined roles to CCA user #59
Changes from 26 commits
62d687c
04a76fd
db99e5c
907919a
1e4adea
c67ebfc
acbdf3b
759d312
e2c63e2
a2dad52
6d5fa58
b244166
ebb1346
1c90bba
49338a7
f6e5996
816f1f1
2670e6b
a6800b2
49a96a6
d42e09b
caec3aa
5efceb6
cb57fa6
f5384d1
4d52e10
116c060
6cae9cb
75e294d
4f3d65f
0c27235
6928d00
4196ab5
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 |
---|---|---|
|
@@ -2,3 +2,53 @@ | |
HQ_DATABASE_NAME = "HQ Data" | ||
|
||
OAUTH2_DATABASE_NAME = "oauth2-server-data" | ||
|
||
HQ_USER_ROLE_NAME = "hq_user" | ||
|
||
HQ_ROLE_NAME_MAPPING = { | ||
"gamma": "Gamma", | ||
"dataset_editor": "dataset_editor", | ||
"sql_lab": "sql_lab", | ||
} | ||
|
||
# Permissions | ||
SCHEMA_ACCESS_PERMISSION = "schema_access" | ||
MENU_ACCESS_PERMISSION = "menu_access" | ||
|
||
CAN_SHOW_PERMISSION = "can_show" | ||
CAN_LIST_PERMISSION = "can_list" | ||
CAN_GET_PERMISSION = "can_get" | ||
CAN_EXTERNAL_METADATA_PERMISSION = "can_external_metadata" | ||
CAN_EXTERNAL_METADATA_BY_NAME_PERMISSION = "can_external_metadata_by_name" | ||
CAN_READ_PERMISSION = "can_read" | ||
|
||
READ_ONLY_PERMISSIONS = [ | ||
CAN_SHOW_PERMISSION, | ||
CAN_LIST_PERMISSION, | ||
CAN_GET_PERMISSION, | ||
CAN_EXTERNAL_METADATA_PERMISSION, | ||
CAN_EXTERNAL_METADATA_BY_NAME_PERMISSION, | ||
CAN_READ_PERMISSION, | ||
] | ||
|
||
CAN_WRITE_PERMISSION = "can_write" | ||
CAN_EDIT_PERMISSION = "can_edit" | ||
CAN_ADD_PERMISSION = "can_add" | ||
CAN_DELETE_PERMISSIONS = "can_delete" | ||
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. it seems some of these are now redundant and can be removed. |
||
|
||
|
||
READ_ONLY_MENU_PERMISSIONS = { | ||
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. As I read this now, I believe at certain point we could see HQ setting read specifically for either of Chart, Dataset, Dashboard etc. 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. Correct. I played around a lot with how to best separate the read and write whilst keeping duplication to a minimum, but this current way of doing it feels like the most granular and configurable approach. You can set specific permissions for specific view/menu's. |
||
"Chart": READ_ONLY_PERMISSIONS, | ||
"Dataset": READ_ONLY_PERMISSIONS, | ||
"Dashboard": READ_ONLY_PERMISSIONS, | ||
"Datasource": READ_ONLY_PERMISSIONS, | ||
"OpenApi": READ_ONLY_PERMISSIONS, | ||
"Explore": READ_ONLY_PERMISSIONS, | ||
"Select a Domain": [MENU_ACCESS_PERMISSION], | ||
"Home": [MENU_ACCESS_PERMISSION], | ||
"Data": [MENU_ACCESS_PERMISSION], | ||
"Dashboards": [MENU_ACCESS_PERMISSION], | ||
"Charts": [MENU_ACCESS_PERMISSION], | ||
"Datasets": [MENU_ACCESS_PERMISSION], | ||
"ExploreFormDataRestApi": [CAN_READ_PERMISSION] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,15 @@ def set_oauth_session(self, provider, oauth_response): | |
# } | ||
session[SESSION_OAUTH_RESPONSE_KEY] = oauth_response | ||
|
||
def set_role_permissions(self, role, permissions): | ||
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. nit: its confusing that this is in the OAuth file. Isn't there a better place for this addition? 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. I was also thinking it feels a little out of place, but then all the permissions-related functionality sits in the class this class inherits from (methods like (This class is the security manager, which handles the roles, permissions etc.) |
||
""" | ||
This method sets the permissions on a role by overwriting the existing | ||
permissions | ||
""" | ||
role.permissions = [] | ||
for permission in permissions: | ||
self.add_permission_role(role, permission) | ||
|
||
|
||
def get_valid_cchq_oauth_token(): | ||
# Returns a valid working oauth access_token and also saves it on session | ||
|
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.
What does this permission allow? Reading external metadata, or setting external metadata, or something else?