settings

package
v0.11.0-alpha.0.pre.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

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

	RouteSubmitFlow = "/self-service/settings"

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

Variables

View Source
var (
	ErrContinuePreviousAction = errors.New("found prior action")
)
View Source
var (
	ErrHookAbortFlow = 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(reg interface {
	config.Provider
	x.WriterProvider
}) func(http.ResponseWriter, *http.Request, httprouter.Params)

func PostHookPostPersistExecutorNames

func PostHookPostPersistExecutorNames(e []PostHookPostPersistExecutor) []string

func PostHookPrePersistExecutorNames

func PostHookPrePersistExecutorNames(e []PostHookPrePersistExecutor) []string

func WithCallback

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

Types

type ErrorHandler

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

func NewErrorHandler

func NewErrorHandler(d errorHandlerDependencies) *ErrorHandler

func (*ErrorHandler) PrepareReplacementForExpiredFlow

func (s *ErrorHandler) PrepareReplacementForExpiredFlow(w http.ResponseWriter, r *http.Request, f *Flow, id *identity.Identity, err error) (*flow.ExpiredError, error)

func (*ErrorHandler) WriteFlowError

func (s *ErrorHandler) WriteFlowError(
	w http.ResponseWriter,
	r *http.Request,
	group node.UiNodeGroup,
	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.
	//
	// required: true
	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"`

	// ReturnTo contains the requested return_to URL.
	ReturnTo string `json:"return_to,omitempty" db:"-"`

	// 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"`

	// UI contains data which must be shown in the user interface.
	//
	// required: true
	UI *container.Container `json:"ui" db:"ui"`

	// Identity contains the identity's data in raw form.
	//
	// If `state` is `success` this will be the updated identity!
	//
	// 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"`

	// InternalContext stores internal context used by internals - for example MFA keys.
	InternalContext sqlxx.JSONRawMessage `db:"internal_context" json:"-" faker:"-"`

	// 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"`
	NID       uuid.UUID `json:"-"  faker:"-" db:"nid"`
}

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 selfServiceSettingsFlow

func MustNewFlow

func MustNewFlow(conf *config.Config, exp time.Duration, r *http.Request, i *identity.Identity, ft flow.Type) *Flow

func NewFlow

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

func (*Flow) AfterFind

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

func (*Flow) AfterSave

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

func (*Flow) AppendTo

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

func (*Flow) EnsureInternalContext

func (f *Flow) EnsureInternalContext()

func (Flow) GetID

func (f Flow) GetID() uuid.UUID

func (Flow) GetNID

func (f Flow) GetNID() uuid.UUID

func (*Flow) GetRequestURL

func (f *Flow) GetRequestURL() string

func (*Flow) GetType

func (f *Flow) GetType() flow.Type

func (*Flow) GetUI added in v0.11.0

func (f *Flow) GetUI() *container.Container

func (Flow) MarshalJSON

func (f Flow) MarshalJSON() ([]byte, error)

func (*Flow) SetReturnTo

func (f *Flow) SetReturnTo()

func (Flow) TableName

func (f Flow) TableName(ctx context.Context) string

func (*Flow) Valid

func (f *Flow) Valid(s *session.Session) error

type FlowNeedsReAuth

type FlowNeedsReAuth struct {
	*herodot.DefaultError `json:"error"`

	// Points to where to redirect the user to next.
	//
	// required: true
	RedirectBrowserTo string `json:"redirect_browser_to"`
}

Is sent when a privileged session is required to perform the settings update.

swagger:model needsPrivilegedSessionError

func NewFlowNeedsReAuth

func NewFlowNeedsReAuth() *FlowNeedsReAuth

func (*FlowNeedsReAuth) EnhanceJSONError

func (e *FlowNeedsReAuth) EnhanceJSONError() interface{}

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
	DeleteExpiredSettingsFlows(context.Context, time.Time, int) error
}

type Handler

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

func NewHandler

func NewHandler(d handlerDependencies) *Handler

func (*Handler) FromOldFlow

func (h *Handler) FromOldFlow(w http.ResponseWriter, r *http.Request, i *identity.Identity, of Flow) (*Flow, error)

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) *HookExecutor

func (*HookExecutor) PostSettingsHook

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

func (*HookExecutor) PreSettingsHook added in v0.11.0

func (e *HookExecutor) PreSettingsHook(w http.ResponseWriter, r *http.Request, a *Flow) error

type HookExecutorProvider

type HookExecutorProvider interface {
	SettingsHookExecutor() *HookExecutor
}

type HooksProvider

type HooksProvider interface {
	PreSettingsHooks(ctx context.Context) []PreHookExecutor
	PostSettingsPrePersistHooks(ctx context.Context, settingsType string) []PostHookPrePersistExecutor
	PostSettingsPostPersistHooks(ctx context.Context, 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 PreHookExecutor added in v0.11.0

type PreHookExecutor interface {
	ExecuteSettingsPreHook(w http.ResponseWriter, r *http.Request, a *Flow) error
}

type PreHookExecutorFunc added in v0.11.0

type PreHookExecutorFunc func(w http.ResponseWriter, r *http.Request, a *Flow) error

func (PreHookExecutorFunc) ExecuteSettingsPreHook added in v0.11.0

func (f PreHookExecutorFunc) ExecuteSettingsPreHook(w http.ResponseWriter, r *http.Request, a *Flow) error

type State

type State string

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.

swagger:model selfServiceSettingsFlowState

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
	NodeGroup() node.UiNodeGroup
	RegisterSettingsRoutes(*x.RouterPublic)
	PopulateSettingsMethod(*http.Request, *identity.Identity, *Flow) error
	Settings(w http.ResponseWriter, r *http.Request, f *Flow, s *session.Session) (*UpdateContext, error)
}

type StrategyProvider

type StrategyProvider interface {
	SettingsStrategies(ctx context.Context) Strategies
	AllSettingsStrategies() Strategies
}

type UpdateContext

type UpdateContext struct {
	Session *session.Session
	Flow    *Flow
	// contains filtered or unexported fields
}

func (*UpdateContext) GetIdentityToUpdate

func (c *UpdateContext) GetIdentityToUpdate() (*identity.Identity, error)

func (UpdateContext) GetSessionIdentity

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

func (*UpdateContext) UpdateIdentity

func (c *UpdateContext) UpdateIdentity(i *identity.Identity)

type UpdatePayload

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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