rs_server_osam/tasks.md¶
Main tasks executed by OSAM service.
add_default_bucket_access(bucket, user, read_set, write_set, download_set)
¶
Adds a default wildcard access path for a user within a specific S3 bucket.
This function constructs a standardized path of the form:
<bucket>/<user>/*/
and ensures that it is present in the provided access control sets (read, write, and download). The path is added only if it does not already exist in each respective set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bucket
|
str
|
The S3 bucket name. |
required |
user
|
str
|
The user identifier used to scope access within the bucket. |
required |
read_set
|
set[str]
|
Set of paths with read permissions. |
required |
write_set
|
set[str]
|
Set of paths with write permissions. |
required |
download_set
|
set[str]
|
Set of paths with download permissions. |
required |
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
apply_user_access_policy(user, current_rights)
¶
Apply access policy over an user in ovh
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
build_s3_rights(user, user_info)
¶
Builds the S3 access rights structure for a user based on their Keycloak roles.
This function classifies roles into read, write, and download operations, then computes the corresponding access rights by matching them against a configmap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user
|
str
|
Username used to build default bucket path prefixes. |
required |
user_info
|
dict
|
Dictionary containing user attributes, specifically the "keycloak_roles" key with a list of role strings. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
A dictionary with three keys: - "read": List of read-only access paths. - "read_download": List of read+download access paths. - "write_download": List of write+download access paths. |
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
build_users_data_map()
¶
Builds a dictionary mapping usernames to their associated user data.
For each user retrieved from Keycloak, this function gathers: - Custom attributes from Keycloak - Assigned Keycloak roles
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
A dictionary where each key is a username and the value is another dictionary containing: - "keycloak_attribute": Custom user attribute from Keycloak - "keycloak_roles": List of roles assigned to the user |
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
create_obs_user_account_for_keycloak_user(keycloak_user)
¶
Creates an OBS user and links it to a Keycloak user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keycloak_user
|
dict
|
A dictionary representing the Keycloak user. |
required |
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
delete_obs_user_account_if_not_used_by_keycloak_account(obs_user, keycloak_users)
¶
Deletes an OBS user if it is not linked to any Keycloak user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs_user
|
dict
|
Dictionary representing the OBS user. |
required |
keycloak_users
|
list[dict]
|
List of Keycloak user dictionaries. |
required |
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
get_keycloak_handler()
¶
get_ovh_handler()
¶
get_user_s3_credentials(kc_user)
¶
Retrieves the S3 access and secret keys for a given user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kc_user
|
str
|
The Keycloak username for whom to retrieve S3 credentials. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary containing 'access_key', 'secret_key', 'endpoint', 'region' |
dict
|
for the user's S3 storage. |
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
link_rspython_users_and_obs_users()
¶
Coordinates linking between Keycloak users and OVH object storage (OBS) users.
- Retrieves Keycloak and OBS users.
- Optionally links or removes users based on whether mappings exist.
Note
The linking/unlinking logic is currently commented out and should be implemented based on specific integration rules.
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
traced_function(name=None)
¶
Decorator to trace the execution of a function using OpenTelemetry spans.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Custom name for the span. Defaults to the function's name. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Callable |
A wrapped function with tracing enabled. |
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
update_s3_rights_lists(s3_rights)
¶
Constructs the final user S3 access policy document for ovh based on the provided access rights.
This function takes access permissions derived from a user's Keycloak roles and configmap and builds a structured S3 access policy document. The policy includes separate blocks for read, read+download, and write+download permissions, formatted according to OVH-compatible bucket and object prefixes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s3_rights
|
dict
|
A dictionary of categorized access paths per permission type. Expected keys include: - 'read': list of paths with read-only access. - 'read_download': list of paths with read + download access. - 'write_download': list of paths with write + download access. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
A complete S3 access policy document including version and statements, ready to be applied to an OVH S3 user. |
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | |