I sent an email on Friday explaining the first step. For convenience, here's what the email said:
By Sunday night at midnight: Add a comment in your issue listing the restrictions that your privilege level should have for each field in each table (except the rootkey table, which we're removing).
Here's an example of what that last step should look like for a few fields if your assigned privilege level is Organizers -> Admins:
users table
level field
Can modify for other users
Can view for self, but not modify; this prevents a situation where there are no admins
fname field
Can modify for self
Can view for other users, but not modify
pwd field
Can modify for self, but not view
Can modify for other users, but not view; this allows admins to reset passwords
Step 2
Questions due by: Monday at 3 PMCode due by: Tuesday at noon
Now we need to take the data you've collected and turn it into code. I've created a class for each privilege level in the auth.levels package. Find the class that corresponds with your issue and develop the class.
Here's how permissions work:
When an operation is in progress, the backend calls the Permissions#checkPermission method with information about the requested operation. It expects that if the operation is in violation of the user's permissions, checkPermission will throw an AuthorizationException.
The Permissions class looks up the privilege level of the current user and obtains an instance of the corresponding Level subclass.
The Permissions class calls one of the checkPermission* methods in the Level subclass named according to the table the operation affects. For example, user-related operations call checkPermissionUsers because the user table is named USERS. It passes a Context object as an argument.
Your Level subclass calls methods on the Context object to describe the restrictions your privilege level places on the particular table/field.
It's up to you to figure out:
How to use the Context class
How to implement the abstract methods from Level
How to ensure you cover all possible cases, without leaving any gaps for anyone to get through
There are some very basic examples in auth.levels.LoggedOutLevel. You'll also want to take a close look at the auth.levels.Level and auth.levels.Level.Context classes.
Important:
When you begin, IntelliJ should detect that your class is invalid. You should see error indicators.
When you are done, IntelliJ must not show any errors or warnings for your class.
Your task is not complete until:
There are no warnings
There are no errors
All combinations of table/field are covered for your privilege level, except for UID fields, which aren't covered by permissions
IntelliJ tips:
F2 will jump to the next error. If there aren't any more errors, it will jump to the next warning.
Alt + Enter while the cursor is on an error/warning will provide options to automatically fix or aid in fixing the problem. You can use this to automaticlaly generate a lot of code that would normally be tedious to write.
The InitDB class has a list of all fields for each table. Use Ctrl/Cmd + O to jump to a class by name.
Fields are case-sensitive and will always be uppercase.
Checklist
Step 1
See https://github.com/massbay-cs/cs225-proj4/wiki/Authorization for the information that Prof. Moussavi has provided about authorization/privileges.
I sent an email on Friday explaining the first step. For convenience, here's what the email said:
By Sunday night at midnight: Add a comment in your issue listing the restrictions that your privilege level should have for each field in each table (except the rootkey table, which we're removing).
Here's an example of what that last step should look like for a few fields if your assigned privilege level is Organizers -> Admins:
Step 2
Questions due by: Monday at 3 PM Code due by: Tuesday at noon
Now we need to take the data you've collected and turn it into code. I've created a class for each privilege level in the
auth.levels
package. Find the class that corresponds with your issue and develop the class.Here's how permissions work:
Permissions#checkPermission
method with information about the requested operation. It expects that if the operation is in violation of the user's permissions, checkPermission will throw an AuthorizationException.checkPermission*
methods in the Level subclass named according to the table the operation affects. For example, user-related operations callcheckPermissionUsers
because the user table is namedUSERS
. It passes a Context object as an argument.It's up to you to figure out:
There are some very basic examples in
auth.levels.LoggedOutLevel
. You'll also want to take a close look at theauth.levels.Level
andauth.levels.Level.Context
classes.Important:
Your task is not complete until:
IntelliJ tips:
InitDB
class has a list of all fields for each table. Use Ctrl/Cmd + O to jump to a class by name.