types

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: MIT Imports: 6 Imported by: 5

Documentation

Index

Constants

View Source
const (
	VerificationTypeSignup      = "signup"
	VerificationTypeRecovery    = "recovery"
	VerificationTypeInvite      = "invite"
	VerificationTypeMagiclink   = "magiclink"
	VerificationTypeEmailChange = "email_change"
	VerificationTypeSMS         = "sms"
	VerificationTypePhoneChange = "phone_change"
)

Variables

View Source
var (
	ErrInvalidAdminAuditRequest        = errors.New("admin audit request is invalid - if Query is not nil, then query Column must be author, action or type, and value must be given")
	ErrInvalidAdminUpdateFactorRequest = errors.New("admin update factor request is invalid - nothing to update")
	ErrInvalidTokenRequest             = errors.New("token request is invalid - grant_type must be either one of password, refresh_token, or pkce, email and password must be provided for grant_type=password, refresh_token must be provided for grant_type=refresh_token, auth_code and code_verifier must be provided for grant_type=pkce")
	ErrInvalidVerifyRequest            = errors.New("verify request is invalid - type, token and redirect_to must be provided, and email or phone must be provided to VerifyForUser")
)

Functions

This section is empty.

Types

type AdminAuditRequest

type AdminAuditRequest struct {
	// Query, if provided, is used to search the audit log.
	// Logs will be returned where the chosen column matches the value.
	Query *AuditQuery

	// Pagination
	Page    uint
	PerPage uint
}

type AdminAuditResponse

type AdminAuditResponse struct {
	Logs []AuditLogEntry

	// Pagination
	TotalCount int
	TotalPages uint
	NextPage   uint
}

type AdminCreateSSOProviderRequest

type AdminCreateSSOProviderRequest struct {
	ResourceID       string               `json:"resource_id"`
	Type             string               `json:"type"`
	MetadataURL      string               `json:"metadata_url"`
	MetadataXML      string               `json:"metadata_xml"`
	Domains          []string             `json:"domains"`
	AttributeMapping SAMLAttributeMapping `json:"attribute_mapping"`
}

type AdminCreateSSOProviderResponse

type AdminCreateSSOProviderResponse struct {
	SSOProvider
}

type AdminCreateUserRequest

type AdminCreateUserRequest struct {
	Aud          string                 `json:"aud,omitempty"`
	Role         string                 `json:"role,omitempty"`
	Email        string                 `json:"email,omitempty"`
	Phone        string                 `json:"phone,omitempty"`
	Password     *string                `json:"password,omitempty"` // Only if type = signup
	EmailConfirm bool                   `json:"email_confirm,omitempty"`
	PhoneConfirm bool                   `json:"phone_confirm,omitempty"`
	UserMetadata map[string]interface{} `json:"user_metadata,omitempty"`
	AppMetadata  map[string]interface{} `json:"app_metadata,omitempty"`
	BanDuration  time.Duration          `json:"ban_duration,omitempty"` // Cannot be "none" when creating a user, so just set it or leave it empty
}

type AdminCreateUserResponse

type AdminCreateUserResponse struct {
	User
}

type AdminDeleteSSOProviderRequest

type AdminDeleteSSOProviderRequest struct {
	ProviderID uuid.UUID
}

type AdminDeleteSSOProviderResponse

type AdminDeleteSSOProviderResponse struct {
	SSOProvider
}

type AdminDeleteUserFactorRequest

type AdminDeleteUserFactorRequest struct {
	UserID   uuid.UUID
	FactorID uuid.UUID
}

type AdminDeleteUserRequest

type AdminDeleteUserRequest struct {
	UserID uuid.UUID
}

type AdminGenerateLinkRequest

type AdminGenerateLinkRequest struct {
	Type       LinkType               `json:"type"`
	Email      string                 `json:"email"`
	NewEmail   string                 `json:"new_email"`
	Password   string                 `json:"password"`
	Data       map[string]interface{} `json:"data"`
	RedirectTo string                 `json:"redirect_to"`
}

type AdminGenerateLinkResponse

type AdminGenerateLinkResponse struct {
	ActionLink       string   `json:"action_link"`
	EmailOTP         string   `json:"email_otp"`
	HashedToken      string   `json:"hashed_token"`
	RedirectTo       string   `json:"redirect_to"`
	VerificationType LinkType `json:"verification_type"`

	User
}

type AdminGetSSOProviderRequest

type AdminGetSSOProviderRequest struct {
	ProviderID uuid.UUID
}

type AdminGetSSOProviderResponse

type AdminGetSSOProviderResponse struct {
	SSOProvider
}

type AdminGetUserRequest

type AdminGetUserRequest struct {
	UserID uuid.UUID
}

type AdminGetUserResponse

type AdminGetUserResponse struct {
	User
}

type AdminListSSOProvidersResponse

type AdminListSSOProvidersResponse struct {
	Providers []SSOProvider `json:"items"`
}

type AdminListUserFactorsRequest

type AdminListUserFactorsRequest struct {
	UserID uuid.UUID
}

type AdminListUserFactorsResponse

type AdminListUserFactorsResponse struct {
	Factors []Factor
}

type AdminListUsersResponse

type AdminListUsersResponse struct {
	Users []User `json:"users"`
}

type AdminUpdateSSOProviderRequest

type AdminUpdateSSOProviderRequest struct {
	ProviderID uuid.UUID `json:"-"`

	ResourceID       string               `json:"resource_id"`
	Type             string               `json:"type"`
	MetadataURL      string               `json:"metadata_url"`
	MetadataXML      string               `json:"metadata_xml"`
	Domains          []string             `json:"domains"`
	AttributeMapping SAMLAttributeMapping `json:"attribute_mapping"`
}

type AdminUpdateSSOProviderResponse

type AdminUpdateSSOProviderResponse struct {
	SSOProvider
}

type AdminUpdateUserFactorRequest

type AdminUpdateUserFactorRequest struct {
	UserID   uuid.UUID `json:"-"`
	FactorID uuid.UUID `json:"-"`

	FriendlyName string `json:"friendly_name,omitempty"`
}

type AdminUpdateUserFactorResponse

type AdminUpdateUserFactorResponse struct {
	Factor
}

type AdminUpdateUserRequest

type AdminUpdateUserRequest struct {
	UserID uuid.UUID `json:"-"`

	Aud          string                 `json:"aud,omitempty"`
	Role         string                 `json:"role,omitempty"`
	Email        string                 `json:"email,omitempty"`
	Phone        string                 `json:"phone,omitempty"`
	Password     string                 `json:"password,omitempty"`
	EmailConfirm bool                   `json:"email_confirm,omitempty"`
	PhoneConfirm bool                   `json:"phone_confirm,omitempty"`
	UserMetadata map[string]interface{} `json:"user_metadata,omitempty"`
	AppMetadata  map[string]interface{} `json:"app_metadata,omitempty"`
	BanDuration  *BanDuration           `json:"ban_duration,omitempty"`
}

type AdminUpdateUserResponse

type AdminUpdateUserResponse struct {
	User
}

type AuditLogEntry

type AuditLogEntry struct {
	ID        uuid.UUID              `json:"id" db:"id"`
	Payload   map[string]interface{} `json:"payload" db:"payload"`
	CreatedAt time.Time              `json:"created_at" db:"created_at"`
	IPAddress string                 `json:"ip_address" db:"ip_address"`
}

type AuditQuery

type AuditQuery struct {
	Column AuditQueryColumn
	Value  string
}

type AuditQueryColumn

type AuditQueryColumn string

--- Request/Response Types ---

const (
	AuditQueryColumnAuthor AuditQueryColumn = "author"
	AuditQueryColumnAction AuditQueryColumn = "action"
	AuditQueryColumnType   AuditQueryColumn = "type"
)

type AuthorizeRequest

type AuthorizeRequest struct {
	Provider   Provider
	RedirectTo string
	FlowType   FlowType
	Scopes     string
}

type AuthorizeResponse

type AuthorizeResponse struct {
	AuthorizationURL string
	Verifier         string
}

type BanDuration

type BanDuration struct {
	// contains filtered or unexported fields
}

func BanDurationNone

func BanDurationNone() BanDuration

func BanDurationTime

func BanDurationTime(d time.Duration) BanDuration

func (BanDuration) MarshalJSON

func (b BanDuration) MarshalJSON() ([]byte, error)

func (BanDuration) String

func (b BanDuration) String() string

func (*BanDuration) UnmarshalJSON

func (b *BanDuration) UnmarshalJSON(data []byte) error

func (BanDuration) Value

func (b BanDuration) Value() *time.Duration

type ChallengeFactorRequest

type ChallengeFactorRequest struct {
	FactorID uuid.UUID `json:"factor_id"`
}

type ChallengeFactorResponse

