Skip to content

feat: add group allowlist for oidc #11070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Dec 8, 2023
Prev Previous commit
Next Next commit
update golden files
  • Loading branch information
Emyrk committed Dec 6, 2023
commit 8a871d737fd091002fb4f8774e1acdef73a4fecc
6 changes: 6 additions & 0 deletions cli/testdata/coder_server_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,12 @@ OIDC OPTIONS:
--oidc-allow-signups bool, $CODER_OIDC_ALLOW_SIGNUPS (default: true)
Whether new users can sign up with OIDC.

--oidc-allowed-groups string-array, $CODER_OIDC_ALLOWED_GROUPS
If provided any group name not in the list will not be allowed to
authenticate. This allows for restricting access to a specific set of
groups. This filter is applied after the group mapping and before the
regex filter.

--oidc-auth-url-params struct[map[string]string], $CODER_OIDC_AUTH_URL_PARAMS (default: {"access_type": "offline"})
OIDC auth URL parameters to pass to the upstream provider.

Expand Down
5 changes: 5 additions & 0 deletions cli/testdata/server-config.yaml.golden
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ oidc:
# mapping.
# (default: .*, type: regexp)
groupRegexFilter: .*
# If provided any group name not in the list will not be allowed to authenticate.
# This allows for restricting access to a specific set of groups. This filter is
# applied after the group mapping and before the regex filter.
# (default: <unset>, type: string-array)
groupAllowed: []
# This field must be set if using the user roles sync feature. Set this to the
# name of the claim used to store the user's role. The roles should be sent as an
# array of strings.
Expand Down
4 changes: 2 additions & 2 deletions coderd/userauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -1061,9 +1061,9 @@ func (api *API) oidcGroups(ctx context.Context, mergedClaims map[string]interfac
}

if !inAllowList {
detail := fmt.Sprintf("Ask an administrator to add one of your groups to the whitelist: %s", strings.Join(groups, ", "))
detail := fmt.Sprintf("Ask an administrator to add one of your groups (%s) to the whitelist", strings.Join(groups, ", "))
if len(groups) == 0 {
detail = "You are currently not a member of any groups!"
detail = "You are currently not a member of any groups! Ask an administrator to add you to an authorized group to login."
}
return usingGroups, groups, &httpError{
code: http.StatusForbidden,
Expand Down