server.web.routes.utils

Attributes

_CONFIG

logger

Classes

User

dict() -> new empty dictionary

Functions

to_user_dict(→ User)

to_user_dict.

get_user(→ User)

get_user.

get_request_username(→ str)

get_request_username.

user_in_group(→ bool)

user_in_group.

is_super_user(→ bool)

is_super_user.

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._CONFIG[source]
server.web.routes.utils.logger[source]
class server.web.routes.utils.User[source]

Bases: typing_extensions.TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

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

to_user_dict.

Converts dict to User TypedDict.

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

get_user.

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[source]

get_request_username.

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

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

user_in_group.

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

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

is_super_user.

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[source]

Check if authentication is enabled.

server.web.routes.utils.create_anonymous_user() User[source]

Create an anonymous user for unauthenticated mode.

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

Get user or return anonymous user when auth is disabled.