rs_server_osam/main.md¶
osam main module.
__get_user_rights(user)
¶
Retrieves and constructs the S3 access rights policy for a specified user.
This function
- Looks up the user's Keycloak roles from the in-memory user store.
- Parses the roles to determine S3 access permissions (read, read+download, write+download).
- Generates a full S3 access policy document using predefined templates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user
|
str
|
Username of the account for which to retrieve access rights. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The constructed S3 access policy for the specified user. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
If the user is not found in the in-memory Keycloak user store (HTTP 404). |
Source code in docs/rs-server/services/osam/rs_server_osam/main.py
app_lifespan(fastapi_app)
async
¶
Lifespann app to be implemented with start up / stop logic
Source code in docs/rs-server/services/osam/rs_server_osam/main.py
auth_validation(request)
¶
Authorization validation: check that the user has the right role for a specific action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
HTTP request |
required |
Source code in docs/rs-server/services/osam/rs_server_osam/main.py
create_and_delete_obs_accounts(request)
async
¶
This endpoint is called by an RS operator with the rs_osam_update role. It triggers the synchronization of the creation and deletion of S3 Object Storage (OBS) accounts for all RS users, associated to their Keycloak account.
How it works:
-
When a new Keycloak user account is created, an associated OBS access account with no rights is created and linked to it.
-
When a Keycloak user account is deleted, the associated OBS access account is also deleted.
NOTE: to synchronize OBS user rights from Keycloak you then need to call the endpoint /storage/account/{user}/update.
Returns:¶
JSONResponse — Always a success message saying that the synchronization algorithm of the accounts started.
Source code in docs/rs-server/services/osam/rs_server_osam/main.py
get_obs_user_rights(request, user)
async
¶
This endpoint is called by an RS operator with the rs_osam_update role. It returns the S3 Object Storage (OBS) rights of any user, calculated from their associated Keycloak account.
When called, this endpoint will:
-
Read the user's roles from their Keycloak account.
-
Calculate the associated OBS access policy rights: they describe the buckets, paths, and permission levels (such as read, write and download) that the user has access to.
-
Return the access policy in the OBS JSON format, without applying them to the OBS user account.
Args¶
user (str) — The Keycloak username for which the access policy should be returned.
Returns¶
JSONResponse — The computed OBS access policy for the user.
Raises¶
404 — If the user does not exist in Keycloak.
Source code in docs/rs-server/services/osam/rs_server_osam/main.py
get_storage_configuration()
¶
This endpoint returns the bucket configuration configmap. This is used by different services in different namespaces.
This endpoint reads the CSV-based configuration file stored in Object Storage and returns it as a JSON array of arrays. Each inner array represents a row of the configuration file. If the configuration file is missing or cannot be read, an error response is returned.
Returns¶
list[list[str]] — The parsed configuration file as a JSON array.
Raises¶
404 — If the configuration file does not exist.
500 — If an unexpected error occurs while reading the file
Source code in docs/rs-server/services/osam/rs_server_osam/main.py
get_your_s3_credentials(request)
async
¶
This endpoint is called by any anthenticated user. It returns your personnal S3 credentials, so you can connect to the bucket where your products have been generated.
Returns¶
dict — A dictionary containing 'access_key', 'secret_key', 'endpoint', 'region' for the user's S3 storage.
Source code in docs/rs-server/services/osam/rs_server_osam/main.py
main_osam_task(timeout=60)
¶
Asynchronous background task that periodically links RS-Python users to observation users.
This function continuously waits for either a shutdown signal or an external trigger (users_sync_trigger)
to perform synchronization of Keycloak user attributes using link_rspython_users_and_obs_users().
The loop exits gracefully on shutdown signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
int
|
Number of seconds to wait before checking for shutdown or trigger events. Defaults to 60 seconds. |
60
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
This function does not explicitly raise |
Source code in docs/rs-server/services/osam/rs_server_osam/main.py
update_obs_user_rights(request, user)
async
¶
This endpoint is called by an RS operator with the rs_osam_update role. It updates the S3 Object Storage (OBS) rights of any user, calculated from their associated Keycloak account.
When called, this endpoint will:
-
Read the user's roles from their Keycloak account.
-
Calculate the associated OBS access policy rights: they describe the buckets, paths, and permission levels (such as read, write and download) that the user has access to.
-
Apply the access policy to the user's OBS account.
The operation ensures that the user's OBS permissions match their Keycloak permissions.
Args¶
user (str) — The Keycloak username for which the access policy should be applied.
Returns¶
JSONResponse — A JSON response confirming that the access policy has been applied.
Raises¶
404 — If the user does not exist in Keycloak.
400 — If the policy could not be applied by the Object Storage provider.