google

package
v0.15.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package google contains the Google directory provider.

Index

Constants

View Source
const (
	// Name is the provider name.
	Name = "google"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(cfg *config)

An Option changes the configuration for the Google directory provider.

func WithServiceAccount

func WithServiceAccount(serviceAccount *ServiceAccount) Option

WithServiceAccount sets the service account in the Google configuration.

func WithURL

func WithURL(url string) Option

WithURL sets the provider url to use.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

A Provider is a Google directory provider.

func New

func New(options ...Option) *Provider

New creates a new Google directory provider.

func (*Provider) User added in v0.11.0

func (p *Provider) User(ctx context.Context, userID, accessToken string) (*directory.User, error)

User returns the user record for the given id.

func (*Provider) UserGroups

func (p *Provider) UserGroups(ctx context.Context) ([]*directory.Group, []*directory.User, error)

UserGroups returns a slice of group names a given user is in NOTE: groups via Directory API is limited to 1 QPS! https://developers.google.com/admin-sdk/directory/v1/reference/groups/list https://developers.google.com/admin-sdk/directory/v1/limits

type ServiceAccount

type ServiceAccount struct {
	Type string `json:"type"` // serviceAccountKey or userCredentialsKey

	// Service Account fields
	ClientEmail  string `json:"client_email"`
	PrivateKeyID string `json:"private_key_id"`
	PrivateKey   string `json:"private_key"`
	TokenURL     string `json:"token_uri"`
	ProjectID    string `json:"project_id"`

	// User Credential fields
	// (These typically come from gcloud auth.)
	ClientSecret string `json:"client_secret"`
	ClientID     string `json:"client_id"`
	RefreshToken string `json:"refresh_token"`

	// The User to use for Admin Directory API calls
	ImpersonateUser string `json:"impersonate_user"`
}

A ServiceAccount is used to authenticate with the Google APIs.

Google oauth fields are from https://github.com/golang/oauth2/blob/master/google/google.go#L99

func ParseServiceAccount

func ParseServiceAccount(rawServiceAccount string) (*ServiceAccount, error)

ParseServiceAccount parses the service account in the config options.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL