Documentation
¶
Index ¶
- Variables
- func ClearOAuthStateCookie(w http.ResponseWriter)
- func GetOrCreateUserFromOAuth(ctx context.Context, db *sql.DB, provider, providerUserID, email string, ...) (string, error)
- func HandleCallback(ctx context.Context, db *sql.DB, stateSecret string, provider OAuthProvider, ...) (string, error)
- func HandleCallbackHTTP(w http.ResponseWriter, r *http.Request, db *sql.DB, stateSecret string, ...) (string, error)
- func NewRandomURLSafe(n int) (string, error)
- func PKCEChallenge(verifier string) string
- func ReadOAuthStateCookie(r *http.Request) (string, error)
- func SetOAuthStateCookie(w http.ResponseWriter, value string)
- func SignOAuthState(secret, state, verifier string) (string, error)
- func Start(stateSecret string, provider OAuthProvider) (signedState, url string, err error)
- func StartHTTP(w http.ResponseWriter, r *http.Request, stateSecret string, ...) error
- func ValidateOAuthStateSecret(secret string) error
- func VerifyOAuthStateCookie(secret, raw string) (state string, verifier string, err error)
- type Client
- type ClientConfig
- type DiscordProvider
- type DiscordProviderConfig
- type GitHubProvider
- type GitHubProviderConfig
- type OAuthCallbackValidator
- type OAuthIdentity
- type OAuthProvider
- type OAuthProviderMeta
- type OIDCProvider
- type OIDCProviderConfig
- type RedditProvider
- type RedditProviderConfig
- type ShopifyProvider
- func (p ShopifyProvider) AuthURL(state, codeChallenge string) (string, error)
- func (p ShopifyProvider) DisplayName() string
- func (p ShopifyProvider) ExchangeAndFetchIdentity(ctx context.Context, code, codeVerifier string) (*OAuthIdentity, error)
- func (p ShopifyProvider) Name() string
- func (p *ShopifyProvider) ValidateCallback(r *http.Request) error
- type ShopifyProviderConfig
- type SpotifyProvider
- type SpotifyProviderConfig
- type TwitterProvider
- type TwitterProviderConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrOAuthAccountMissingUserID = errors.New("oauth account missing user id")
View Source
var ErrOAuthCallbackInvalid = errors.New("oauth callback invalid")
View Source
var ErrOAuthCodeMissing = errors.New("oauth code missing")
View Source
var ErrOAuthEmailAlreadyRegistered = errors.New("oauth email already registered")
View Source
var ErrOAuthEmailMissing = errors.New("oauth email missing")
View Source
var ErrOAuthIDTokenInvalid = errors.New("oauth id_token invalid")
View Source
var ErrOAuthIDTokenMissing = errors.New("oauth id_token missing")
View Source
var ErrOAuthProvider = errors.New("oauth provider error")
View Source
var ErrOAuthProviderNotFound = errors.New("oauth provider not found")
View Source
var ErrOAuthStateInvalid = errors.New("oauth state invalid")
View Source
var ErrOAuthStateMismatch = errors.New("oauth state mismatch")
View Source
var ErrOAuthStateMissing = errors.New("oauth state missing")
View Source
var ErrOAuthTokenExchange = errors.New("oauth token exchange failed")
View Source
var ErrOAuthUserInfo = errors.New("oauth userinfo fetch failed")
Functions ¶
func ClearOAuthStateCookie ¶
func ClearOAuthStateCookie(w http.ResponseWriter)
func HandleCallback ¶
func HandleCallbackHTTP ¶
func HandleCallbackHTTP(w http.ResponseWriter, r *http.Request, db *sql.DB, stateSecret string, provider OAuthProvider) (string, error)
func NewRandomURLSafe ¶
func PKCEChallenge ¶
func SetOAuthStateCookie ¶
func SetOAuthStateCookie(w http.ResponseWriter, value string)
func SignOAuthState ¶
func Start ¶
func Start(stateSecret string, provider OAuthProvider) (signedState, url string, err error)
func StartHTTP ¶
func StartHTTP(w http.ResponseWriter, r *http.Request, stateSecret string, provider OAuthProvider) error
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(cfg ClientConfig) (*Client, error)
func (*Client) HandleCallbackHTTP ¶
func (*Client) ProviderMetadata ¶
func (c *Client) ProviderMetadata() []OAuthProviderMeta
type ClientConfig ¶
type ClientConfig struct {
DB *sql.DB
StateSecret string
Providers map[string]OAuthProvider
}
type DiscordProvider ¶
type DiscordProvider struct {
// contains filtered or unexported fields
}
func NewDiscordProvider ¶
func NewDiscordProvider(cfg DiscordProviderConfig) (*DiscordProvider, error)
func (DiscordProvider) DisplayName ¶
func (p DiscordProvider) DisplayName() string
func (DiscordProvider) ExchangeAndFetchIdentity ¶
func (p DiscordProvider) ExchangeAndFetchIdentity(ctx context.Context, code, codeVerifier string) (*OAuthIdentity, error)
type DiscordProviderConfig ¶
type GitHubProvider ¶
type GitHubProvider struct {
// contains filtered or unexported fields
}
func NewGitHubProvider ¶
func NewGitHubProvider(cfg GitHubProviderConfig) (*GitHubProvider, error)
func (GitHubProvider) DisplayName ¶
func (p GitHubProvider) DisplayName() string
func (GitHubProvider) ExchangeAndFetchIdentity ¶
func (p GitHubProvider) ExchangeAndFetchIdentity(ctx context.Context, code, codeVerifier string) (*OAuthIdentity, error)
type GitHubProviderConfig ¶
type OAuthCallbackValidator ¶
type OAuthIdentity ¶
type OAuthProvider ¶
type OAuthProviderMeta ¶
func OAuthProviderMetadata ¶
func OAuthProviderMetadata(providers map[string]OAuthProvider) []OAuthProviderMeta
type OIDCProvider ¶
type OIDCProvider struct {
// contains filtered or unexported fields
}
func NewOIDCProvider ¶
func NewOIDCProvider(ctx context.Context, cfg OIDCProviderConfig) (*OIDCProvider, error)
func (*OIDCProvider) AuthURL ¶
func (p *OIDCProvider) AuthURL(state, codeChallenge string) (string, error)
func (*OIDCProvider) DisplayName ¶
func (p *OIDCProvider) DisplayName() string
func (*OIDCProvider) ExchangeAndFetchIdentity ¶
func (p *OIDCProvider) ExchangeAndFetchIdentity(ctx context.Context, code, codeVerifier string) (*OAuthIdentity, error)
func (*OIDCProvider) Name ¶
func (p *OIDCProvider) Name() string
type OIDCProviderConfig ¶
type RedditProvider ¶
type RedditProvider struct {
// contains filtered or unexported fields
}
func NewRedditProvider ¶
func NewRedditProvider(cfg RedditProviderConfig) (*RedditProvider, error)
func (RedditProvider) DisplayName ¶
func (p RedditProvider) DisplayName() string
func (RedditProvider) ExchangeAndFetchIdentity ¶
func (p RedditProvider) ExchangeAndFetchIdentity(ctx context.Context, code, codeVerifier string) (*OAuthIdentity, error)
type RedditProviderConfig ¶
type ShopifyProvider ¶
type ShopifyProvider struct {
// contains filtered or unexported fields
}
func NewShopifyProvider ¶
func NewShopifyProvider(cfg ShopifyProviderConfig) (*ShopifyProvider, error)
func (ShopifyProvider) DisplayName ¶
func (p ShopifyProvider) DisplayName() string
func (ShopifyProvider) ExchangeAndFetchIdentity ¶
func (p ShopifyProvider) ExchangeAndFetchIdentity(ctx context.Context, code, codeVerifier string) (*OAuthIdentity, error)
func (*ShopifyProvider) ValidateCallback ¶
func (p *ShopifyProvider) ValidateCallback(r *http.Request) error
type ShopifyProviderConfig ¶
type SpotifyProvider ¶
type SpotifyProvider struct {
// contains filtered or unexported fields
}
func NewSpotifyProvider ¶
func NewSpotifyProvider(cfg SpotifyProviderConfig) (*SpotifyProvider, error)
func (SpotifyProvider) DisplayName ¶
func (p SpotifyProvider) DisplayName() string
func (SpotifyProvider) ExchangeAndFetchIdentity ¶
func (p SpotifyProvider) ExchangeAndFetchIdentity(ctx context.Context, code, codeVerifier string) (*OAuthIdentity, error)
type SpotifyProviderConfig ¶
type TwitterProvider ¶
type TwitterProvider struct {
// contains filtered or unexported fields
}
func NewTwitterProvider ¶
func NewTwitterProvider(cfg TwitterProviderConfig) (*TwitterProvider, error)
func (TwitterProvider) DisplayName ¶
func (p TwitterProvider) DisplayName() string
func (TwitterProvider) ExchangeAndFetchIdentity ¶
func (p TwitterProvider) ExchangeAndFetchIdentity(ctx context.Context, code, codeVerifier string) (*OAuthIdentity, error)
Click to show internal directories.
Click to hide internal directories.