Documentation
¶
Index ¶
- Constants
- func ParseBody[T any](res *http.Response, target *T) error
- type Admin
- func (a *Admin) CreateUser(ctx context.Context, params AdminUserParams) (*AdminUser, *ErrorResponse)
- func (a *Admin) GenerateLink(ctx context.Context, params GenerateLinkParams) (*GenerateLinkResponse, error)
- func (a *Admin) GetUser(ctx context.Context, userID string) (*AdminUser, *ErrorResponse)
- func (a *Admin) UpdateUser(ctx context.Context, userID string, params AdminUserParams) (*AdminUser, *ErrorResponse)
- type AdminUser
- type AdminUserParams
- type Auth
- func (a *Auth) ExchangeCode(ctx context.Context, opts ExchangeCodeOpts) (*AuthenticatedDetails, *ErrorResponse)
- func (a *Auth) InviteUserByEmail(ctx context.Context, email string) (*User, *ErrorResponse)
- func (a *Auth) InviteUserByEmailWithData(ctx context.Context, email string, data map[string]interface{}, ...) (*User, *ErrorResponse)
- func (a *Auth) RefreshUser(ctx context.Context, userToken string, refreshToken string) (*AuthenticatedDetails, *ErrorResponse)
- func (a *Auth) ResetPasswordForEmail(ctx context.Context, email string) *ErrorResponse
- func (a *Auth) SendMagicLink(ctx context.Context, email string) *ErrorResponse
- func (a *Auth) SignIn(ctx context.Context, credentials UserCredentials) (*AuthenticatedDetails, *ErrorResponse)
- func (a *Auth) SignInWithProvider(opts ProviderSignInOptions) (*ProviderSignInDetails, *ErrorResponse)
- func (a *Auth) SignOut(ctx context.Context, userToken string) *ErrorResponse
- func (a *Auth) SignUp(ctx context.Context, credentials UserCredentials) (*User, *ErrorResponse)
- func (a *Auth) UpdateUser(ctx context.Context, userToken string, updateData map[string]interface{}) (*User, *ErrorResponse)
- func (a *Auth) User(ctx context.Context, userToken string) (*User, *ErrorResponse)
- type AuthenticatedDetails
- type Client
- type ErrorResponse
- type ExchangeCodeOpts
- type Factor
- type FlowType
- type GenerateLinkParams
- type GenerateLinkResponse
- type Identity
- type JSONMap
- type PKCEParams
- type ProviderSignInDetails
- type ProviderSignInOptions
- type User
- type UserCredentials
Constants ¶
const ( AuthEndpoint = "auth/v1" AdminEndpoint = "auth/v1/admin" RestEndpoint = "rest/v1" StorageEndpoint = "storage/v1" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Admin ¶
type Admin struct {
// contains filtered or unexported fields
}
func (*Admin) CreateUser ¶
func (a *Admin) CreateUser(ctx context.Context, params AdminUserParams) (*AdminUser, *ErrorResponse)
Create a user
func (*Admin) GenerateLink ¶
func (a *Admin) GenerateLink(ctx context.Context, params GenerateLinkParams) (*GenerateLinkResponse, error)
Update a user
func (*Admin) UpdateUser ¶
func (a *Admin) UpdateUser(ctx context.Context, userID string, params AdminUserParams) (*AdminUser, *ErrorResponse)
Update a user
type AdminUser ¶
type AdminUser struct { ID string `json:"id" db:"id"` Aud string `json:"aud" db:"aud"` Role string `json:"role" db:"role"` Email string `json:"email" db:"email"` EmailConfirmedAt *time.Time `json:"email_confirmed_at,omitempty" db:"email_confirmed_at"` InvitedAt *time.Time `json:"invited_at,omitempty" db:"invited_at"` Phone string `json:"phone" db:"phone"` PhoneConfirmedAt *time.Time `json:"phone_confirmed_at,omitempty" db:"phone_confirmed_at"` ConfirmationSentAt *time.Time `json:"confirmation_sent_at,omitempty" db:"confirmation_sent_at"` RecoverySentAt *time.Time `json:"recovery_sent_at,omitempty" db:"recovery_sent_at"` EmailChange string `json:"new_email,omitempty" db:"email_change"` EmailChangeSentAt *time.Time `json:"email_change_sent_at,omitempty" db:"email_change_sent_at"` PhoneChange string `json:"new_phone,omitempty" db:"phone_change"` PhoneChangeSentAt *time.Time `json:"phone_change_sent_at,omitempty" db:"phone_change_sent_at"` ReauthenticationSentAt *time.Time `json:"reauthentication_sent_at,omitempty" db:"reauthentication_sent_at"` LastSignInAt *time.Time `json:"last_sign_in_at,omitempty" db:"last_sign_in_at"` AppMetaData JSONMap `json:"app_metadata" db:"raw_app_meta_data"` UserMetaData JSONMap `json:"user_metadata" db:"raw_user_meta_data"` Factors []Factor `json:"factors,omitempty" has_many:"factors"` Identities []Identity `json:"identities" has_many:"identities"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` BannedUntil *time.Time `json:"banned_until,omitempty" db:"banned_until"` DeletedAt *time.Time `json:"deleted_at,omitempty" db:"deleted_at"` }
type AdminUserParams ¶
type AdminUserParams struct { Role string `json:"role"` Email string `json:"email"` Phone string `json:"phone"` Password *string `json:"password"` EmailConfirm bool `json:"email_confirm"` PhoneConfirm bool `json:"phone_confirm"` UserMetadata JSONMap `json:"user_metadata"` AppMetadata JSONMap `json:"app_metadata"` BanDuration string `json:"ban_duration"` }
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
func (*Auth) ExchangeCode ¶
func (a *Auth) ExchangeCode(ctx context.Context, opts ExchangeCodeOpts) (*AuthenticatedDetails, *ErrorResponse)
ExchangeCode takes an auth code and PCKE verifier and returns the current user if succeeded.
func (*Auth) InviteUserByEmail ¶
InviteUserByEmail sends an invite link to the given email. Returns a user.
func (*Auth) InviteUserByEmailWithData ¶
func (a *Auth) InviteUserByEmailWithData(ctx context.Context, email string, data map[string]interface{}, redirectTo string) (*User, *ErrorResponse)
InviteUserByEmailWithOpts sends an invite link to the given email with metadata. Returns a user.
func (*Auth) RefreshUser ¶
func (a *Auth) RefreshUser(ctx context.Context, userToken string, refreshToken string) (*AuthenticatedDetails, *ErrorResponse)
SignIn enters the user credentials and returns the current user if succeeded.
func (*Auth) ResetPasswordForEmail ¶
func (a *Auth) ResetPasswordForEmail(ctx context.Context, email string) *ErrorResponse
ResetPasswordForEmail sends a password recovery link to the given e-mail address.
func (*Auth) SendMagicLink ¶
func (a *Auth) SendMagicLink(ctx context.Context, email string) *ErrorResponse
SendMagicLink sends a link to a specific e-mail address for passwordless auth.
func (*Auth) SignIn ¶
func (a *Auth) SignIn(ctx context.Context, credentials UserCredentials) (*AuthenticatedDetails, *ErrorResponse)
SignIn enters the user credentials and returns the current user if succeeded.
func (*Auth) SignInWithProvider ¶
func (a *Auth) SignInWithProvider(opts ProviderSignInOptions) (*ProviderSignInDetails, *ErrorResponse)
SignInWithProvider returns a URL for signing in via OAuth
func (*Auth) SignOut ¶
func (a *Auth) SignOut(ctx context.Context, userToken string) *ErrorResponse
SignOut revokes the users token and session.
func (*Auth) SignUp ¶
func (a *Auth) SignUp(ctx context.Context, credentials UserCredentials) (*User, *ErrorResponse)
SignUp registers the user's email and password to the database.
func (*Auth) UpdateUser ¶
func (a *Auth) UpdateUser(ctx context.Context, userToken string, updateData map[string]interface{}) (*User, *ErrorResponse)
UpdateUser updates the user information
type AuthenticatedDetails ¶
type AuthenticatedDetails struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` ExpiresIn int `json:"expires_in"` RefreshToken string `json:"refresh_token"` User User `json:"user"` ProviderToken string `json:"provider_token"` ProviderRefreshToken string `json:"provider_refresh_token"` }
type Client ¶
type ErrorResponse ¶
type ErrorResponse struct { Code int `json:"code"` Message string `json:"msg"` ErrorCode string `json:"error_code"` }
func GenericError ¶ added in v1.3.4
func GenericError(err error) *ErrorResponse
func NewErrorResponse ¶ added in v1.3.5
func NewErrorResponse(code int, message string, errorCode string) *ErrorResponse
func (*ErrorResponse) Error ¶
func (err *ErrorResponse) Error() string
type ExchangeCodeOpts ¶
type Factor ¶
type Factor struct { ID string `json:"id" db:"id"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` Status string `json:"status" db:"status"` FriendlyName string `json:"friendly_name,omitempty" db:"friendly_name"` FactorType string `json:"factor_type" db:"factor_type"` }
type GenerateLinkParams ¶
type GenerateLinkResponse ¶
type Identity ¶
type Identity struct { ID string `json:"id" db:"id"` UserID string `json:"user_id" db:"user_id"` IdentityData JSONMap `json:"identity_data,omitempty" db:"identity_data"` Provider string `json:"provider" db:"provider"` LastSignInAt *time.Time `json:"last_sign_in_at,omitempty" db:"last_sign_in_at"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
type PKCEParams ¶
adapted from https://go-review.googlesource.com/c/oauth2/+/463979/9/pkce.go#64
type ProviderSignInDetails ¶
type ProviderSignInOptions ¶
type User ¶
type User struct { ID string `json:"id"` Aud string `json:"aud"` Role string `json:"role"` Email string `json:"email"` InvitedAt time.Time `json:"invited_at"` ConfirmedAt time.Time `json:"confirmed_at"` ConfirmationSentAt time.Time `json:"confirmation_sent_at"` AppMetadata struct { // contains filtered or unexported fields } `json:"app_metadata"` UserMetadata map[string]interface{} `json:"user_metadata"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }