From becb9e34b55d4269498df3fb3e1554c7738ef22f Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 3 Jul 2021 22:00:10 +0200 Subject: [PATCH] outposts: fix docker controller not checking env correctly Signed-off-by: Jens Langhammer --- authentik/core/api/utils.py | 4 +++- authentik/outposts/api/outposts.py | 2 +- authentik/outposts/controllers/docker.py | 13 +++++++------ website/docs/releases/v2021.6.md | 3 +++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/authentik/core/api/utils.py b/authentik/core/api/utils.py index f768bb812..87aa87260 100644 --- a/authentik/core/api/utils.py +++ b/authentik/core/api/utils.py @@ -14,7 +14,9 @@ def is_dict(value: Any): """Ensure a value is a dictionary, useful for JSONFields""" if isinstance(value, dict): return - raise ValidationError("Value must be a dictionary, and not have any duplicate keys.") + raise ValidationError( + "Value must be a dictionary, and not have any duplicate keys." + ) class PassiveSerializer(Serializer): diff --git a/authentik/outposts/api/outposts.py b/authentik/outposts/api/outposts.py index 7e6972171..41cb8b0a4 100644 --- a/authentik/outposts/api/outposts.py +++ b/authentik/outposts/api/outposts.py @@ -51,7 +51,7 @@ class OutpostSerializer(ModelSerializer): raise ValidationError( ( f"Outpost type {self.initial_data['type']} can't be used with " - f"{provider.__class__.__name} providers." + f"{provider.__class__.__name__} providers." ) ) return providers diff --git a/authentik/outposts/controllers/docker.py b/authentik/outposts/controllers/docker.py index 53231f823..5f0d71d94 100644 --- a/authentik/outposts/controllers/docker.py +++ b/authentik/outposts/controllers/docker.py @@ -36,8 +36,10 @@ class DockerController(BaseController): def _get_env(self) -> dict[str, str]: return { - "AUTHENTIK_HOST": self.outpost.config.authentik_host, - "AUTHENTIK_INSECURE": str(self.outpost.config.authentik_host_insecure), + "AUTHENTIK_HOST": self.outpost.config.authentik_host.lower(), + "AUTHENTIK_INSECURE": str( + self.outpost.config.authentik_host_insecure + ).lower(), "AUTHENTIK_TOKEN": self.outpost.token.key, } @@ -45,11 +47,10 @@ class DockerController(BaseController): """Check if container's env is equal to what we would set. Return true if container needs to be rebuilt.""" should_be = self._get_env() - container_env = container.attrs.get("Config", {}).get("Env", {}) + container_env = container.attrs.get("Config", {}).get("Env", []) for key, expected_value in should_be.items(): - if key not in container_env: - continue - if container_env[key] != expected_value: + entry = f"{key.upper()}={expected_value}" + if entry not in container_env: return True return False diff --git a/website/docs/releases/v2021.6.md b/website/docs/releases/v2021.6.md index fae4006ca..fe3b0c89b 100644 --- a/website/docs/releases/v2021.6.md +++ b/website/docs/releases/v2021.6.md @@ -143,6 +143,9 @@ slug: "2021.6" - crypto: show both sha1 and sha256 fingerprints - flows: handle old cached flow plans better +- g: fix static and media caching not working properly +- outposts: fix container not being started after creation +- outposts: fix docker controller not checking env correctly - outposts/ldap: add support for boolean fields in ldap - outposts/proxy: always redirect to session-end interface on sign_out - providers/oauth2: add revoked field, create suspicious event when previous token is used