Documentation
¶
Overview ¶
Package googleoauth provides Google Authorization Code flow orchestration.
Index ¶
- Constants
- Variables
- type Challenge
- type Config
- type EventType
- type ExchangeInput
- type GoogleProviderConfig
- type Identity
- type IdentityResolution
- type IdentityStore
- type LinkedIdentity
- type Manager
- func (manager *Manager) Begin(ctx context.Context, subjectID string) (Started, error)
- func (manager *Manager) Complete(ctx context.Context, state, code string) (User, error)
- func (manager *Manager) List(ctx context.Context, subjectID string) ([]LinkedIdentity, error)
- func (manager *Manager) Unlink(ctx context.Context, subjectID string, providerSubject string, ...) error
- type Provider
- type SecurityEvent
- type SecurityEventSink
- type Started
- type Store
- type User
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 {
ListIdentities(ctx context.Context, subjectID string) ([]LinkedIdentity, error)
UnlinkIdentity(ctx context.Context, subjectID, providerSubject string, unlinkedAt time.Time) error
}
IdentityStore must atomically refuse removal of the user's last sign-in method.
type LinkedIdentity ¶
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. 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.