settings

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: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouteInitBrowserFlow = "/self-service/settings/browser"
	RouteInitAPIFlow     = "/self-service/settings/api"
	RouteGetFlow         = "/self-service/settings/flows"

	ContinuityPrefix = "ory_kratos_settings"
)
View Source
const (
	StrategyProfile = "profile"
)

Variables

View Source
var (
	ErrContinuePreviousAction = errors.New("found prior action")
)
View Source
var (
	ErrHookAbortRequest = errors.New("aborted settings hook execution")
)

Functions

func ContinuityKey

func ContinuityKey(id string) string

func ContinuityOptions

func ContinuityOptions(p interface{}, i *identity.Identity) []continuity.ManagerOption

func GetFlowID

func GetFlowID(r *http.Request) (uuid.UUID, error)

func OnUnauthenticated

func OnUnauthenticated(c configuration.Provider, reg interface {
	x.WriterProvider
}) func(http.ResponseWriter, *http.Request, httprouter.Params)

func PostHookPostPersistExecutorNames

func PostHookPostPersistExecutorNames(e []PostHookPostPersistExecutor) []string

func PostHookPrePersistExecutorNames

func PostHookPrePersistExecutorNames(e []PostHookPrePersistExecutor) []string

func TestRequestPersister

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

func WithCallback

func WithCallback(cb func(ctxUpdate *UpdateContext) error) func(o *postSettingsHookOptions)

Types

type APIFlowResponse

type APIFlowResponse struct {
	// The Flow
	//
	// required: true
	Flow *Flow `json:"flow"`

	// The Identity
	//
	// The updated identity
	//
	// required: true
	Identity *identity.Identity `json:"identity"`
}

The Response for Settings Flows via API

swagger:model settingsViaApiResponse

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,
	method string,
	f *Flow,
	id *identity.Identity,
	err error,
)

type ErrorHandlerProvider

type ErrorHandlerProvider interface{ SettingsFlowErrorHandler() *ErrorHandler }

type Flow

type Flow struct {
	// ID represents the flow's unique ID. When performing the settings flow, this
	// represents the id in the settings ui's query parameter: http://<selfservice.flows.settings.ui_url>?flow=<id>
	//
	// required: true
	// 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 flow expires. If the user still wishes to update the setting,
	// a new flow 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 flow 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" db:"active_method"`

	// Messages contains a list of messages to be displayed in the Settings 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" db:"messages" faker:"-"`

	// Methods contains context for all enabled registration methods. If a settings flow has been
	// processed, but for example the first name is empty, this will contain error messages.
	//
	// required: true
	Methods map[string]*FlowMethod `json:"methods" faker:"settings_flow_methods" db:"-"`

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

	// Identity contains all of the identity's data in raw form.
	//
	// required: true
	Identity *identity.Identity `json:"identity" faker:"identity" db:"-" belongs_to:"identities" fk_id:"IdentityID"`

	// State represents the state of this flow. It knows two states:
	//
	// - show_form: No user data has been collected, or it is invalid, and thus the form should be shown.
	// - success: Indicates that the settings flow has been updated successfully with the provided data.
	//	   Done will stay true when repeatedly checking. If set to true, done will revert back to false only
	//	   when a flow with invalid (e.g. "please use a valid phone number") data was sent.
	//
	// required: true
	State State `json:"state" faker:"-" db:"state"`

	// IdentityID is a helper struct field for gobuffalo.pop.
	IdentityID uuid.UUID `json:"-" faker:"-" db:"identity_id"`
	// 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"`
}

Flow represents a Settings Flow

This flow is used when an identity wants to update settings (e.g. profile data, passwords, ...) in a selfservice manner.

We recommend reading the [User Settings Documentation](../self-service/flows/user-settings)

swagger:model settingsFlow

func NewFlow

func NewFlow(exp time.Duration, r *http.Request, i *identity.Identity, ft flow.Type) *Flow

func (*Flow) AfterFind

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

func (*Flow) AfterSave

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

func (*Flow) AppendTo

func (r *Flow) AppendTo(settingsURL *url.URL) *url.URL

func (*Flow) BeforeSave

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

func (*Flow) GetID

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

func (Flow) TableName

func (r Flow) TableName() string

func (*Flow) Valid

