Skip to content

AuthXDependency

authx.dependencies.AuthXDependency

AuthXDependency(_from, request=None, response=None)

Bases: Generic[T]

PARAMETER DESCRIPTION
_from

TYPE: AuthX[T]

request

TYPE: Optional[Request] DEFAULT: None

response

TYPE: Optional[Response] DEFAULT: None

Source code in authx/dependencies.py
def __init__(
    self,
    _from: "AuthX[T]",
    request: Optional[Request] = None,
    response: Optional[Response] = None,
) -> None:
    self._response = response
    self._request = request
    self._security = _from

request property

request

response property

response

create_access_token

create_access_token(uid, fresh=False, headers=None, expiry=None, data=None, audience=None, *args, **kwargs)
PARAMETER DESCRIPTION
uid

TYPE: str

fresh

TYPE: bool DEFAULT: False

headers

TYPE: Optional[Dict[str, Any]] DEFAULT: None

expiry

TYPE: Optional[DateTimeExpression] DEFAULT: None

data

TYPE: Optional[Dict[str, Any]] DEFAULT: None

audience

TYPE: Optional[StringOrSequence] DEFAULT: None

*args

DEFAULT: ()

**kwargs

DEFAULT: {}

Source code in authx/dependencies.py
def create_access_token(
    self,
    uid: str,
    fresh: bool = False,
    headers: Optional[Dict[str, Any]] = None,
    expiry: Optional[DateTimeExpression] = None,
    data: Optional[Dict[str, Any]] = None,
    audience: Optional[StringOrSequence] = None,
    *args,
    **kwargs,
) -> str:
    return self._security.create_access_token(
        uid, fresh, headers, expiry, data, audience, *args, **kwargs
    )

create_refresh_token

create_refresh_token(uid, headers=None, expiry=None, data=None, audience=None, *args, **kwargs)
PARAMETER DESCRIPTION
uid

TYPE: str

headers

TYPE: Optional[Dict[str, Any]] DEFAULT: None

expiry

TYPE: Optional[DateTimeExpression] DEFAULT: None

data

TYPE: Optional[Dict[str, Any]] DEFAULT: None

audience

TYPE: Optional[StringOrSequence] DEFAULT: None

*args

TYPE: Any DEFAULT: ()

**kwargs

TYPE: Any DEFAULT: {}

Source code in authx/dependencies.py
def create_refresh_token(
    self,
    uid: str,
    headers: Optional[Dict[str, Any]] = None,
    expiry: Optional[DateTimeExpression] = None,
    data: Optional[Dict[str, Any]] = None,
    audience: Optional[StringOrSequence] = None,
    *args: Any,
    **kwargs: Any,
) -> str:
    return self._security.create_refresh_token(
        uid, headers, expiry, data, audience, *args, **kwargs
    )

set_access_cookies

set_access_cookies(token, response=None, max_age=None)
PARAMETER DESCRIPTION
token

response

TYPE: Optional[Response] DEFAULT: None

max_age

TYPE: Optional[int] DEFAULT: None

Source code in authx/dependencies.py
def set_access_cookies(
    self, token, response: Optional[Response] = None, max_age: Optional[int] = None
):
    self._security.set_access_cookies(
        token=token, response=(response or self._response), max_age=max_age
    )

set_refresh_cookies

set_refresh_cookies(token, response=None, max_age=None)
PARAMETER DESCRIPTION
token

response

TYPE: Optional[Response] DEFAULT: None

max_age

TYPE: Optional[int] DEFAULT: None

Source code in authx/dependencies.py
def set_refresh_cookies(
    self, token, response: Optional[Response] = None, max_age: Optional[int] = None
):
    self._security.set_refresh_cookies(
        token=token, response=(response or self._response), max_age=max_age
    )

unset_access_cookies

unset_access_cookies(response=None)
PARAMETER DESCRIPTION
response

TYPE: Optional[Response] DEFAULT: None

Source code in authx/dependencies.py
def unset_access_cookies(self, response: Optional[Response] = None):
    self._security.unset_access_cookies(response=(response or self._response))

unset_refresh_cookies

unset_refresh_cookies(response=None)
PARAMETER DESCRIPTION
response

TYPE: Optional[Response] DEFAULT: None

Source code in authx/dependencies.py
def unset_refresh_cookies(self, response: Optional[Response] = None):
    self._security.unset_access_cookies(response=(response or self._response))

unset_cookies

unset_cookies(response=None)
PARAMETER DESCRIPTION
response

TYPE: Optional[Response] DEFAULT: None

Source code in authx/dependencies.py
def unset_cookies(self, response: Optional[Response] = None):
    self._security.unset_cookies(response=(response or self._response))

get_current_subject async

get_current_subject()
Source code in authx/dependencies.py
async def get_current_subject(self) -> Optional[T]:
    return await self._security.get_current_subject(request=self._request)