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 |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
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
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | |
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_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
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | |
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
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
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 |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
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 |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
get_keycloak_handler()
Used to get a copy of Keycloak handler
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
116 117 118 | |
get_ovh_handler()
Used to get a copy of Ovh handler
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
121 122 123 | |
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
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
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
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
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
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
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
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 | |