type ChallengeFactorResponse struct {
	ID        uuid.UUID `json:"id"`
	ExpiresAt time.Time `json:"expires_at"`
}

type EnrollFactorRequest

type EnrollFactorRequest struct {
	FriendlyName string     `json:"friendly_name"`
	FactorType   FactorType `json:"factor_type"`
	Issuer       string     `json:"issuer"`
}

type EnrollFactorResponse

type EnrollFactorResponse struct {
	ID   uuid.UUID  `json:"id"`
	Type FactorType `json:"type"`
	TOTP TOTPObject `json:"totp,omitempty"`
}

type ErrInvalidGenerateLinkRequest

type ErrInvalidGenerateLinkRequest struct {
	// contains filtered or unexported fields
}

func NewErrInvalidGenerateLinkRequest

func NewErrInvalidGenerateLinkRequest(message string) *ErrInvalidGenerateLinkRequest

func (*ErrInvalidGenerateLinkRequest) Error

type ExternalProviders

type ExternalProviders struct {
	Apple     bool `json:"apple"`
	Azure     bool `json:"azure"`
	Bitbucket bool `json:"bitbucket"`
	Discord   bool `json:"discord"`
	Email     bool `json:"email"`
	Facebook  bool `json:"facebook"`
	GitHub    bool `json:"github"`
	GitLab    bool `json:"gitlab"`
	Google    bool `json:"google"`
	Keycloak  bool `json:"keycloak"`
	Linkedin  bool `json:"linkedin"`
	Notion    bool `json:"notion"`
	Phone     bool `json:"phone"`
	SAML      bool `json:"saml"`
	Slack     bool `json:"slack"`
	Spotify   bool `json:"spotify"`
	Twitch    bool `json:"twitch"`
	Twitter   bool `json:"twitter"`
	WorkOS    bool `json:"workos"`
	Zoom      bool `json:"zoom"`
}

type Factor

