Expand description
Common functionality related to authorization
StructsΒ§
- Extractor for an authenticated user.
- Validates that user has right to function
- Responder for AuthorizationToken
- GraphQL
Request π - Moocfi
User π - Moocfi
User πResponse
EnumsΒ§
- Describes an action that a user can take on some resource.
- The target of an action.
ConstantsΒ§
- MOOCFI_
GRAPHQL_ πURL - SESSION_
KEY π
FunctionsΒ§
- HTTP Client used only for authenticating with TMC server. This function:
- Authenticates the user with mooc.fi, returning the authenticated user and their oauth token.
- Authenticates a test user with predefined credentials. Returns Ok(true) if authentication succeeds, Ok(false) if credentials are incorrect, and Err for other errors.
- The authorization token is the only way to return a controller result, and should only be used in controller functions that return a response to the user.
- Can be used to check whether user is allowed to view some course material
- Can be used to check whether user is allowed to view some course material
- Same as
authorize
, but takes as an argumentVec<Role>
so that we avoid fetching the roles from the database for optimization reasons. This is useful when weβre checking multiple authorizations at once. - Can be used to check whether user is allowed to view some course material. Chapters can be closed and and limited to certain people only.
- Also checks organization and course roles which are valid for course instances.
- Also checks organization role which is valid for courses.
- Also checks organization role which is valid for exams.
- Creates a ControllerError for authorization failures with more information in the source error
- Exchanges user credentials with TMC server to obtain an OAuth token.
- Forgets authentication from the current session, if any.
- Gets the rate limit protection API key from environment variables and converts it to a header value. This key is used to bypass rate limiting when making requests to TMC server.
- Checks if the user is authenticated in the given session.
- has_
permission π - Stores the user as authenticated in the given session.
- Skips the authorize() and returns AuthorizationToken, needed in functions with anonymous and test users
- For making sure the user saved in the session still exists in the database. Check the userβs existance when the session is at least 3 hours old, updates the session automatically, and returns an up-to-date AuthUser.