types

package
v1.50.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizeRequest

type AuthorizeRequest struct {
	ProviderID string `path:"provider"`
	RedirectTo string `query:"redirect_to" json:"redirect_to,omitempty" nullable:"true"`
	// ActorID is set when an already signed-in user starts a linking flow.
	ActorID string `json:"-"`
}

AuthorizeRequest represents an authorization request

type AuthorizeResponse

type AuthorizeResponse struct {
	AuthURL string `json:"auth_url" required:"true" nullable:"false"`
}

AuthorizeResponse represents an authorization response

type CallbackRequest

type CallbackRequest struct {
	ProviderID string `path:"provider"`
	Code       string `query:"code" json:"code,omitempty" nullable:"true"`
	State      string `query:"state" json:"state,omitempty" nullable:"true"`
	Error      string `query:"error" json:"error,omitempty" nullable:"true"`

	// ActorID and SessionID are populated from the request context when a signed-in
	// user starts a linking flow.
	ActorID   string `json:"-"`
	SessionID string `json:"-"`

	// Signed flow cookies are validated by the use case.
	StateCookie    string `json:"-"`
	RedirectCookie string `json:"-"`
	VerifierCookie string `json:"-"`
}

CallbackRequest represents an OAuth2 callback request

type CallbackResponse

type CallbackResponse struct {
	User    *models.User     `json:"user" required:"true" nullable:"false"`
	Session *CallbackSession `json:"session" required:"true" nullable:"false"`
}

CallbackResponse represents an OAuth2 callback response. It intentionally omits the session token, IP address, and user agent.

type CallbackResult

type CallbackResult struct {
	User          *models.User
	Session       *models.Session
	SessionToken  string
	RedirectTo    string
	ReusedSession bool
}

CallbackResult represents the result of OAuth2 callback

type CallbackSession added in v1.50.0

type CallbackSession struct {
	ID        string    `json:"id" required:"true" nullable:"false"`
	UserID    string    `json:"user_id" required:"true" nullable:"false"`
	ExpiresAt time.Time `json:"expires_at" required:"true" nullable:"false"`
}

CallbackSession is the safe public view of a session.

type ErrorResponse added in v1.50.0

type ErrorResponse struct {
	Message string `json:"message" required:"true" nullable:"false"`
}

ErrorResponse is the generic error body returned by OAuth2 endpoints.

type OAuth2PluginConfig

type OAuth2PluginConfig struct {
	Enabled     bool                      `json:"enabled" toml:"enabled"`
	HTTPTimeout time.Duration             `json:"http_timeout" toml:"http_timeout"`
	Providers   map[string]ProviderConfig `json:"providers" toml:"providers"`
}

OAuth2PluginConfig represents the OAuth2 plugin configuration

func (*OAuth2PluginConfig) ApplyDefaults

func (c *OAuth2PluginConfig) ApplyDefaults()

ApplyDefaults applies default values to the config

type OAuth2Provider

type OAuth2Provider interface {
	Name() string
	GetConfig() *oauth2.Config
	GetAuthURL(state string, opts ...oauth2.AuthCodeOption) string
	Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
	GetUserInfo(ctx context.Context, token *oauth2.Token) (*UserInfo, error)
	RequiresPKCE() bool
}

OAuth2Provider interface defines the contract for OAuth2 providers

type ProviderConfig

type ProviderConfig struct {
	// Enabled defaults to true when absent. Set it explicitly to false to disable a provider.
	Enabled      *bool    `json:"enabled,omitempty" toml:"enabled,omitempty"`
	ClientID     string   `json:"client_id" toml:"client_id"`
	ClientSecret string   `json:"client_secret" toml:"client_secret"`
	RedirectURL  string   `json:"redirect_url" toml:"redirect_url"`
	Scopes       []string `json:"scopes" toml:"scopes"`
	AuthURL      string   `json:"auth_url" toml:"auth_url"`
	TokenURL     string   `json:"token_url" toml:"token_url"`
	UserInfoURL  string   `json:"user_info_url" toml:"user_info_url"`
	UserIDField  string   `json:"user_id_field" toml:"user_id_field"`
	EmailField   string   `json:"email_field" toml:"email_field"`
	NameField    string   `json:"name_field" toml:"name_field"`
	PictureField string   `json:"picture_field" toml:"picture_field"`
	// EmailVerifiedField is the field that carries the provider's email verification flag.
	EmailVerifiedField string `json:"email_verified_field" toml:"email_verified_field"`
	// PKCE controls whether this provider must use PKCE with S256. It defaults to true.
	// Setting it to false is an explicit opt-out and is not OAuth 2.1 compliant.
	PKCE *bool `json:"pkce,omitempty" toml:"pkce,omitempty"`
}

ProviderConfig represents configuration for an OAuth2 provider

func (ProviderConfig) IsEnabled added in v1.50.0

func (c ProviderConfig) IsEnabled() bool

IsEnabled reports whether the provider is enabled. Absent means enabled.

func (ProviderConfig) PKCEEnabled added in v1.50.1

func (c ProviderConfig) PKCEEnabled() bool

PKCEEnabled reports whether PKCE is required for this provider. Absent means enabled.

type RedirectResponse added in v1.50.0

type RedirectResponse struct{}

RedirectResponse documents the empty body returned with a 302 response.

type UserInfo

type UserInfo struct {
	ProviderAccountID string         `json:"provider_account_id"`
	Email             string         `json:"email"`
	EmailVerified     bool           `json:"email_verified"`
	Name              string         `json:"name"`
	Picture           string         `json:"picture"`
	Raw               map[string]any `json:"raw"`
}

UserInfo represents normalized user information from OAuth2 providers

Jump to

Keyboard shortcuts

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