File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed
client/content/tools/tabs Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 55# spell-checker:ignore genai ocids ocid
66
77import os
8+ import base64
9+ import json
810from typing import Union
911import 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
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ async def oci_get(
6666async 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(
8484async 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 )
You can’t perform that action at this time.
0 commit comments