Config
Functions:
|
Validate the given username and password with the Database |
|
Create a JWT with the given data and an Expires Delta |
|
Get the current user from a JWT |
|
Add the token to local Database and if someone try to authenticate again with these token it will fail |
- tools.security.authenticate_user(db_session: sqlalchemy.orm.session.Session, username: str, password: str) Optional[schemes.scheme_user.UserLogin] [source]
Validate the given username and password with the Database
- Parameters
db_session (Session) – Session to the Database
username (str) – Email of the user
password (str) – Password to verify
- Returns
Return the User OR False
- Return type
Union[UserLogin, None]
- tools.security.create_access_token(data: dict, expires_delta: Optional[datetime.timedelta] = None) str [source]
Create a JWT with the given data and an Expires Delta
- Parameters
data (dict) – Data to store in the Token
expires_delta (Optional[timedelta], optional) – Defaults to None.
- Returns
Created JWT
- Return type
str
- async tools.security.get_current_user(db_session: sqlalchemy.orm.session.Session = Depends(get_db), token: str = Depends(OAuth2PasswordBearerWithCookie)) schemes.scheme_user.UserLogin [source]
Get the current user from a JWT
- Parameters
db_session (Session, optional) – Session to the Database. Defaults to Depends(get_db).
token (str, optional) – JTW - Otherwise it takes it from /token. Defaults to Depends(oauth2_scheme).
- Raises
NotAuthorizedException – Exception if the the Token or the Data is invalid
- Returns
Logged in User from the Databse
- Return type
- async tools.security.invalid_access_token(token: str = Depends(OAuth2PasswordBearerWithCookie)) str [source]
Add the token to local Database and if someone try to authenticate again with these token it will fail
- Parameters
token (str, optional) – Token to be invalid. Defaults to Depends(oauth2_scheme).
- Returns
The removed Token
- Return type
str