fix(secrets): scope-aware Azure credential presence reads in identity diagnostics
AZURE_CLIENT_SECRET and AZURE_FEDERATED_TOKEN_FILE presence checks in the Entra diagnostics path now read through the profile secret scope (Slack pattern) instead of raw os.environ.
This commit is contained in:
@@ -367,11 +367,27 @@ def describe_active_credential(config: Optional[EntraIdentityConfig] = None,
|
||||
info["tenant_id_env"] = os.environ["AZURE_TENANT_ID"].strip()
|
||||
|
||||
# Surface which env-var sources are present without minting yet.
|
||||
# Credential-bearing vars (AZURE_CLIENT_SECRET, AZURE_FEDERATED_TOKEN_FILE)
|
||||
# are read through the profile secret scope so a multiplexed profile's
|
||||
# diagnostics don't report another profile's env-bridged credentials;
|
||||
# unscoped CLI probes keep the legacy env read (Slack pattern).
|
||||
def _scoped_env(name: str) -> str:
|
||||
try:
|
||||
from agent.secret_scope import UnscopedSecretError, get_secret
|
||||
|
||||
try:
|
||||
return (get_secret(name) or "").strip()
|
||||
except UnscopedSecretError:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
return os.environ.get(name, "").strip()
|
||||
|
||||
env_sources = []
|
||||
if os.environ.get("AZURE_FEDERATED_TOKEN_FILE", "").strip():
|
||||
if _scoped_env("AZURE_FEDERATED_TOKEN_FILE"):
|
||||
env_sources.append("WorkloadIdentityCredential (AZURE_FEDERATED_TOKEN_FILE)")
|
||||
if (os.environ.get("AZURE_CLIENT_ID", "").strip()
|
||||
and os.environ.get("AZURE_CLIENT_SECRET", "").strip()
|
||||
and _scoped_env("AZURE_CLIENT_SECRET")
|
||||
and os.environ.get("AZURE_TENANT_ID", "").strip()):
|
||||
env_sources.append("EnvironmentCredential (client secret)")
|
||||
if os.environ.get("IDENTITY_ENDPOINT", "").strip() or os.environ.get("MSI_ENDPOINT", "").strip():
|
||||
|
||||
Reference in New Issue
Block a user