recovery

package
v0.4.3-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2020 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicRecoveryInitPath    = "/self-service/browser/flows/recovery"
	PublicRecoveryRequestPath = "/self-service/browser/flows/requests/recovery"
)
View Source
const (
	StrategyRecoveryTokenName = "link"
)

Variables

View Source
var (
	ErrRequestExpired = herodot.ErrBadRequest.
						WithError("recovery request expired").
						WithReasonf(`The recovery request has expired. Please restart the flow.`)
	ErrHookAbortRequest             = errors.New("aborted recovery hook execution")
	ErrRequestNeedsReAuthentication = herodot.ErrForbidden.WithReasonf("The login session is too old and thus not allowed to update these fields. Please re-authenticate.")
)

Functions

func HasReachedState

func HasReachedState(expected, actual State) bool

func TestRequestPersister

func TestRequestPersister(p interface {
	RequestPersister
	identity.PrivilegedPool
}) func(t *testing.T)

Types

type ErrorHandler

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

func NewErrorHandler

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

func (*ErrorHandler) HandleRecoveryError

func (s *ErrorHandler) HandleRecoveryError(
	w http.ResponseWriter,
	r *http.Request,
	rr *Request,
	err error,
	method string,
)

type ErrorHandlerProvider

type ErrorHandlerProvider interface{ RecoveryRequestErrorHandler() *ErrorHandler }

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 {
	RecoveryHandler() *Handler
}

type Request

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

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

	// IssuedAt is the time (UTC) when the request occurred.
	//
	// required: true
	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.
	//
	// required: true
	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 Recovery 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 recovery 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]*RequestMethod `json:"methods" faker:"recovery_request_methods" db:"-"`

	// MethodsRaw is a helper struct field for gobuffalo.pop.
	MethodsRaw RequestMethodsRaw `json:"-" faker:"-" has_many:"selfservice_recovery_request_methods" fk_id:"selfservice_recovery_request_id"`

	// State represents the state of this request:
	//
	// - choose_method: ask the user to choose a method (e.g. recover account via email)
	// - sent_email: the email has been sent to the user
	// - passed_challenge: the request was successful and the recovery 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"`

	// RecoveredIdentityID is a helper struct field for gobuffalo.pop.
	RecoveredIdentityID uuid.NullUUID `json:"-" faker:"-" db:"recovered_identity_id"`
}

Request presents a recovery request

This request is used when an identity wants to recover their account.

We recommend reading the [Account Recovery Documentation](../self-service/flows/password-reset-account-recovery)

swagger:model recoveryRequest

func NewRequest

func NewRequest(exp time.Duration, csrf string, r *http.Request, strategies Strategies) (*Request, error)

func (*Request) AfterFind

func (r *Request) AfterFind(_ *pop.Connection) error

func (*Request) AfterSave

func (r *Request) AfterSave(c *pop.Connection) error

func (*Request) BeforeSave

func (r *Request) BeforeSave(_ *pop.Connection) error

func (*Request) GetID

func (r *Request) GetID() uuid.UUID

func (*Request) MethodToForm

func (r *Request) MethodToForm(id string) (form.Form, error)

func (Request) TableName

func (r Request) TableName() string

func (*Request) URL

func (r *Request) URL(recoveryURL *url.URL) *url.URL

func (*Request) Valid

func (r *Request) Valid() error

type RequestMethod

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

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

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

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

	// Request is a helper struct field for gobuffalo.pop.
	Request *Request `json:"-" belongs_to:"selfservice_recovery_request" fk_id:"RequestID"`

	// 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 recoveryRequestMethod

func (RequestMethod) TableName

func (u RequestMethod) TableName() string

type RequestMethodConfig

type RequestMethodConfig struct {
	// swagger:ignore
	RequestMethodConfigurator
	// contains filtered or unexported fields
}

swagger:type recoveryRequestConfigPayload

func (*RequestMethodConfig) MarshalJSON

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

func (*RequestMethodConfig) Scan

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

func (*RequestMethodConfig) UnmarshalJSON

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

func (*RequestMethodConfig) Value

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

type RequestMethods

type RequestMethods map[string]*RequestMethod

func (RequestMethods) TableName

func (u RequestMethods) TableName() string

type RequestMethodsRaw

type RequestMethodsRaw []RequestMethod // workaround for https://github.com/gobuffalo/pop/pull/478

func (RequestMethodsRaw) TableName

func (u RequestMethodsRaw) TableName() string

type RequestPersistenceProvider

type RequestPersistenceProvider interface {
	RecoveryRequestPersister() RequestPersister
}

type RequestPersister

type RequestPersister interface {
	CreateRecoveryRequest(context.Context, *Request) error
	GetRecoveryRequest(ctx context.Context, id uuid.UUID) (*Request, error)
	UpdateRecoveryRequest(context.Context, *Request) error
}

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

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

func (Strategies) Strategy

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

type Strategy

type Strategy interface {
	RecoveryStrategyID() string
	RegisterRecoveryRoutes(*x.RouterPublic)
	PopulateRecoveryMethod(*http.Request, *Request) error
}

type StrategyProvider

type StrategyProvider interface {
	RecoveryStrategies() Strategies
}

Jump to

Keyboard shortcuts

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