mdvtools.auth.authutils#
Attributes#
Functions#
|
Factory function to create an authentication provider. |
Determines the correct authentication method and returns an instance of the |
|
Validate the current user via Auth0 or Shibboleth. |
|
Attach the before_request auth logic to the Flask app. |
|
Check if cache needs to be refreshed based on time interval. |
|
Caches user details and their associated project permissions in memory. |
|
|
Updates the in-memory caches (user_cache, user_project_cache, all_users_cache, active_projects_cache) |
Module Contents#
- mdvtools.auth.authutils.create_auth_provider(auth_method: str, app)[source]#
Factory function to create an authentication provider.
- mdvtools.auth.authutils.get_auth_provider()[source]#
Determines the correct authentication method and returns an instance of the corresponding auth provider.
The resolution order is: 1. If DEFAULT_AUTH_METHOD in the app config is explicitly set to ‘dummy’,
the DummyAuthProvider is ALWAYS used. This is a developer override for safe local testing.
If ‘auth_method’ is present in the session, that method is used.
Otherwise, the value from the required DEFAULT_AUTH_METHOD app configuration is used.
- Raises:
ValueError – If DEFAULT_AUTH_METHOD is not configured in the application.
- mdvtools.auth.authutils.is_authenticated()[source]#
Validate the current user via Auth0 or Shibboleth.
- mdvtools.auth.authutils.register_before_request_auth(app)[source]#
Attach the before_request auth logic to the Flask app.
- mdvtools.auth.authutils.needs_cache_refresh()[source]#
Check if cache needs to be refreshed based on time interval.
- mdvtools.auth.authutils.cache_user_projects()[source]#
Caches user details and their associated project permissions in memory.
- mdvtools.auth.authutils.update_cache(user_id=None, project_id=None, user_data=None, project_data=None, permissions=None)[source]#
Updates the in-memory caches (user_cache, user_project_cache, all_users_cache, active_projects_cache) for the provided user and project details, including any changes in permissions.
- Parameters:
user_id – The ID of the user whose cache needs to be updated.
project_id – The ID of the project to be added or updated in the cache.
user_data – A dictionary containing the user’s details (if updating the user cache).
project_data – A dictionary containing the project’s details (if updating the project cache).
permissions – A dictionary containing the user’s permissions for a project (optional).