Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hdacloud
dex
Commits
a38e2158
Unverified
Commit
a38e2158
authored
5 years ago
by
Nandor Kracser
Browse files
Options
Downloads
Patches
Plain Diff
connector/google: support group whitelisting
Signed-off-by:
Nandor Kracser
<
bonifaido@gmail.com
>
parent
c4103573
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Documentation/connectors/google.md
+7
-0
7 additions, 0 deletions
Documentation/connectors/google.md
connector/google/google.go
+15
-1
15 additions, 1 deletion
connector/google/google.go
with
22 additions
and
1 deletion
Documentation/connectors/google.md
+
7
−
0
View file @
a38e2158
...
@@ -29,6 +29,13 @@ connectors:
...
@@ -29,6 +29,13 @@ connectors:
# hostedDomains:
# hostedDomains:
# - example.com
# - example.com
# The Google connector supports whitelisting allowed groups when using G Suite
# (Google Apps). The following field can be set to a list of groups
# that can log in:
#
# groups:
# - admins@example.com
# Google does not support the OpenID Connect groups claim and only supports
# Google does not support the OpenID Connect groups claim and only supports
# fetching a user's group membership with a service account.
# fetching a user's group membership with a service account.
# This service account requires an authentication JSON file and the email
# This service account requires an authentication JSON file and the email
...
...
This diff is collapsed.
Click to expand it.
connector/google/google.go
+
15
−
1
View file @
a38e2158
...
@@ -13,9 +13,10 @@ import (
...
@@ -13,9 +13,10 @@ import (
"golang.org/x/oauth2"
"golang.org/x/oauth2"
"github.com/dexidp/dex/connector"
"github.com/dexidp/dex/connector"
pkg_groups
"github.com/dexidp/dex/pkg/groups"
"github.com/dexidp/dex/pkg/log"
"github.com/dexidp/dex/pkg/log"
"golang.org/x/oauth2/google"
"golang.org/x/oauth2/google"
"google.golang.org/api/admin/directory/v1"
admin
"google.golang.org/api/admin/directory/v1"
)
)
const
(
const
(
...
@@ -34,6 +35,10 @@ type Config struct {
...
@@ -34,6 +35,10 @@ type Config struct {
// If this field is nonempty, only users from a listed domain will be allowed to log in
// If this field is nonempty, only users from a listed domain will be allowed to log in
HostedDomains
[]
string
`json:"hostedDomains"`
HostedDomains
[]
string
`json:"hostedDomains"`
// Optional list of whitelisted groups
// If this field is nonempty, only users from a listed group will be allowed to log in
Groups
[]
string
`json:"groups"`
// Optional path to service account json
// Optional path to service account json
// If nonempty, and groups claim is made, will use authentication from file to
// If nonempty, and groups claim is made, will use authentication from file to
// check groups with the admin directory api
// check groups with the admin directory api
...
@@ -84,6 +89,7 @@ func (c *Config) Open(id string, logger log.Logger) (conn connector.Connector, e
...
@@ -84,6 +89,7 @@ func (c *Config) Open(id string, logger log.Logger) (conn connector.Connector, e
logger
:
logger
,
logger
:
logger
,
cancel
:
cancel
,
cancel
:
cancel
,
hostedDomains
:
c
.
HostedDomains
,
hostedDomains
:
c
.
HostedDomains
,
groups
:
c
.
Groups
,
serviceAccountFilePath
:
c
.
ServiceAccountFilePath
,
serviceAccountFilePath
:
c
.
ServiceAccountFilePath
,
adminEmail
:
c
.
AdminEmail
,
adminEmail
:
c
.
AdminEmail
,
adminSrv
:
srv
,
adminSrv
:
srv
,
...
@@ -103,6 +109,7 @@ type googleConnector struct {
...
@@ -103,6 +109,7 @@ type googleConnector struct {
cancel
context
.
CancelFunc
cancel
context
.
CancelFunc
logger
log
.
Logger
logger
log
.
Logger
hostedDomains
[]
string
hostedDomains
[]
string
groups
[]
string
serviceAccountFilePath
string
serviceAccountFilePath
string
adminEmail
string
adminEmail
string
adminSrv
*
admin
.
Service
adminSrv
*
admin
.
Service
...
@@ -211,6 +218,13 @@ func (c *googleConnector) createIdentity(ctx context.Context, identity connector
...
@@ -211,6 +218,13 @@ func (c *googleConnector) createIdentity(ctx context.Context, identity connector
if
err
!=
nil
{
if
err
!=
nil
{
return
identity
,
fmt
.
Errorf
(
"google: could not retrieve groups: %v"
,
err
)
return
identity
,
fmt
.
Errorf
(
"google: could not retrieve groups: %v"
,
err
)
}
}
if
len
(
c
.
groups
)
>
0
{
groups
=
pkg_groups
.
Filter
(
groups
,
c
.
groups
)
if
len
(
groups
)
==
0
{
return
identity
,
fmt
.
Errorf
(
"google: user %q is not in any of the required groups"
,
claims
.
Username
)
}
}
}
}
identity
=
connector
.
Identity
{
identity
=
connector
.
Identity
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment