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
442d3de1
Commit
442d3de1
authored
5 years ago
by
Brian Candler
Browse files
Options
Downloads
Patches
Plain Diff
Allow the "google" connector to work without a service account
Fixes #1718
parent
709d4169
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
connector/google/google.go
+8
-2
8 additions, 2 deletions
connector/google/google.go
examples/config-dev.yaml
+1
-1
1 addition, 1 deletion
examples/config-dev.yaml
with
9 additions
and
3 deletions
connector/google/google.go
+
8
−
2
View file @
442d3de1
...
@@ -212,7 +212,7 @@ func (c *googleConnector) createIdentity(ctx context.Context, identity connector
...
@@ -212,7 +212,7 @@ func (c *googleConnector) createIdentity(ctx context.Context, identity connector
}
}
var
groups
[]
string
var
groups
[]
string
if
s
.
Groups
&&
c
.
admin
Email
!=
""
&&
c
.
serviceAccountFilePath
!=
""
{
if
s
.
Groups
&&
c
.
admin
Srv
!=
nil
{
groups
,
err
=
c
.
getGroups
(
claims
.
Email
)
groups
,
err
=
c
.
getGroups
(
claims
.
Email
)
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
)
...
@@ -251,7 +251,7 @@ func (c *googleConnector) getGroups(email string) ([]string, error) {
...
@@ -251,7 +251,7 @@ func (c *googleConnector) getGroups(email string) ([]string, error) {
}
}
for
_
,
group
:=
range
groupsList
.
Groups
{
for
_
,
group
:=
range
groupsList
.
Groups
{
// TODO (joelspeed): Make des
r
ied group key configurable
// TODO (joelspeed): Make desi
r
ed group key configurable
userGroups
=
append
(
userGroups
,
group
.
Email
)
userGroups
=
append
(
userGroups
,
group
.
Email
)
}
}
...
@@ -267,6 +267,12 @@ func (c *googleConnector) getGroups(email string) ([]string, error) {
...
@@ -267,6 +267,12 @@ func (c *googleConnector) getGroups(email string) ([]string, error) {
// sets up super user impersonation and creates an admin client for calling
// sets up super user impersonation and creates an admin client for calling
// the google admin api
// the google admin api
func
createDirectoryService
(
serviceAccountFilePath
string
,
email
string
)
(
*
admin
.
Service
,
error
)
{
func
createDirectoryService
(
serviceAccountFilePath
string
,
email
string
)
(
*
admin
.
Service
,
error
)
{
if
serviceAccountFilePath
==
""
&&
email
==
""
{
return
nil
,
nil
}
if
serviceAccountFilePath
==
""
||
email
==
""
{
return
nil
,
fmt
.
Errorf
(
"directory service requires both serviceAccountFilePath and adminEmail"
)
}
jsonCredentials
,
err
:=
ioutil
.
ReadFile
(
serviceAccountFilePath
)
jsonCredentials
,
err
:=
ioutil
.
ReadFile
(
serviceAccountFilePath
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error reading credentials from file: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"error reading credentials from file: %v"
,
err
)
...
...
This diff is collapsed.
Click to expand it.
examples/config-dev.yaml
+
1
−
1
View file @
442d3de1
...
@@ -70,7 +70,7 @@ connectors:
...
@@ -70,7 +70,7 @@ connectors:
-
type
:
mockCallback
-
type
:
mockCallback
id
:
mock
id
:
mock
name
:
Example
name
:
Example
# - type:
oidc
# - type:
google
# id: google
# id: google
# name: Google
# name: Google
# config:
# config:
...
...
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