Documentation
¶
Overview ¶
Package googleoauth provides Google Authorization Code flow orchestration.
Index ¶
Constants ¶
View Source
const (
AuthorizationEndpoint = "https://accounts.google.com/o/oauth2/v2/auth"
)
Variables ¶
View Source
var ( ErrConflict = errors.New("Google identity is linked to another user") ErrInvalidConfig = errors.New("invalid Google OAuth configuration") ErrInvalidInput = errors.New("invalid Google OAuth input") ErrInvalidRecord = errors.New("invalid Google OAuth record") ErrInvalidState = errors.New("invalid or expired OAuth state") ErrLastCredential = errors.New("cannot remove the last sign-in method") ErrLinkRequired = errors.New("existing user must authenticate before linking Google") ErrNotFound = errors.New("Google OAuth record not found") ErrUnverified = errors.New("Google identity email is not verified") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
ClientID string
AuthorizationURL string
RedirectURL string
StateLifetime time.Duration
Identities IdentityStore
SecurityEvents SecurityEventSink
Now func() time.Time
}
type ExchangeInput ¶
type GoogleProviderConfig ¶
type IdentityResolution ¶
type IdentityStore ¶
type IdentityStore interface {
UnlinkIdentity(ctx context.Context, subjectID string, unlinkedAt time.Time) error
}
IdentityStore must atomically refuse removal of the user's last sign-in method.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
type Provider ¶
type Provider interface {
Exchange(ctx context.Context, input ExchangeInput) (Identity, error)
}
Provider verifies the Google ID token signature, issuer, audience, and expiry.
func NewGoogleProvider ¶
func NewGoogleProvider(config GoogleProviderConfig) (Provider, error)
type SecurityEvent ¶
type SecurityEventSink ¶
type SecurityEventSink interface {
Record(ctx context.Context, event SecurityEvent)
}
type Store ¶
type Store interface {
CreateChallenge(ctx context.Context, challenge Challenge) error
ConsumeChallenge(ctx context.Context, stateHash [32]byte, consumedAt time.Time) (Challenge, error)
// ResolveIdentity finds, links, or creates a user atomically. Each user may
// have only one Google identity. ProviderSubject is the permanent account
// key; an existing unlinked email returns ErrLinkRequired.
ResolveIdentity(ctx context.Context, resolution IdentityResolution) (User, error)
}
Click to show internal directories.
Click to hide internal directories.