Expand description
Decides whether a user may perform an Action on a Resource.
A passing check hands out an AuthorizationToken. Its only field is private, so the token cannot be forged outside this crate and therefore proves that a check was made; callers that answer requests are expected to require one before responding.
ModulesΒ§
- error
- Contains error and result types for the authorization checks.
StructsΒ§
- Action
OnResource - Authorization
Token - Proof that an authorization check passed.
EnumsΒ§
- Action
- Describes an action that a user can take on some resource.
- Resource
- The target of an action.
- Role
Source π - Where a check gets the userβs roles: a snapshot the caller already holds, or a query this crate runs only if the check gets far enough to need one.
FunctionsΒ§
- access_
to_ πchatbot - access_
to_ πcourse_ material - authorize
- Checks whether the user may perform
actiononresource, fetching their roles. - authorize_
access_ to_ chatbot - Handles authorization for global chatbots and course chatbots
- authorize_
access_ to_ chatbot_ with_ fetched_ list_ of_ roles - Same as authorize_access_to_chatbot, but takes already-fetched roles instead of querying for them.
- authorize_
access_ to_ course_ material - Checks whether the user may view course material.
- authorize_
access_ to_ course_ material_ with_ fetched_ list_ of_ roles - Same as authorize_access_to_course_material, but takes already-fetched roles instead of querying for them.
- authorize_
with_ fetched_ list_ of_ roles - Same as authorize, but takes already-fetched roles instead of querying for them; use when checking several actions for the same user.
- can_
user_ view_ chapter - Checks whether the user may view a chapter, which may be closed to everyone but certain roles.
- can_
user_ view_ chapter_ with_ fetched_ list_ of_ roles - Same as can_user_view_chapter, but takes already-fetched roles instead of querying for them.
- check_
course_ πinstance_ permission - Also checks organization and course roles which are valid for course instances.
- check_
course_ πor_ exam_ permission - check_
course_ πpermission - Also checks organization role which is valid for courses.
- check_
exam_ πpermission - Also checks organization role which is valid for exams.
- check_
organization_ πpermission - check_
study_ πregistry_ permission - create_
authorization_ πerror - Builds the generic Forbidden error shown to the user, nesting the actual roles and attempted action in the source error so they only surface in logs.
- fetch_
user_ roles - The roles a user holds, for callers that check several permissions and want to pay for the roles query once by passing the result to authorize_with_fetched_list_of_roles.
- has_
permission π - is_
permitted - Whether
user_rolesallowactiononresource. - is_
user_ global_ admin - Whether the user holds a global admin role.
- skip_
authorize - Skips authorize(), for anonymous and test-user code paths where there is no user to check.
- user_
can_ πview_ chapter