Skip to content
Snippets Groups Projects
Unverified Commit 415ddaa3 authored by Pradeep Mudlapur's avatar Pradeep Mudlapur Committed by GitHub
Browse files

Minimalistic support for group filtering in oidc connector (#3074)

parent 3b78752a
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ import ( ...@@ -15,6 +15,7 @@ import (
"golang.org/x/oauth2" "golang.org/x/oauth2"
"github.com/dexidp/dex/connector" "github.com/dexidp/dex/connector"
groups_pkg "github.com/dexidp/dex/pkg/groups"
"github.com/dexidp/dex/pkg/httpclient" "github.com/dexidp/dex/pkg/httpclient"
"github.com/dexidp/dex/pkg/log" "github.com/dexidp/dex/pkg/log"
) )
...@@ -50,7 +51,8 @@ type Config struct { ...@@ -50,7 +51,8 @@ type Config struct {
InsecureSkipEmailVerified bool `json:"insecureSkipEmailVerified"` InsecureSkipEmailVerified bool `json:"insecureSkipEmailVerified"`
// InsecureEnableGroups enables groups claims. This is disabled by default until https://github.com/dexidp/dex/issues/1065 is resolved // InsecureEnableGroups enables groups claims. This is disabled by default until https://github.com/dexidp/dex/issues/1065 is resolved
InsecureEnableGroups bool `json:"insecureEnableGroups"` InsecureEnableGroups bool `json:"insecureEnableGroups"`
AllowedGroups []string `json:"allowedGroups"`
// AcrValues (Authentication Context Class Reference Values) that specifies the Authentication Context Class Values // AcrValues (Authentication Context Class Reference Values) that specifies the Authentication Context Class Values
// within the Authentication Request that the Authorization Server is being requested to use for // within the Authentication Request that the Authorization Server is being requested to use for
...@@ -180,6 +182,7 @@ func (c *Config) Open(id string, logger log.Logger) (conn connector.Connector, e ...@@ -180,6 +182,7 @@ func (c *Config) Open(id string, logger log.Logger) (conn connector.Connector, e
httpClient: httpClient, httpClient: httpClient,
insecureSkipEmailVerified: c.InsecureSkipEmailVerified, insecureSkipEmailVerified: c.InsecureSkipEmailVerified,
insecureEnableGroups: c.InsecureEnableGroups, insecureEnableGroups: c.InsecureEnableGroups,
allowedGroups: c.AllowedGroups,
acrValues: c.AcrValues, acrValues: c.AcrValues,
getUserInfo: c.GetUserInfo, getUserInfo: c.GetUserInfo,
promptType: c.PromptType, promptType: c.PromptType,
...@@ -207,6 +210,7 @@ type oidcConnector struct { ...@@ -207,6 +210,7 @@ type oidcConnector struct {
httpClient *http.Client httpClient *http.Client
insecureSkipEmailVerified bool insecureSkipEmailVerified bool
insecureEnableGroups bool insecureEnableGroups bool
allowedGroups []string
acrValues []string acrValues []string
getUserInfo bool getUserInfo bool
promptType string promptType string
...@@ -425,6 +429,18 @@ func (c *oidcConnector) createIdentity(ctx context.Context, identity connector.I ...@@ -425,6 +429,18 @@ func (c *oidcConnector) createIdentity(ctx context.Context, identity connector.I
} }
} }
} }
// Validate that the user is part of allowedGroups
if len(c.allowedGroups) > 0 {
groupMatches := groups_pkg.Filter(groups, c.allowedGroups)
if len(groupMatches) == 0 {
// No group membership matches found, disallowing
return identity, fmt.Errorf("user not a member of allowed groups")
}
groups = groupMatches
}
} }
cd := connectorData{ cd := connectorData{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment