Skip to content
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

Allow the "google" connector to work without a service account #1720

Merged
merged 1 commit into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions connector/google/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (c *googleConnector) createIdentity(ctx context.Context, identity connector
}

var groups []string
if s.Groups && c.adminEmail != "" && c.serviceAccountFilePath != "" {
if s.Groups && c.adminSrv != nil {
groups, err = c.getGroups(claims.Email)
if err != nil {
return identity, fmt.Errorf("google: could not retrieve groups: %v", err)
Expand Down Expand Up @@ -251,7 +251,7 @@ func (c *googleConnector) getGroups(email string) ([]string, error) {
}

for _, group := range groupsList.Groups {
// TODO (joelspeed): Make desried group key configurable
// TODO (joelspeed): Make desired group key configurable
userGroups = append(userGroups, group.Email)
}

Expand All @@ -267,6 +267,12 @@ func (c *googleConnector) getGroups(email string) ([]string, error) {
// sets up super user impersonation and creates an admin client for calling
// the google admin api
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)
if err != nil {
return nil, fmt.Errorf("error reading credentials from file: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion examples/config-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ connectors:
- type: mockCallback
id: mock
name: Example
# - type: oidc
# - type: google
# id: google
# name: Google
# config:
Expand Down