From 293a05cf452bb91714bc76b94139e916e7bece78 Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Wed, 5 Apr 2023 10:30:38 -0500 Subject: [PATCH 1/2] fix: Include 'CODER' env var prefix on group mappings --- codersdk/deployment.go | 2 +- docs/cli/server.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codersdk/deployment.go b/codersdk/deployment.go index ebace3488709d..44f67c3895cbb 100644 --- a/codersdk/deployment.go +++ b/codersdk/deployment.go @@ -900,7 +900,7 @@ when required by your organization's security policy.`, Name: "OIDC Group Mapping", Description: "A map of OIDC group IDs and the group in Coder it should map to. This is useful for when OIDC providers only return group IDs.", Flag: "oidc-group-mapping", - Env: "OIDC_GROUP_MAPPING", + Env: "CODER_OIDC_GROUP_MAPPING", Default: "{}", Value: &c.OIDC.GroupMapping, Group: &deploymentGroupOIDC, diff --git a/docs/cli/server.md b/docs/cli/server.md index e9c9e73bb68d7..accbcd7bb05d6 100644 --- a/docs/cli/server.md +++ b/docs/cli/server.md @@ -371,7 +371,7 @@ Change the OIDC default 'groups' claim field. By default, will be 'groups' if pr | | | | ----------- | -------------------------------------- | | Type | struct[map[string]string] | -| Environment | $OIDC_GROUP_MAPPING | +| Environment | $CODER_OIDC_GROUP_MAPPING | | Default | {} | A map of OIDC group IDs and the group in Coder it should map to. This is useful for when OIDC providers only return group IDs. From 46e5f430cae331feff75e45c32c983d56faec26c Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Wed, 5 Apr 2023 10:35:16 -0500 Subject: [PATCH 2/2] Unit test to force CODER prefix --- codersdk/deployment_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/codersdk/deployment_test.go b/codersdk/deployment_test.go index 3d73734b1c0de..ea48c1fbddd22 100644 --- a/codersdk/deployment_test.go +++ b/codersdk/deployment_test.go @@ -1,6 +1,7 @@ package codersdk_test import ( + "strings" "testing" "github.com/stretchr/testify/require" @@ -101,6 +102,12 @@ func TestDeploymentValues_HighlyConfigurable(t *testing.T) { t.Errorf("Option %q is excluded but has an env name", opt.Name) } + // Also check all env vars are prefixed with CODER_ + const prefix = "CODER_" + if opt.Env != "" && !strings.HasPrefix(opt.Env, prefix) { + t.Errorf("Option %q has an env name (%q) that is not prefixed with %s", opt.Name, opt.Env, prefix) + } + delete(excludes, opt.Name) }