CSC/ECE 517 Fall 2023 - E2379. Reimplement authorization helper.rb
This wiki page is for the information regarding the changes made for the E2379 OSS assignment for Fall 2023, CSC/ECE 517.
Introduction
Expertiza currently uses session-based authentication in its AuthorizationHelper module. The reimplementation back end uses JSON Web Token (JWT) based authentication. This requires a redesign of the AuthorizationHelper module to accommodate JWT-based authentication.
About Helper
The AuthorizationHelper module provides methods to check a user's privileges and roles within the system. It allows you to determine if the current user has specific roles like Super-Admin, Admin, Instructor, TA, or Student. You can also check if the user is a participant in a particular assignment, instructs an assignment, or has TA mappings for an assignment. Additionally, it provides methods to identify if the current user can perform actions like submitting work, reviewing, or taking quizzes. These functions are essential for managing user permissions and access control in the application.
Methods to be implemented
1. `jwt_verify_and_decode(token)`: This method will verify and decode a JWT token and return the user's information, including role and claims. 2. `check_user_privileges(user_info, required_privilege)`: Given user information from the JWT and a required privilege, this method will determine if the user has the required privilege. 3. Update and adapt the existing methods to use JWT claims for authentication and authorization.