Help us shape the future of Go! Take the 2026 Go Developer Survey

googleworkspaceoauthsync

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package googleworkspaceoauthsync pulls Google Workspace per-user OAuth grants and upserts them into security_assets (type=OAUTH_APP, labels including 'shadow-it') and oauth_app_grants. Until this package landed, no production producer wrote to either table for Google, so the Shadow IT page showed zero OAuth apps for live tenants even after a successful Google connect.

Design notes:

  • Google's Directory API exposes user-granted OAuth tokens via admin.users.tokens.list, which is per-user. The sync walks all known saas_identities for the integration (populated by googleworkspacedirectorysync) and calls tokens.list per user. If saas_identities is empty (e.g., directory sync has not run yet) the sweep returns 0 grants without errors so the cursor still surfaces a "last_synced_at" heartbeat in the connectors UI.
  • Each unique OAuth app produces one security_assets row with type=OAUTH_APP and labels=['shadow-it']; one oauth_app_grants row is upserted per (app, user). The unique constraint (organization_id, integration_id, external_app_id, user_email) idempotently converges across retries.
  • HTTP failures on a single user log and are surfaced on the cursor's last_error; one user with a token-list permission issue must not abort the whole sweep.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OAuthConfig

type OAuthConfig struct {
	ClientID     string
	ClientSecret string
}

type OAuthResolver

type OAuthResolver interface {
	ResolveGoogleOAuthClient(ctx context.Context, organizationID string) (OAuthConfig, bool)
}

type Sync

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

func New

func New(db *sql.DB, resolver OAuthResolver) *Sync

func (*Sync) Run

func (s *Sync) Run(ctx context.Context) error

func (*Sync) Tick

func (s *Sync) Tick(ctx context.Context) error

func (*Sync) WakeIntegration

func (s *Sync) WakeIntegration(ctx context.Context, integrationID string) error

func (*Sync) WithHTTPClient

func (s *Sync) WithHTTPClient(c *http.Client) *Sync

func (*Sync) WithInterval

func (s *Sync) WithInterval(d time.Duration) *Sync

func (*Sync) WithNowFn

func (s *Sync) WithNowFn(fn func() time.Time) *Sync

Jump to

Keyboard shortcuts

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