server.web.routes.utils ======================= .. py:module:: server.web.routes.utils Attributes ---------- .. autoapisummary:: server.web.routes.utils._CONFIG server.web.routes.utils.logger Classes ------- .. autoapisummary:: server.web.routes.utils.User Functions --------- .. autoapisummary:: server.web.routes.utils.to_user_dict server.web.routes.utils.get_user server.web.routes.utils.get_request_username server.web.routes.utils.user_in_group server.web.routes.utils.is_super_user server.web.routes.utils.is_auth_enabled server.web.routes.utils.create_anonymous_user server.web.routes.utils.get_user_or_anonymous Module Contents --------------- .. py:data:: _CONFIG .. py:data:: logger .. py:class:: User Bases: :py:obj:`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) .. py:attribute:: sub :type: str .. py:attribute:: email :type: str .. py:attribute:: preferred_username :type: str .. py:attribute:: name :type: str .. py:attribute:: updated_at :type: int .. py:attribute:: given_name :type: str .. py:attribute:: family_name :type: str .. py:attribute:: groups :type: List[str] .. py:attribute:: nonce :type: str .. py:attribute:: at_hash :type: str .. py:attribute:: sid :type: str .. py:attribute:: aud :type: str .. py:attribute:: exp :type: int .. py:attribute:: iat :type: int .. py:attribute:: iss :type: str .. py:function:: to_user_dict(data: Mapping[str, Any]) -> User to_user_dict. Converts dict to User TypedDict. .. py:function:: get_user(request: starlette.requests.Request) -> User get_user. A shared function to get the user from the session. Make it a method to mock in testing. .. py:function:: get_request_username(request: starlette.requests.Request) -> str get_request_username. Returns the username part of the email address from the request. .. py:function:: user_in_group(request: starlette.requests.Request, group: str) -> bool user_in_group. Check is a user is a member of the specified group. .. py:function:: is_super_user(user: User) -> bool is_super_user. Checks if a user is a member of the superuser group defined in the OIDC__ADMIN_GROUP configuration option. .. py:function:: is_auth_enabled() -> bool Check if authentication is enabled. .. py:function:: create_anonymous_user() -> User Create an anonymous user for unauthenticated mode. .. py:function:: get_user_or_anonymous(request: starlette.requests.Request) -> User Get user or return anonymous user when auth is disabled.