Skip to content

Commit 54842e6

Browse files
authored
fix: don't require keycloak algorithms in background_jobs (#869)
1 parent 1bb3fac commit 54842e6

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

bases/renku_data_services/data_api/dependencies.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@ def from_env(cls, prefix: str = "") -> "DependencyManager":
528528
message="The JWKS url for Keycloak cannot be found from the OIDC discovery endpoint."
529529
)
530530
jwks = PyJWKClient(jwks_url)
531+
if config.keycloak.algorithms is None:
532+
raise errors.ConfigurationError(message="At least one token signature algorithm is required.")
533+
531534
authenticator = KeycloakAuthenticator(jwks=jwks, algorithms=config.keycloak.algorithms)
532535
assert config.gitlab_url is not None
533536
gitlab_authenticator = GitlabAuthenticator(gitlab_url=config.gitlab_url)

bases/renku_data_services/secrets_storage_api/dependencies.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def from_env(cls) -> "DependencyManager":
5151
message="The JWKS url for Keycloak cannot be found from the OIDC discovery endpoint."
5252
)
5353
jwks = PyJWKClient(jwks_url)
54+
if config.keycloak.algorithms is None:
55+
raise errors.ConfigurationError(message="At least one token signature algorithm is required.")
56+
5457
authenticator = KeycloakAuthenticator(jwks=jwks, algorithms=config.keycloak.algorithms)
5558
core_client = K8sCoreClient()
5659

components/renku_data_services/app_config/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class KeycloakConfig:
2323
realm: str
2424
client_id: str
2525
client_secret: str
26-
algorithms: list[str]
26+
algorithms: list[str] | None
2727

2828
@classmethod
2929
def from_env(cls) -> "KeycloakConfig":
@@ -36,9 +36,9 @@ def from_env(cls) -> "KeycloakConfig":
3636
client_id = os.environ["KEYCLOAK_CLIENT_ID"]
3737
client_secret = os.environ["KEYCLOAK_CLIENT_SECRET"]
3838
algorithms = os.environ.get("KEYCLOAK_TOKEN_SIGNATURE_ALGS")
39-
if algorithms is None:
40-
raise errors.ConfigurationError(message="At least one token signature algorithm is required.")
41-
algorithms_lst = [i.strip() for i in algorithms.split(",")]
39+
algorithms_lst = None
40+
if algorithms is not None:
41+
algorithms_lst = [i.strip() for i in algorithms.split(",")]
4242
return cls(
4343
url=url,
4444
realm=realm,

0 commit comments

Comments
 (0)