google

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package google implements the Google OpenID Connect provider for Auth-All.

Google is a conformant OpenID Connect issuer, so this package is a preset over the generic provider in oauth/oidc. One code path carries the identity token verification, so a defect is repaired one time.

Index

Constants

View Source
const (
	DefaultAuthURL  = "https://accounts.google.com/o/oauth2/v2/auth"
	DefaultTokenURL = "https://oauth2.googleapis.com/token"
	DefaultJWKSURL  = "https://www.googleapis.com/oauth2/v3/certs"
	DefaultIssuer   = "https://accounts.google.com"
)

Default Google endpoints.

View Source
const ProviderID = "google"

ProviderID is the stable identifier of this provider.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Provider)

Option configures the provider.

func WithClientID

func WithClientID(v string) Option

WithClientID sets the OAuth client id.

func WithClientSecret

func WithClientSecret(v string) Option

WithClientSecret sets the OAuth client secret.

func WithClock

func WithClock(now func() time.Time) Option

WithClock replaces the clock used for token expiry validation.

func WithEndpoints

func WithEndpoints(authURL, tokenURL, jwksURL, issuer string) Option

WithEndpoints overrides the provider endpoints and the expected issuer. Tests use it to point at a deterministic fake Google server.

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

WithHTTPClient sets the HTTP client used for provider calls.

func WithScopes

func WithScopes(v ...string) Option

WithScopes replaces the requested scopes.

type Provider

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

Provider is the Google OpenID Connect provider.

func New

func New(opts ...Option) *Provider

New returns a Google provider.

Google publishes a discovery document, and this preset names the endpoints directly. The endpoints are stable and documented, so the first sign-in needs no extra round trip.

func (*Provider) AuthCodeURL

func (p *Provider) AuthCodeURL(req oauth.AuthRequest) (string, error)

AuthCodeURL implements oauth.Provider.

func (*Provider) Exchange

func (p *Provider) Exchange(ctx context.Context, req oauth.ExchangeRequest) (*oauth.Identity, error)

Exchange implements oauth.Provider. It validates the issuer, the audience, the nonce, the expiry, and the signature of the identity token.

func (*Provider) ID

func (p *Provider) ID() string

ID implements oauth.Provider.

func (*Provider) SupportsPKCE

func (p *Provider) SupportsPKCE() bool

SupportsPKCE implements oauth.Provider.

func (*Provider) Validate

func (p *Provider) Validate() error

Validate reports missing configuration.

Jump to

Keyboard shortcuts

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