v0hooks

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMFAHookRejectionMessage      = "Further MFA verification attempts will be rejected."
	DefaultPasswordHookRejectionMessage = "Further password verification attempts will be rejected."
)
View Source
const (
	HookRejection = "reject"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessTokenClaims

type AccessTokenClaims struct {
	jwt.RegisteredClaims
	Email                         string                 `json:"email"`
	Phone                         string                 `json:"phone"`
	AppMetaData                   map[string]interface{} `json:"app_metadata"`
	UserMetaData                  map[string]interface{} `json:"user_metadata"`
	Role                          string                 `json:"role"`
	AuthenticatorAssuranceLevel   string                 `json:"aal,omitempty"`
	AuthenticationMethodReference []models.AMREntry      `json:"amr,omitempty"`
	SessionId                     string                 `json:"session_id,omitempty"`
	IsAnonymous                   bool                   `json:"is_anonymous"`
	ClientID                      string                 `json:"client_id,omitempty"`
	Scope                         string                 `json:"scope,omitempty"`
}

AccessTokenClaims is a struct thats used for JWT claims

type AfterUserCreatedInput

type AfterUserCreatedInput struct {
	Metadata *Metadata    `json:"metadata"`
	User     *models.User `json:"user"`
}

func NewAfterUserCreatedInput

func NewAfterUserCreatedInput(
	r *http.Request,
	user *models.User,
) *AfterUserCreatedInput

type AfterUserCreatedOutput

type AfterUserCreatedOutput struct{}

type BeforeUserCreatedInput

type BeforeUserCreatedInput struct {
	Metadata *Metadata    `json:"metadata"`
	User     *models.User `json:"user"`
}

func NewBeforeUserCreatedInput

func NewBeforeUserCreatedInput(
	r *http.Request,
	user *models.User,
) *BeforeUserCreatedInput

type BeforeUserCreatedOutput

type BeforeUserCreatedOutput struct {
}

type CustomAccessTokenInput

type CustomAccessTokenInput struct {
	Metadata             *Metadata          `json:"metadata"`
	UserID               uuid.UUID          `json:"user_id"`
	Claims               *AccessTokenClaims `json:"claims"`
	AuthenticationMethod string             `json:"authentication_method"`
}

func NewCustomAccessTokenInput

func NewCustomAccessTokenInput(
	r *http.Request,
	userID uuid.UUID,
	claims *AccessTokenClaims,
	authenticationMethod string,
) *CustomAccessTokenInput

type CustomAccessTokenOutput

type CustomAccessTokenOutput struct {
	Claims map[string]any `json:"claims"`
}

func (*CustomAccessTokenOutput) UnmarshalJSON

func (o *CustomAccessTokenOutput) UnmarshalJSON(b []byte) error

type MFAVerificationAttemptInput

type MFAVerificationAttemptInput struct {
	Metadata   *Metadata `json:"metadata"`
	UserID     uuid.UUID `json:"user_id"`
	FactorID   uuid.UUID `json:"factor_id"`
	FactorType string    `json:"factor_type"`
	Valid      bool      `json:"valid"`
}

func NewMFAVerificationAttemptInput

func NewMFAVerificationAttemptInput(
	r *http.Request,
	userID uuid.UUID,
	factorID uuid.UUID,
	factorType string,
	valid bool,
) *MFAVerificationAttemptInput

type MFAVerificationAttemptOutput

type MFAVerificationAttemptOutput struct {
	Decision string `json:"decision"`
	Message  string `json:"message"`
}

type Manager

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

func NewManager

func NewManager(
	config *conf.GlobalConfiguration,
	httpDr *hookshttp.Dispatcher,
	pgfuncDr *hookspgfunc.Dispatcher,
) *Manager

func (*Manager) Enabled

func (o *Manager) Enabled(name Name) bool

func (*Manager) InvokeHook

func (o *Manager) InvokeHook(
	conn *storage.Connection,
	r *http.Request,
	input, output any,
) error

type Metadata

type Metadata struct {
	UUID uuid.UUID `json:"uuid"`
	Time time.Time `json:"time"`

	// Hook name
	Name Name `json:"name,omitempty"`

	// IP Address of the request, if present
	IPAddress string `json:"ip_address,omitempty"`
}

func NewMetadata

func NewMetadata(r *http.Request, name Name) *Metadata

type Name

type Name string
const (
	SendSMS              Name = "send-sms"
	SendEmail            Name = "send-email"
	CustomizeAccessToken Name = "customize-access-token"
	MFAVerification      Name = "mfa-verification"
	PasswordVerification Name = "password-verification"
	BeforeUserCreated    Name = "before-user-created"
	AfterUserCreated     Name = "after-user-created"
)

type PasswordVerificationAttemptInput

type PasswordVerificationAttemptInput struct {
	Metadata *Metadata `json:"metadata"`
	UserID   uuid.UUID `json:"user_id"`
	Valid    bool      `json:"valid"`
}

func NewPasswordVerificationAttemptInput

func NewPasswordVerificationAttemptInput(
	r *http.Request,
	userID uuid.UUID,
	valid bool,
) *PasswordVerificationAttemptInput

type PasswordVerificationAttemptOutput

type PasswordVerificationAttemptOutput struct {
	Decision         string `json:"decision"`
	Message          string `json:"message"`
	ShouldLogoutUser bool   `json:"should_logout_user"`
}

type SMS

type SMS struct {
	OTP     string `json:"otp,omitempty"`
	SMSType string `json:"sms_type,omitempty"`
	Phone   string `json:"phone,omitempty"`
}

TODO(joel): Move this to phone package

type SendEmailInput

type SendEmailInput struct {
	Metadata  *Metadata        `json:"metadata"`
	User      *models.User     `json:"user"`
	EmailData mailer.EmailData `json:"email_data"`
}

func NewSendEmailInput

func NewSendEmailInput(
	r *http.Request,
	user *models.User,
	emailData mailer.EmailData,
) *SendEmailInput

type SendEmailOutput

type SendEmailOutput struct {
}

type SendSMSInput

type SendSMSInput struct {
	Metadata *Metadata    `json:"metadata"`
	User     *models.User `json:"user,omitempty"`
	SMS      SMS          `json:"sms,omitempty"`
}

func NewSendSMSInput

func NewSendSMSInput(
	r *http.Request,
	user *models.User,
	sms SMS,
) *SendSMSInput

type SendSMSOutput

type SendSMSOutput struct {
}

Jump to

Keyboard shortcuts

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