fastapi_aad_auth.config¶
fastapi_aad_auth configuration options.
- class fastapi_aad_auth.config.AuthSessionConfig(**kwargs)[source]¶
Authentication Session configuration.
Contains secret and salt information (should be set as environment variables in a multi-worker/multi-processing environment to enable authentication across workers)
- Keyword Arguments
secret (pydantic.types.SecretStr) -- Secret used for encoding authentication information (Can be set by
SESSION_AUTH_SECRET
environment variable)salt (pydantic.types.SecretStr) -- Salt used for encoding authentication information (Can be set by
SESSION_AUTH_SALT
environment variable)
Initialise the config object.
- class fastapi_aad_auth.config.BaseSettings(**kwargs)[source]¶
Allow deprecations in the BaseSettings object.
Initialise the config object.
- class fastapi_aad_auth.config.Config(**kwargs)[source]¶
The overall configuration for the AAD authentication.
Provides the overall configuration and parameters.
- Keyword Arguments
enabled (bool) -- Enable authentication [default:
True
] (Can be set byFASTAPI_AUTH_ENABLED
environment variable)providers (list) -- The provider configurations to use
aad (fastapi_aad_auth.providers.aad.AADConfig) -- AAD Configuration information Field will be deprecated in version 0.2.0, and is replaced by Config.providers
auth_session (fastapi_aad_auth.config.AuthSessionConfig) -- The configuration for encoding the authentication information in the session
routing (fastapi_aad_auth.config.RoutingConfig) -- Configuration for routing
session (fastapi_aad_auth.config.SessionConfig) -- Configuration for the session middleware
login_ui (fastapi_aad_auth.config.LoginUIConfig) -- Login UI Configuration
user_klass (type) -- User class to use within the AADOAuthBackend, this will be treated as an import path if provided as a string, with the last part the class to load [default:
fastapi_aad_auth._base.state.User
] (Can be set byFASTAPI_AUTH_USER_KLASS
environment variable)
Initialise the config object.
- class fastapi_aad_auth.config.LoginUIConfig(**kwargs)[source]¶
Configuration for the application Login UI.
Includes the application name, template file, error template file, static directory, path to mount the login static information to, and the context.
- Keyword Arguments
app_name (str) -- Application name to show on the Login UI page (Can be set by
APP_NAME
environment variable)template_file (pydantic.types.FilePath) -- The jinja2 template to use for the login screen [default:
fastapi_aad_auth\ui\login.html
] (Can be set byFASTAPI_AUTH_LOGIN_TEMPLATE_FILE
environment variable)error_template_file (pydantic.types.FilePath) -- The jinja2 template to use for error information [default:
fastapi_aad_auth\ui\error.html
] (Can be set byFASTAPI_AUTH_LOGIN_ERROR_TEMPLATE_FILE
environment variable)user_template_file (pydantic.types.FilePath) -- The jinja2 template to use for the user view [default:
fastapi_aad_auth\ui\user.html
] (Can be set byFASTAPI_AUTH_USER_TEMPLATE_FILE
environment variable)static_directory (pydantic.types.DirectoryPath) -- Static path for the UI components [default:
fastapi_aad_auth\ui\static
] (Can be set byFASTAPI_AUTH_LOGIN_STATIC_DIR
environment variable)static_path (str) -- Path to mount the login static dir in [default:
/static-login
] (Can be set byFASTAPI_AUTH_LOGIN_STATIC_PATH
environment variable)context (dict) -- Any additional context variables required for the template
ui_klass (type) -- UI class to use to handle creating and returning the routes for the login, error and user screens, this will be treated as an import path if provided as a string, with the last part the class to load [default:
fastapi_aad_auth.ui:UI
] (Can be set byFASTAPI_AUTH_UI_KLASS
environment variable)
Initialise the config object.
- class fastapi_aad_auth.config.RoutingConfig(**kwargs)[source]¶
Configuration for authentication related routing.
Includes
logout_path
,login_path
, andlogin_redirect_path
(defaults should be fine for most use-cases).There are also the
landing_path
for the login page, as well as thehome_path
for the home page (defaults to the application root), and thepost_logout_path
for any specific routing once a logout has completed.- Keyword Arguments
login_path (str) -- Path for initiating the AAD oauth call Field will be deprecated in version 0.2.0, and is replaced by Routing.oauth_base_route - To access the new behaviour, set this value to None or an empty string [default:
/login/oauth
] (Can be set byFASTAPI_AUTH_LOGIN_ROUTE
environment variable)login_redirect_path (str) -- Path for handling the AAD redirect call Field will be deprecated in version 0.2.0, and is replaced by Routing.oauth_base_route - To access the new behaviour, set this value to None or an empty string [default:
/login/oauth/redirect
] (Can be set byFASTAPI_AUTH_LOGIN_REDIRECT_ROUTE
environment variable)oauth_base_route (str) -- Base Path for initiating the oauth calls [default:
/oauth
] (Can be set byFASTAPI_OAUTH_BASE_ROUTE
environment variable)logout_path (str) -- Path for processing a logout request [default:
/logout
] (Can be set byFASTAPI_AUTH_LOGOUT_ROUTE
environment variable)landing_path (str) -- Path for the login UI page [default:
/login
] (Can be set byFASTAPI_AUTH_LOGIN_UI_ROUTE
environment variable)user_path (str) -- Path for getting the user view [default:
/me
] (Can be set byFASTAPI_AUTH_USER_ROUTE
environment variable)home_path (str) -- Path for the application home page (default redirect if none provided) [default:
/
] (Can be set byAPP_HOME_ROUTE
environment variable)post_logout_path (str) -- Path for the redirect post logout - defaults to the landing path if not provided (Can be set by
FASTAPI_AUTH_POST_LOGOUT_ROUTE
environment variable)
Initialise the config object.
- property no_redirect_routes¶
Routes that we don't want to redirect to.
- class fastapi_aad_auth.config.SessionConfig(**kwargs)[source]¶
Configuration for session middleware.
Contains the session secret (should be set as environment variables in a multi-worker/multi-processing environment to enable authentication across workers)
Provides configuration for the fastapi session middleware
- Keyword Arguments
secret_key (pydantic.types.SecretStr) -- Secret used for the session middleware (Can be set by
SESSION_SECRET
environment variable)session_cookie (str) -- Cookie name for the session information [default:
session
] (Can be set bySESSION_COOKIE
environment variable)same_site (str) -- Cookie validation mode for the session [default:
lax
] (Can be set bySESSION_SAME_SITE
environment variable)https_only (bool) -- Allow the sessions only with https connections (Can be set by
SESSION_HTTPS_ONLY
environment variable)max_age (int) -- Maximum age for a session [default:
86400
] (Can be set bySESSION_MAX_AGE
environment variable)
Initialise the config object.