mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add group allowlist for oidc (#11070)
* feat: group allow list in OIDC settings
This commit is contained in:
@@ -149,6 +149,15 @@ func createOIDCConfig(ctx context.Context, vals *codersdk.DeploymentValues) (*co
|
||||
}
|
||||
useCfg = pkiCfg
|
||||
}
|
||||
if len(vals.OIDC.GroupAllowList) > 0 && vals.OIDC.GroupField == "" {
|
||||
return nil, xerrors.Errorf("'oidc-group-field' must be set if 'oidc-allowed-groups' is set. Either unset 'oidc-allowed-groups' or set 'oidc-group-field'")
|
||||
}
|
||||
|
||||
groupAllowList := make(map[string]bool)
|
||||
for _, group := range vals.OIDC.GroupAllowList.Value() {
|
||||
groupAllowList[group] = true
|
||||
}
|
||||
|
||||
return &coderd.OIDCConfig{
|
||||
OAuth2Config: useCfg,
|
||||
Provider: oidcProvider,
|
||||
@@ -163,6 +172,7 @@ func createOIDCConfig(ctx context.Context, vals *codersdk.DeploymentValues) (*co
|
||||
IgnoreUserInfo: vals.OIDC.IgnoreUserInfo.Value(),
|
||||
GroupField: vals.OIDC.GroupField.String(),
|
||||
GroupFilter: vals.OIDC.GroupRegexFilter.Value(),
|
||||
GroupAllowList: groupAllowList,
|
||||
CreateMissingGroups: vals.OIDC.GroupAutoCreate.Value(),
|
||||
GroupMapping: vals.OIDC.GroupMapping.Value,
|
||||
UserRoleField: vals.OIDC.UserRoleField.String(),
|
||||
|
||||
+6
@@ -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.
|
||||
|
||||
|
||||
+5
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user