ogdc_runner.service.auth module¶
Module containing code related to authenticating an OGDC user.
Users authenticate by submitting a username and password to the token/ endpoint. If the username/password pair are valid, the response will contain a JSON Web Token (JWT) that can be used to authenticate other endpoints via a Authorization: Bearer token header.
- class ogdc_runner.service.auth.TokenResponse(**data: Any) None¶
Bases:
BaseModelModel representing token data returned by the app when auth is successful.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- ogdc_runner.service.auth.create_access_token(user: User) tuple[str, datetime]¶
Create a JWT access token for authentication.
Returns a tuple with the first element being the JWT access token and the second the expiration datetime in UTC.
- async ogdc_runner.service.auth.get_user_by_auth_token(token: Annotated[str, fastapi.Depends], session: Annotated[Session, fastapi.Depends]) User¶
Given a valid token, return the matching user.
- ogdc_runner.service.auth.token(form_data: Annotated[fastapi.security.OAuth2PasswordRequestForm, fastapi.Depends], session: Annotated[Session, fastapi.Depends]) TokenResponse¶
Given a username and password matching an existing user, return an access token.
Token can be used to authenticate with other endpoints that use the AuthenticatedUserDependency.
- Parameters:
form_data (
Annotated[OAuth2PasswordRequestForm])session (
Annotated[Session])
- Return type: