verification

package
v0.0.0-...-81cd3a7 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouteInitBrowserFlow = "/self-service/verification/browser"
	RouteInitAPIFlow     = "/self-service/verification/api"
	RouteGetFlow         = "/self-service/verification/flows"
)
View Source
const (
	StrategyVerificationLinkName = "link"
)

Variables

This section is empty.

Functions

func HasReachedState

func HasReachedState(expected, actual State) bool

func TestFlowPersister

func TestFlowPersister(p interface {
	FlowPersister
	identity.PrivilegedPool
}) func(t *testing.T)

Types

type AdminHandler

type AdminHandler interface {
	RegisterAdminVerificationRoutes(admin *x.RouterAdmin)
}

type ErrorHandler

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

func NewErrorHandler

func NewErrorHandler(d errorHandlerDependencies, c configuration.Provider) *ErrorHandler

func (*ErrorHandler) WriteFlowError

func (s *ErrorHandler) WriteFlowError(
	w http.ResponseWriter,
	r *http.Request,
	methodName string,
	f *Flow,
	err error,
)

type ErrorHandlerProvider

type ErrorHandlerProvider interface {
	VerificationFlowErrorHandler() *ErrorHandler
}

type Flow

type Flow struct {
	// ID represents the request's unique ID. When performing the verification flow, this
	// represents the id in the verify ui's query parameter: http://<selfservice.flows.verification.ui_url>?request=<id>
	//
	// type: string
	// format: uuid
	ID uuid.UUID `json:"id" db:"id" faker:"-"`

	// Type represents the flow's type which can be either "api" or "browser", depending on the flow interaction.
	Type flow.Type `json:"type" db:"type" faker:"flow_type"`

	// ExpiresAt is the time (UTC) when the request expires. If the user still wishes to verify the address,
	// a new request has to be initiated.
	ExpiresAt time.Time `json:"expires_at" faker:"time_type" db:"expires_at"`

	// IssuedAt is the time (UTC) when the request occurred.
	IssuedAt time.Time `json:"issued_at" faker:"time_type" db:"issued_at"`

	// RequestURL is the initial URL that was requested from ORY Kratos. It can be used
	// to forward information contained in the URL's path or query for example.
	RequestURL string `json:"request_url" db:"request_url"`

	// Active, if set, contains the registration method that is being used. It is initially
	// not set.
	Active sqlxx.NullString `json:"active,omitempty" faker:"-" db:"active_method"`

	// Messages contains a list of messages to be displayed in the Verification UI. Omitting these
	// messages makes it significantly harder for users to figure out what is going on.
	//
	// More documentation on messages can be found in the [User Interface Documentation](https://www.ory.sh/kratos/docs/concepts/ui-user-interface/).
	Messages text.Messages `json:"messages" faker:"-" db:"messages"`

	// Methods contains context for all account verification methods. If a registration request has been
	// processed, but for example the password is incorrect, this will contain error messages.
	//
	// required: true
	Methods map[string]*FlowMethod `json:"methods" faker:"verification_flow_methods" db:"-"`

	// MethodsRaw is a helper struct field for gobuffalo.pop.
	MethodsRaw FlowMethodsRaw `json:"-" faker:"-" has_many:"selfservice_verification_flow_methods" fk_id:"selfservice_verification_flow_id"`

	// State represents the state of this request:
	//
	// - choose_method: ask the user to choose a method (e.g. verify your email)
	// - sent_email: the email has been sent to the user
	// - passed_challenge: the request was successful and the verification challenge was passed.
	//
	// required: true
	State State `json:"state" faker:"-" db:"state"`

	// CSRFToken contains the anti-csrf token associated with this request.
	CSRFToken string `json:"-" db:"csrf_token"`

	// CreatedAt is a helper struct field for gobuffalo.pop.
	CreatedAt time.Time `json:"-" faker:"-" db:"created_at"`
	// UpdatedAt is a helper struct field for gobuffalo.pop.
	UpdatedAt time.Time `json:"-" faker:"-" db:"updated_at"`
}

A Verification Flow

Used to verify an out-of-band communication channel such as an email address or a phone number.

For more information head over to: https://www.ory.sh/docs/kratos/selfservice/flows/verify-email-account-activation

swagger:model verificationFlow

func NewFlow

func NewFlow(exp time.Duration, csrf string, r *http.Request, strategies Strategies, ft flow.Type) (*Flow, error)

func (*Flow) AfterFind

func (f *Flow) AfterFind(_ *pop.Connection) error

func (*Flow) AfterSave

func (f *Flow) AfterSave(c *pop.Connection) error

func (*Flow) AppendTo

func (f *Flow) AppendTo(src *url.URL) *url.URL

func (*Flow) BeforeSave

func (f *Flow) BeforeSave(_ *pop.Connection) error