type Factor struct {
	ID           uuid.UUID `json:"id"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
	Status       string    `json:"status"`
	FriendlyName string    `json:"friendly_name,omitempty"`
	FactorType   string    `json:"factor_type"`
}

type FactorType

type FactorType string
const FactorTypeTOTP FactorType = "totp"

type FlowType

type FlowType string
const (
	FlowImplicit FlowType = "implicit"
	FlowPKCE     FlowType = "pkce"
)

type GoTrueMetaSecurity

type GoTrueMetaSecurity struct {
	CaptchaToken string `json:"captcha_token"`
}

type HealthCheckResponse

type HealthCheckResponse struct {
	Version     string `json:"version"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type Identity

type Identity struct {
	ID           string                 `json:"id"`
	UserID       uuid.UUID              `json:"user_id"`
	IdentityData map[string]interface{} `json:"identity_data,omitempty"`
	Provider     string                 `json:"provider"`
	LastSignInAt *time.Time             `json:"last_sign_in_at,omitempty"`
	CreatedAt    time.Time              `json:"created_at"`
	UpdatedAt    time.Time              `json:"updated_at"`
}

type InviteRequest

type InviteRequest struct {
	Email string                 `json:"email"`
	Data  map[string]interface{} `json:"data"`
}

type InviteResponse

type InviteResponse struct {
	User
}

type LinkType

type LinkType string
const (
	LinkTypeSignup             LinkType = "signup"
	LinkTypeMagicLink          LinkType = "magiclink"
	LinkTypeRecovery           LinkType = "recovery"
	LinkTypeInvite             LinkType = "invite"
	LinkTypeEmailChangeCurrent LinkType = "email_change_current"
	LinkTypeEmailChangeNew     LinkType = "email_change_new"
)

type MagiclinkRequest

type MagiclinkRequest struct {
	Email string `json:"email"`

	// Provide Captcha token if enabled.
	SecurityEmbed
}

DEPRECATED: Use /otp with Email and CreateUser=true instead of /magiclink.

type OTPRequest

type OTPRequest struct {
	Email      string                 `json:"email"`
	Phone      string                 `json:"phone"`
	CreateUser bool                   `json:"create_user"`
	Data       map[string]interface{} `json:"data"`

	// Provide Captcha token if enabled.
	SecurityEmbed
}

type PKCEParams

type PKCEParams struct {
	Challenge       string
	ChallengeMethod string
	Verifier        string
}

adapted from https://go-review.googlesource.com/c/oauth2/+/463979/9/pkce.go#64

type Provider

type Provider string
const (
	ProviderApple     Provider = "apple"
	ProviderAzure     Provider = "azure"
	ProviderBitbucket Provider = "bitbucket"
	ProviderDiscord   Provider = "discord"
	ProviderGitHub    Provider = "github"
	ProviderGitLab    Provider = "gitlab"
	ProviderGoogle    Provider = "google"
	ProviderKeycloak  Provider = "keycloak"
	ProviderLinkedin  Provider = "linkedin"
	ProviderFacebook  Provider = "facebook"
	ProviderNotion    Provider = "notion"
	ProviderSpotify   Provider = "spotify"
	ProviderSlack     Provider = "slack"
	ProviderTwitch    Provider = "twitch"
	ProviderTwitter   Provider = "twitter"
	ProviderWorkOS    Provider = "workos"
	ProviderZoom      Provider = "zoom"
)

type RecoverRequest

type RecoverRequest struct {
	Email string `json:"email"`

	// Provide Captcha token if enabled.
	SecurityEmbed
}

type SAMLAttribute

type SAMLAttribute struct {
	Name    string      `json:"name,omitempty"`
	Names   []string    `json:"names,omitempty"`
	Default interface{} `json:"default,omitempty"`
}

type SAMLAttributeMapping

type SAMLAttributeMapping struct {
	Keys map[string]SAMLAttribute `json:"keys,omitempty"`
}

type SAMLProvider

type SAMLProvider struct {
	EntityID    string  `json:"entity_id"`
	MetadataXML string  `json:"metadata_xml,omitempty"`
	MetadataURL *string `json:"metadata_url,omitempty"`

	AttributeMapping SAMLAttributeMapping `json:"attribute_mapping,omitempty"`
}

type SSODomain

type SSODomain struct {
	Domain string `db:"domain" json:"domain"`
}

type SSOProvider

type SSOProvider struct {
	ID           uuid.UUID    `json:"id"`
	ResourceID   *string      `json:"resource_id,omitempty"`
	SAMLProvider SAMLProvider `json:"saml,omitempty"`
	SSODomains   []SSODomain  `json:"domains"`
	CreatedAt    time.Time    `json:"created_at"`
	UpdatedAt    time.Time    `json:"updated_at"`
}

type SSORequest

type SSORequest struct {
	// Use either ProviderID or Domain.
	ProviderID       uuid.UUID `json:"provider_id"`
	Domain           string    `json:"domain"`
	RedirectTo       string    `json:"redirect_to"`
	SkipHTTPRedirect bool      `json:"skip_http_redirect"`

	// Provide Captcha token if enabled.
	SecurityEmbed
}

type SSOResponse

type SSOResponse struct {
	// Returned only if SkipHTTPRedirect was set in request.
	URL string `json:"url"`

	// Returned otherwise.
	HTTPResponse *http.Response `json:"-"`
}

type SecurityEmbed

type SecurityEmbed struct {
	Security GoTrueMetaSecurity `json:"gotrue_meta_security"`
}

type Session

type Session struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	ExpiresAt    int64  `json:"expires_at"`
	User         User   `json:"user"`
}

type SettingsResponse

type SettingsResponse struct {
	DisableSignup     bool              `json:"disable_signup"`
	Autoconfirm       bool              `json:"autoconfirm"`
	MailerAutoconfirm bool              `json:"mailer_autoconfirm"`
	PhoneAutoconfirm  bool              `json:"phone_autoconfirm"`
	SmsProvider       string            `json:"sms_provider"`
	MFAEnabled        bool              `json:"mfa_enabled"`
	External          ExternalProviders `json:"external"`
}

type SignupRequest

type SignupRequest struct {
	Email    string                 `json:"email,omitempty"`
	Phone    string                 `json:"phone,omitempty"`
	Password string                 `json:"password,omitempty"`
	Data     map[string]interface{} `json:"data,omitempty"`

	// Provide Captcha token if enabled.
	SecurityEmbed
}

type SignupResponse

type SignupResponse struct {
	// Response if autoconfirm is off
	User

	// Response if autoconfirm is on
	Session
}

type TOTPObject

type TOTPObject struct {
	QRCode string `json:"qr_code"`
	Secret string `json:"secret"`
	URI    string `json:"uri"`
}

type TokenRequest

