Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tags=["Authentication"],
)
+# Class to extract the Bearer token from the request headers
+security = fastapi.security.HTTPBearer()
+
+def get_current_principal(
+ credentials: fastapi.security.HTTPAuthorizationCredentials = fastapi.Depends(security)
+):
+ """
+ This is the main function to check whether a client is authenticated.
+ It will fetch the Bearer token from the request header and return the
+ principal.
+ """
+ return get_principal(credentials.credentials)
+
class AuthResponse(pydantic.BaseModel):
# Token Type
type: str = "Bearer"