This repository has been archived by the owner on Mar 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yannic Schröer
authored and
Yannic Schröer
committed
Dec 22, 2021
1 parent
3fe5c2f
commit 9812b60
Showing
13 changed files
with
351 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from fastapi_keycloak.api import FastAPIKeycloak | ||
from fastapi_keycloak.model import OIDCUser, UsernamePassword, HTTPMethod, KeycloakError, KeycloakUser, KeycloakToken, KeycloakRole, KeycloakIdentityProvider | ||
|
||
__all__ = [FastAPIKeycloak.__name__, OIDCUser.__name__, UsernamePassword.__name__, HTTPMethod.__name__, KeycloakError.__name__, KeycloakUser.__name__, KeycloakToken.__name__, | ||
KeycloakRole.__name__, KeycloakIdentityProvider.__name__] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from fastapi import HTTPException | ||
|
||
|
||
class KeycloakError(Exception): | ||
""" Thrown if any response of keycloak does not match our expectation | ||
Attributes: | ||
status_code (int): The status code of the response received | ||
reason (str): The reason why the requests did fail | ||
""" | ||
|
||
def __init__(self, status_code: int, reason: str): | ||
self.status_code = status_code | ||
self.reason = reason | ||
super().__init__(f'HTTP {status_code}: {reason}') | ||
|
||
|
||
class MandatoryActionException(HTTPException): | ||
""" Throw if the exchange of username and password for an access token fails """ | ||
def __init__(self, detail: str) -> None: | ||
super().__init__(status_code=400, detail=detail) | ||
|
||
|
||
class UpdateUserLocaleException(MandatoryActionException): | ||
""" Throw if the exchange of username and password for an access token fails due to the update_user_locale requiredAction""" | ||
def __init__(self) -> None: | ||
super().__init__(detail=f"This user can't login until he updated his locale") | ||
|
||
|
||
class ConfigureTOTPException(MandatoryActionException): | ||
""" Throw if the exchange of username and password for an access token fails due to the CONFIGURE_TOTP requiredAction""" | ||
def __init__(self) -> None: | ||
super().__init__(detail=f"This user can't login until he configured TOTP") | ||
|
||
|
||
class VerifyEmailException(MandatoryActionException): | ||
""" Throw if the exchange of username and password for an access token fails due to the VERIFY_EMAIL requiredAction""" | ||
def __init__(self) -> None: | ||
super().__init__(detail=f"This user can't login until he verified his email") | ||
|
||
|
||
class UpdatePasswordException(MandatoryActionException): | ||
""" Throw if the exchange of username and password for an access token fails due to the UPDATE_PASSWORD requiredAction""" | ||
def __init__(self) -> None: | ||
super().__init__(detail=f"This user can't login until he updated his password") | ||
|
||
|
||
class UpdateProfileException(MandatoryActionException): | ||
""" Throw if the exchange of username and password for an access token fails due to the UPDATE_PROFILE requiredAction""" | ||
def __init__(self) -> None: | ||
super().__init__(detail=f"This user can't login until he updated his profile") |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.