func (r *Flow) Valid(s *session.Session) 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 is the name of this flow method.
	//
	// 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_settings_flow_id"`

	// Flow is a helper struct field for gobuffalo.pop.
	Flow *Flow `json:"-" belongs_to:"selfservice_settings_flow" 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 settingsFlowMethod

func (FlowMethod) TableName

func (u FlowMethod) TableName() string

type FlowMethodConfig

type FlowMethodConfig struct {
	// swagger:ignore
	FlowMethodConfigurator
	// contains filtered or unexported fields
}

swagger:type settingsFlowMethodConfig

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 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 FlowNeedsReAuth

type FlowNeedsReAuth struct {
	*herodot.DefaultError
}

func NewFlowNeedsReAuth

func NewFlowNeedsReAuth() *FlowNeedsReAuth

type FlowPersistenceProvider

type FlowPersistenceProvider interface {
	SettingsFlowPersister() FlowPersister
}

type FlowPersister

type FlowPersister interface {
	CreateSettingsFlow(context.Context, *Flow) error
	GetSettingsFlow(ctx context.Context, id uuid.UUID) (*Flow, error)
	UpdateSettingsFlow(context.Context, *Flow) error
	UpdateSettingsFlowMethod(context.Context, uuid.UUID, string, *FlowMethod) error
}

type Handler

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

func NewHandler

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

func (*Handler) NewFlow

func (h *Handler) NewFlow(w http.ResponseWriter, r *http.Request, i *identity.Identity, ft flow.Type) (*Flow, error)

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

type HookExecutor

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

func NewHookExecutor

func NewHookExecutor(
	d executorDependencies,
	c configuration.Provider,
) *HookExecutor

func (*HookExecutor) PostSettingsHook

func (e *HookExecutor) PostSettingsHook(w http.ResponseWriter, r *http.Request, settingsType string, ctxUpdate *UpdateContext, i *identity.Identity, opts ...PostSettingsHookOption) error

type HookExecutorProvider

type HookExecutorProvider interface {
	SettingsHookExecutor() *HookExecutor
}

type HooksProvider

type HooksProvider interface {
	PostSettingsPrePersistHooks(settingsType string) []PostHookPrePersistExecutor
	PostSettingsPostPersistHooks(settingsType string) []PostHookPostPersistExecutor
}

type PostHookPostPersistExecutor

type PostHookPostPersistExecutor interface {
	ExecuteSettingsPostPersistHook(w http.ResponseWriter, r *http.Request, a *Flow, s *identity.Identity) error
}

type PostHookPostPersistExecutorFunc

type PostHookPostPersistExecutorFunc func(w http.ResponseWriter, r *http.Request, a *Flow, s *identity.Identity) error

func (PostHookPostPersistExecutorFunc) ExecuteSettingsPostPersistHook

func (f PostHookPostPersistExecutorFunc) ExecuteSettingsPostPersistHook(w http.ResponseWriter, r *http.Request, a *Flow, s *identity.Identity) error

type PostHookPrePersistExecutor

type PostHookPrePersistExecutor interface {
	ExecuteSettingsPrePersistHook(w http.ResponseWriter, r *http.Request, a *Flow, s *identity.Identity) error
}

type PostHookPrePersistExecutorFunc

type PostHookPrePersistExecutorFunc func(w http.ResponseWriter, r *http.Request, a *Flow, s *identity.Identity) error

func (PostHookPrePersistExecutorFunc) ExecuteSettingsPrePersistHook

func (f PostHookPrePersistExecutorFunc) ExecuteSettingsPrePersistHook(w http.ResponseWriter, r *http.Request, a *Flow, s *identity.Identity) error

type PostSettingsHookOption

type PostSettingsHookOption func(o *postSettingsHookOptions)

type State

type State string
const (
	StateShowForm State = "show_form"
	StateSuccess  State = "success"
)

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 {
	SettingsStrategyID() string
	RegisterSettingsRoutes(*x.RouterPublic)
	PopulateSettingsMethod(*http.Request, *identity.Identity, *Flow) error
}

type StrategyProvider

type StrategyProvider interface {
	SettingsStrategies() Strategies
}

type UpdateContext

type UpdateContext struct {
	Session *session.Session
	Flow    *Flow
}

func (UpdateContext) GetSessionIdentity

func (c UpdateContext) GetSessionIdentity() *identity.Identity

type UpdatePayload

type UpdatePayload interface {
	GetFlowID() uuid.UUID
	SetFlowID(id uuid.UUID)
}

Jump to

Keyboard shortcuts

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