func (*Flow) MethodToForm

func (f *Flow) MethodToForm(id string) (form.Form, error)

func (Flow) TableName

func (f Flow) TableName() string

func (*Flow) Valid

func (f *Flow) Valid() error

type FlowExpiredError

type FlowExpiredError struct {
	*herodot.DefaultError
	// contains filtered or unexported fields
}

func NewFlowExpiredError

func NewFlowExpiredError(at time.Time) *FlowExpiredError

type FlowMethod

type FlowMethod struct {
	// Method contains the request credentials type.
	//
	// required: true
	Method string `json:"method" db:"method"`

	// Config is the credential type's config.
	//
	// required: true
	Config *FlowMethodConfig `json:"config" db:"config"`

	// ID is a helper struct field for gobuffalo.pop.
	ID uuid.UUID `json:"-" db:"id"`

	// FlowID is a helper struct field for gobuffalo.pop.
	FlowID uuid.UUID `json:"-" db:"selfservice_verification_flow_id"`

	// Flow is a helper struct field for gobuffalo.pop.
	Flow *Flow `json:"-" belongs_to:"selfservice_flow_request" fk_id:"FlowID"`

	// CreatedAt is a helper struct field for gobuffalo.pop.
	CreatedAt time.Time `json:"-" db:"created_at"`

	// UpdatedAt is a helper struct field for gobuffalo.pop.
	UpdatedAt time.Time `json:"-" db:"updated_at"`
}

swagger:model verificationFlowMethod

func (FlowMethod) TableName

func (u FlowMethod) TableName() string

type FlowMethodConfig

type FlowMethodConfig struct {
	// swagger:ignore
	FlowMethodConfigurator

	FlowMethodConfigMock
}

swagger:model verificationFlowMethodConfig

func (*FlowMethodConfig) MarshalJSON

func (c *FlowMethodConfig) MarshalJSON() ([]byte, error)

func (*FlowMethodConfig) Scan

func (c *FlowMethodConfig) Scan(value interface{}) error

func (*FlowMethodConfig) UnmarshalJSON

func (c *FlowMethodConfig) UnmarshalJSON(data []byte) error

func (*FlowMethodConfig) Value

func (c *FlowMethodConfig) Value() (driver.Value, error)

type FlowMethodConfigMock

type FlowMethodConfigMock struct {
	*form.HTMLForm
}

swagger:model verificationFlowMethodConfigPayload

type FlowMethods

type FlowMethods map[string]*FlowMethod

func (FlowMethods) TableName

func (u FlowMethods) TableName() string

type FlowMethodsRaw

type FlowMethodsRaw []FlowMethod // workaround for https://github.com/gobuffalo/pop/pull/478

func (FlowMethodsRaw) TableName

func (u FlowMethodsRaw) TableName() string

type FlowPersistenceProvider

type FlowPersistenceProvider interface {
	VerificationFlowPersister() FlowPersister
}

type FlowPersister

type FlowPersister interface {
	CreateVerificationFlow(context.Context, *Flow) error
	GetVerificationFlow(ctx context.Context, id uuid.UUID) (*Flow, error)
	UpdateVerificationFlow(context.Context, *Flow) error
}

type Handler

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

func NewHandler

func NewHandler(d handlerDependencies, c configuration.Provider) *Handler

func (*Handler) RegisterAdminRoutes

func (h *Handler) RegisterAdminRoutes(admin *x.RouterAdmin)

func (*Handler) RegisterPublicRoutes

func (h *Handler) RegisterPublicRoutes(public *x.RouterPublic)

type HandlerProvider

type HandlerProvider interface {
	VerificationHandler() *Handler
}

type PublicHandler

type PublicHandler interface {
	RegisterPublicVerificationRoutes(public *x.RouterPublic)
}

type State

type State string
const (
	StateChooseMethod    State = "choose_method"
	StateEmailSent       State = "sent_email"
	StatePassedChallenge State = "passed_challenge"
)

func NextState

func NextState(current State) State

type Strategies

type Strategies []Strategy

func (Strategies) MustStrategy

func (s Strategies) MustStrategy(id string) Strategy

func (Strategies) RegisterAdminRoutes

func (s Strategies) RegisterAdminRoutes(r *x.RouterAdmin)

func (Strategies) RegisterPublicRoutes

func (s Strategies) RegisterPublicRoutes(r *x.RouterPublic)

func (Strategies) Strategy

func (s Strategies) Strategy(id string) (Strategy, error)

type Strategy

type Strategy interface {
	VerificationStrategyID() string
	PopulateVerificationMethod(*http.Request, *Flow) error
}

type StrategyProvider

type StrategyProvider interface {
	VerificationStrategies() Strategies
}

Jump to

Keyboard shortcuts

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