genetic_forensic_portal.app.client package¶
This package contains clients that retrieve data and authentication/authorization information for the genetic forensic portal.
Right now, of course, these clients are largely simulating these interactions, but the idea is that they would be able to interact with the actual services once they exist.
If the portal needs to call other services in the future, they would be added here.
Current clients: - gf_api_client: A client that interacts with the genetic forensic API (but since one does not currently exist, it simulates these interactions but provides canned data). - keycloak_client: A client that interacts with a local Keycloak instance to make auth decisions.
Subpackages¶
- genetic_forensic_portal.app.client.models package
Submodules¶
genetic_forensic_portal.app.client.gf_api_client module¶
This module contains the client-side logic for interfacing with a (currently non-existent) Genetic Forensic API.
The functions in this module are placeholders for the real API calls that will be made in the future. They are designed to mimic the behavior of the real API calls, but with hard-coded responses. These modules have been designed in such a way that the real API calls can be easily swapped in when they are available. These functions also hook into a local client to check for user permissions before “calling” the API.
- genetic_forensic_portal.app.client.gf_api_client.get_all_analyses(sample_id)¶
Fetches all types of analyses for a given sample ID.
- Parameters:
sample_id (str) – The UUID of the sample.
- Returns:
An object containing results from all analysis types.
- Return type:
- genetic_forensic_portal.app.client.gf_api_client.get_analysis_status(sample_id)¶
Retrieves the status of the analysis based on the given UUID.
- genetic_forensic_portal.app.client.gf_api_client.get_familial_analysis(sample_id)¶
Retrieves the familial analysis for a sample
- Parameters:
sample_id (str) – The sample ID to get the familial analysis for
- Return type:
DataFrame
- genetic_forensic_portal.app.client.gf_api_client.get_scat_analysis(sample_id)¶
Gets the SCAT analysis for a sample
- genetic_forensic_portal.app.client.gf_api_client.get_scat_analysis_data(sample_id)¶
Gets the SCAT analysis data for a sample
- genetic_forensic_portal.app.client.gf_api_client.get_voronoi_analysis(sample_id)¶
Gets the Voronoi analysis for a sample
- genetic_forensic_portal.app.client.gf_api_client.get_voronoi_analysis_data(sample_id)¶
Gets the Voronoi analysis data for a sample
- genetic_forensic_portal.app.client.gf_api_client.list_all_analyses()¶
Lists UUIDs for all analyses
genetic_forensic_portal.app.client.keycloak_client module¶
This module contains real methods to log into a locally running Keycloak server and, using the returned token, get the roles of a user.
It also contains mock methods to simulate authorization decisions based on the roles of a user and the permissions of a resource. A chart of the permissions simulated herein can be found in the <project root>/docs/test-users.md file.
Basically, authentication (authN) is real, authorization (authZ) is mocked.
Before going to production, this module should be replaced with a real and robust authN/authZ system.
- genetic_forensic_portal.app.client.keycloak_client.check_create_access(user, roles)¶
Check if a user has access to create a resource.
- genetic_forensic_portal.app.client.keycloak_client.check_download_access(user, roles, analysis_id)¶
Check if a user has access to download a specific resource.
- genetic_forensic_portal.app.client.keycloak_client.check_list_all_access(user, roles)¶
Check if a user has access to list all resources.
- genetic_forensic_portal.app.client.keycloak_client.check_resource_access(user, roles, action, analysis_id)¶
Check if a user has access to a specific action on a specific resource.
Returns False if no permissions have been specified for the user, action, and resource.
- genetic_forensic_portal.app.client.keycloak_client.check_user_access(user, roles, action)¶
Check if a user has access to a specific action.
Returns None if the user has not been explicitly allowed or denied the action. Ultimate auth decisions can change based on the absence of those explicit allows/denies, which is why it’s a type we can return.
- genetic_forensic_portal.app.client.keycloak_client.check_view_access(user, roles, analysis_id)¶
Check if a user has access to view a specific resource.
- genetic_forensic_portal.app.client.keycloak_client.get_user_roles(token)¶
Get the roles of a user
- genetic_forensic_portal.app.client.keycloak_client.login_user(username, password)¶
Log in a user and return the token
- genetic_forensic_portal.app.client.keycloak_client.logout_user(token)¶
Logs out a user
- genetic_forensic_portal.app.client.keycloak_client.update_auth_cache(analysis_id, user, action, decision)¶
Updates a (simulated) local cache that maps user, action, and analysis_id to a boolean access decision.
This allows us to avoid calling the “auth server” multiple times for the same user, action, and analysis_id.