social

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package social provides Better Auth-compatible built-in OAuth2/OIDC provider presets and a generic provider constructor.

Index

Constants

This section is empty.

Variables

View Source
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

type EndpointValidator func(context.Context, *url.URL) error

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 New

func New(providerID string, options Options) (*Provider, error)

func NewOIDC

func NewOIDC(ctx context.Context, providerID string, options Options) (*Provider, error)

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 (p *Provider) AuthorizationURL(state, challenge, nonce, redirectURI string) (string, error)

func (*Provider) DisableImplicitSignUp

func (p *Provider) DisableImplicitSignUp() bool

DisableImplicitSignUp implements betterauth.OAuthProviderSignUpPolicy.

func (*Provider) DisableSignUp

func (p *Provider) DisableSignUp() bool

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"
)

Jump to

Keyboard shortcuts

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