server.web.routes.utils

Attributes

logger

Classes

User

User information from OIDC authentication.

Functions

to_user_dict(→ User)

Convert a dict to User TypedDict.

get_user(→ User)

Get the user from the session.

get_request_username(→ str)

Return the username part of the email address from the request.

user_in_group(→ bool)

Check if a user is a member of the specified group.

is_super_user(→ bool)

Check if a user is a member of the superuser group.

is_auth_enabled(→ bool)

Check if authentication is enabled.

create_anonymous_user(→ User)

Create an anonymous user for unauthenticated mode.

get_user_or_anonymous(→ User)

Get user or return anonymous user when auth is disabled.

Module Contents

server.web.routes.utils.logger
class server.web.routes.utils.User

Bases: TypedDict

User information from OIDC authentication.

Initialize self. See help(type(self)) for accurate signature.

sub: str
email: str
preferred_username: str
name: str
updated_at: int
given_name: str
family_name: str
groups: List[str]
nonce: str
at_hash: str
sid: str
aud: str
exp: int
iat: int
iss: str
server.web.routes.utils.to_user_dict(data: Mapping[str, Any]) User

Convert a dict to User TypedDict.

server.web.routes.utils.get_user(request: starlette.requests.Request) User

Get the user from the session.

A shared function to get the user from the session. Make it a method to mock in testing.

server.web.routes.utils.get_request_username(request: starlette.requests.Request) str

Return the username part of the email address from the request.

server.web.routes.utils.user_in_group(request: starlette.requests.Request, group: str) bool

Check if a user is a member of the specified group.

server.web.routes.utils.is_super_user(user: User) bool

Check if a user is a member of the superuser group.

Checks if a user is a member of the superuser group defined in the OIDC__ADMIN_GROUP configuration option.

server.web.routes.utils.is_auth_enabled() bool

Check if authentication is enabled.

server.web.routes.utils.create_anonymous_user() User

Create an anonymous user for unauthenticated mode.

server.web.routes.utils.get_user_or_anonymous(request: starlette.requests.Request) User

Get user or return anonymous user when auth is disabled.