type TokenRequest struct {
	GrantType string `json:"-"`

	// Email or Phone, and Password, are required if GrantType is 'password'.
	// They must not be provided if GrantType is 'refresh_token'.
	Email    string `json:"email,omitempty"`
	Phone    string `json:"phone,omitempty"`
	Password string `json:"password,omitempty"`

	// RefreshToken is required if GrantType is 'refresh_token'.
	// It must not be provided if GrantType is 'password'.
	RefreshToken string `json:"refresh_token,omitempty"`

	// Code and CodeVerifier are required if GrantType is 'pkce'.
	Code         string `json:"auth_code,omitempty"`
	CodeVerifier string `json:"code_verifier,omitempty"`

	// Provide Captcha token if enabled. Not required if GrantType is 'refresh_token'.
	SecurityEmbed
}

type TokenResponse

type TokenResponse struct {
	Session
}

type UnenrollFactorRequest

type UnenrollFactorRequest struct {
	FactorID uuid.UUID
}

type UnenrollFactorResponse

type UnenrollFactorResponse struct {
	ID uuid.UUID `json:"id"`
}

type UpdateUserRequest

type UpdateUserRequest struct {
	Email    string                 `json:"email,omitempty"`
	Password *string                `json:"password,omitempty"`
	Nonce    string                 `json:"nonce,omitempty"`
	Data     map[string]interface{} `json:"data,omitempty"`
	AppData  map[string]interface{} `json:"app_metadata,omitempty"`
	Phone    string                 `json:"phone,omitempty"`
}

type UpdateUserResponse

type UpdateUserResponse struct {
	User
}

type User

type User struct {
	ID uuid.UUID `json:"id"`

	Aud              string     `json:"aud"`
	Role             string     `json:"role"`
	Email            string     `json:"email"`
	EmailConfirmedAt *time.Time `json:"email_confirmed_at,omitempty"`
	InvitedAt        *time.Time `json:"invited_at,omitempty"`

	Phone            string     `json:"phone"`
	PhoneConfirmedAt *time.Time `json:"phone_confirmed_at,omitempty"`

	ConfirmationSentAt *time.Time `json:"confirmation_sent_at,omitempty"`

	RecoverySentAt *time.Time `json:"recovery_sent_at,omitempty"`

	EmailChange       string     `json:"new_email,omitempty"`
	EmailChangeSentAt *time.Time `json:"email_change_sent_at,omitempty"`

	PhoneChange       string     `json:"new_phone,omitempty"`
	PhoneChangeSentAt *time.Time `json:"phone_change_sent_at,omitempty"`

	ReauthenticationSentAt *time.Time `json:"reauthentication_sent_at,omitempty"`

	LastSignInAt *time.Time `json:"last_sign_in_at,omitempty"`

	AppMetadata  map[string]interface{} `json:"app_metadata"`
	UserMetadata map[string]interface{} `json:"user_metadata"`

	Factors    []Factor   `json:"factors,omitempty"`
	Identities []Identity `json:"identities"`

	CreatedAt   time.Time  `json:"created_at"`
	UpdatedAt   time.Time  `json:"updated_at"`
	BannedUntil *time.Time `json:"banned_until,omitempty"`

	// ConfirmedAt is deprecated. Use EmailConfirmedAt or PhoneConfirmedAt instead.
	ConfirmedAt time.Time `json:"confirmed_at"`
}

type UserResponse

type UserResponse struct {
	User
}

type VerificationType

type VerificationType string

type VerifyFactorRequest

type VerifyFactorRequest struct {
	FactorID uuid.UUID `json:"-"`

	ChallengeID uuid.UUID `json:"challenge_id"`
	Code        string    `json:"code"`
}

type VerifyFactorResponse

type VerifyFactorResponse struct {
	Session
}

type VerifyForUserRequest

type VerifyForUserRequest struct {
	Type       VerificationType `json:"type"`
	Token      string           `json:"token"`
	RedirectTo string           `json:"redirect_to"`
	Email      string           `json:"email"`
	Phone      string           `json:"phone"`

	// Provide Captcha token if enabled.
	// Not required for server version >= v2.30.1
	SecurityEmbed
}

type VerifyForUserResponse

type VerifyForUserResponse struct {
	Session
}

type VerifyRequest

type VerifyRequest struct {
	Type       VerificationType
	Token      string
	RedirectTo string
}

type VerifyResponse

type VerifyResponse struct {
	URL string

	// The fields below are returned only for a successful response.
	AccessToken  string
	TokenType    string
	ExpiresIn    int
	RefreshToken string
	Type         VerificationType

	// The fields below are returned if there was an error verifying.
	Error            string
	ErrorCode        string
	ErrorDescription string
}

Jump to

Keyboard shortcuts

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