Skip to content

Commit f20febc

Browse files
committed
fix for workload pricipal bucket access
1 parent 88a2a1c commit f20febc

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/client/content/tools/tabs/split_embed.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,7 @@ def display_split_embed() -> None:
134134
file_sources = ["OCI", "Local", "Web"]
135135
oci_lookup = st_common.state_configs_lookup("oci_configs", "auth_profile")
136136
oci_setup = oci_lookup.get(state.client_settings["oci"].get("auth_profile"))
137-
if (
138-
not oci_setup
139-
or oci_setup.get("namespace") is None
140-
or (oci_setup.get("tenancy") is None and oci_setup.get("authentication") != "oke_workload_identity")
141-
):
137+
if not oci_setup or oci_setup.get("namespace") is None or oci_setup.get("tenancy") is None:
142138
st.warning("OCI is not fully configured, some functionality is disabled", icon="⚠️")
143139
file_sources.remove("OCI")
144140

src/server/api/utils/oci.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# spell-checker:ignore genai ocids ocid
66

77
import os
8+
import base64
9+
import json
810
from typing import Union
911
import urllib3.exceptions
1012

@@ -75,6 +77,13 @@ def init_client(
7577
logger.info("OCI Authentication with Workload Identity")
7678
oke_workload_signer = oci.auth.signers.get_oke_workload_identity_resource_principal_signer()
7779
client = client_type(config={"region": config_json["region"]}, signer=oke_workload_signer)
80+
if not config.tenancy:
81+
token = oke_workload_signer.get_security_token()
82+
payload_part = token.split(".")[1]
83+
padding = "=" * (-len(payload_part) % 4)
84+
decoded_bytes = base64.urlsafe_b64decode(payload_part + padding)
85+
payload = json.loads(decoded_bytes)
86+
config.tenancy = payload.get("tenant")
7887
elif config_json["authentication"] == "security_token" and config_json["security_token_file"]:
7988
logger.info("OCI Authentication with Security Token")
8089
token = None

src/server/api/v1/oci.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async def oci_get(
6666
async def oci_list_regions(
6767
auth_profile: schema.OCIProfileType,
6868
) -> list:
69-
"""Return a list of compartments"""
69+
"""Return a list of regions"""
7070
logger.debug("Received oci_list_regions - auth_profile: %s", auth_profile)
7171
try:
7272
oci_config = await oci_get(auth_profile=auth_profile)
@@ -84,7 +84,7 @@ async def oci_list_regions(
8484
async def oci_list_genai(
8585
auth_profile: schema.OCIProfileType,
8686
) -> list:
87-
"""Return a list of compartments"""
87+
"""Return a list of genai service models"""
8888
logger.debug("Received oci_list_genai - auth_profile: %s", auth_profile)
8989
try:
9090
oci_config = await oci_get(auth_profile=auth_profile)

0 commit comments

Comments
 (0)