Skip to content

Commit

Permalink
fix: min valid period also for oidc-agent inside container
Browse files Browse the repository at this point in the history
  • Loading branch information
giosava94 committed Aug 28, 2024
1 parent fa3aaa7 commit 89c2a7e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/models/identity_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,28 @@ def retrieve_token(endpoint: str):
If the container name is set use perform a docker exec command, otherwise use a
local instance."""
settings = get_settings()
min_valid_period = 5 * 60 # 5 min

if settings.OIDC_AGENT_CONTAINER_NAME is not None:
token_cmd = subprocess.run(
[
"docker",
"exec",
settings.OIDC_AGENT_CONTAINER_NAME,
"oidc-token",
f"--time={min_valid_period}",
endpoint,
],
capture_output=True,
text=True,
)
if token_cmd.returncode > 0:
raise ValueError(token_cmd.stderr if token_cmd.stderr else token_cmd.stdout)
return token_cmd.stdout.strip("\n")
token = token_cmd.stdout.strip("\n")
return token

min_valid_period = 5 * 60 # 5 min
return get_access_token_by_issuer_url(endpoint, min_valid_period=min_valid_period)
token = get_access_token_by_issuer_url(endpoint, min_valid_period=min_valid_period)
return token


class SLA(SLABase):
Expand Down

0 comments on commit 89c2a7e

Please sign in to comment.