Documentation
¶
Overview ¶
Package social provides Better Auth-compatible built-in OAuth2/OIDC provider presets and a generic provider constructor.
Index ¶
- Variables
- type EndpointValidator
- type Options
- type ProfileMapper
- type Provider
- func (p *Provider) AuthorizationURL(state, challenge, nonce, redirectURI string) (string, error)
- func (p *Provider) DisableImplicitSignUp() bool
- func (p *Provider) DisableSignUp() bool
- func (p *Provider) Exchange(ctx context.Context, code string, verifier string, nonce string, ...) (betterauth.OAuthResult, error)
- func (p *Provider) Refresh(ctx context.Context, refreshToken string) (betterauth.ProviderTokens, error)
- type TokenAuthMethod
Constants ¶
This section is empty.
Variables ¶
var SupportedProviders = []string{
"apple", "atlassian", "cognito", "discord", "dropbox", "facebook", "figma",
"github", "gitlab", "google", "huggingface", "kakao", "kick", "line",
"linear", "linkedin", "microsoft", "naver", "notion", "paybin", "paypal",
"polar", "railway", "reddit", "roblox", "salesforce", "slack", "spotify",
"tiktok", "twitch", "twitter", "vercel", "vk", "wechat", "zoom",
}
SupportedProviders is the Better Auth v1.6 built-in provider catalog.
Functions ¶
This section is empty.
Types ¶
type EndpointValidator ¶
EndpointValidator is called for OIDC discovery and every discovered endpoint before a provider is constructed. It lets embedders apply an SSRF policy that is stricter than the generic public-address checks.
type Options ¶
type Options struct {
ClientID string
ClientSecret string
ClientKey string
Issuer string
BaseURL string
Tenant string
Scopes []string
DisableDefaultScope bool
AuthorizationURL string
TokenURL string
UserInfoURL string
JWKSURL string
TokenAuth TokenAuthMethod
ProfileMapper ProfileMapper
AuthorizationParams map[string]string
HTTPClient *http.Client
Timeout time.Duration
MaxResponseBytes int64
// Clock controls token-expiry and OIDC verification time in deterministic
// tests. Nil uses the system UTC clock.
Clock betterauth.Clock
// DiscoveryURL overrides the standard issuer well-known location.
DiscoveryURL string
// ValidateEndpoint validates discovery, authorization, token, user-info,
// and JWKS URLs before any runtime request can use them.
ValidateEndpoint EndpointValidator
// DisableImplicitSignUp requires callers to set requestSignUp for a new
// account while still allowing returning users to sign in.
DisableImplicitSignUp bool
// DisableSignUp permanently prevents this provider from creating users.
DisableSignUp bool
// contains filtered or unexported fields
}
Options configures a built-in preset. Endpoint overrides are intended for self-hosted GitLab, Cognito, Microsoft tenants, Salesforce, and compatible private OAuth deployments.
type ProfileMapper ¶
type ProfileMapper func(map[string]any) (betterauth.OAuthProfile, error)
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is immutable after construction and safe for concurrent use.
func NewOIDC ¶
NewOIDC discovers and validates a generic OpenID Connect provider before constructing an immutable OAuth provider. Issuer is required; explicit endpoint options override discovered values only after the discovered configuration itself has passed validation.
func (*Provider) AuthorizationURL ¶
func (*Provider) DisableImplicitSignUp ¶
DisableImplicitSignUp implements betterauth.OAuthProviderSignUpPolicy.
func (*Provider) DisableSignUp ¶
DisableSignUp implements betterauth.OAuthProviderSignUpPolicy.
func (*Provider) Exchange ¶
func (p *Provider) Exchange( ctx context.Context, code string, verifier string, nonce string, redirectURI string, ) (betterauth.OAuthResult, error)
func (*Provider) Refresh ¶
func (p *Provider) Refresh(ctx context.Context, refreshToken string) (betterauth.ProviderTokens, error)
Refresh exchanges a refresh token using the provider's configured token endpoint and client authentication method.
type TokenAuthMethod ¶
type TokenAuthMethod string
const ( TokenAuthBody TokenAuthMethod = "client_secret_post" TokenAuthBasic TokenAuthMethod = "client_secret_basic" TokenAuthNone TokenAuthMethod = "none" )