Skip to content
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

feat: Add student role with minimal access in Superset #307

Merged
merged 7 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tutoraspects/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
"instructor": "Instructor",
"operator": "Operator",
"admin": "Admin",
"student": "Student",
},
),
("SUPERSET_ADMIN_EMAIL", "admin@openedx.org"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,11 @@ def _get_user_roles(self, username, language):
return ["instructor", f"instructor-{language}"]
else:
roles = self.extra_get_user_roles(username, decoded_access_token)
if bool("{{SUPERSET_BLOCK_STUDENT_ACCESS}}") and not roles:
raise Exception(f"Student {username} tried to access Superset")
return roles if roles else []
if roles:
return roles
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm somewhat concerned about this logic. Having a student role returned here would override SUPERSET_BLOCK_STUDENT_ACCESS. Maybe not a big deal, but can we add a check for that and throw an exception if it happens?

if not bool("{{SUPERSET_BLOCK_STUDENT_ACCESS}}"):
return ["student", f"student - {language}"]
Ian2012 marked this conversation as resolved.
Show resolved Hide resolved
raise Exception(f"Student {username} tried to access Superset")

def extra_get_user_roles(self, username, decoded_access_token):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@
"alpha": ["Alpha"], # Global staff
"gamma": ["Gamma"], # Course staff
"instructor": ["{{SUPERSET_ROLES_MAPPING.instructor}}"], # Course instructors
"student": ["{{SUPERSET_ROLES_MAPPING.student}}"], # Course students
"operator": ["{{SUPERSET_ROLES_MAPPING.operator}}"], # Installation operators
"public": ["Public"], # AKA anonymous users
}

for language in LANGUAGES.keys():
AUTH_ROLES_MAPPING[f"instructor-{language}"] = [f"{{SUPERSET_ROLES_MAPPING.instructor}} - {language}"]
AUTH_ROLES_MAPPING[f"student-{language}"] = [f"{{SUPERSET_ROLES_MAPPING.student}} - {language}"]
Ian2012 marked this conversation as resolved.
Show resolved Hide resolved


from openedx_sso_security_manager import OpenEdxSsoSecurityManager
Expand Down
Loading
Loading