rs_server_osam/tasks.md
Main tasks executed by OSAM service.
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
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | |
build_s3_rights(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
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 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 | |
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
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
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
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
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
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 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 | |
get_keycloak_handler()
Used to get a copy of Keycloak handler
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
96 97 98 | |
get_ovh_handler()
Used to get a copy of Ovh handler
Source code in docs/rs-server/services/osam/rs_server_osam/tasks.py
101 102 103 | |
get_user_s3_credentials(user)
Retrieves the S3 access and secret keys for a given user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user
|
str
|
The 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
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
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
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
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
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
update_s3_rights_lists(s3_rights)
Constructs the final user S3 access policy document for ovhbased 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
394 395 396 397 398 399 400 401 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 463 464 465 466 467 468 469 470 471 472 473 474 475 | |