registration

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

Documentation

Index

Constants

View Source
const (
	RouteInitBrowserFlow = "/self-service/registration/browser"
	RouteInitAPIFlow     = "/self-service/registration/api"

	RouteGetFlow = "/self-service/registration/flows"
)

Variables

View Source
var (
	ErrHookAbortFlow   = errors.New("aborted registration hook execution")
	ErrAlreadyLoggedIn = herodot.ErrBadRequest.WithReason("A valid session was detected and thus registration is not possible.")
)

Functions

func PostHookPostPersistExecutorNames

func PostHookPostPersistExecutorNames(e []PostHookPostPersistExecutor) []string

func TestFlowPersister

func TestFlowPersister(p FlowPersister) func(t *testing.T)

Types

type APIFlowResponse

type APIFlowResponse struct {
	// The Session Token
	//
	// This field is only set when the session hook is configured as a post-registration hook.
	//
	// A session token is equivalent to a session cookie, but it can be sent in the HTTP Authorization
	// Header:
	//
	// 		Authorization: bearer ${session-token}
	//
	// The session token is only issued for API flows, not for Browser flows!
	//
	// required: true
	Token string `json:"session_token,omitempty"`

	// The Session
	//
	// This field is only set when the session hook is configured as a post-registration hook.
	//
	// The session contains information about the user, the session device, and so on.
	// This is only available for API flows, not for Browser flows!
	Session *session.Session `json:"session,omitempty"`

	// The Identity
	//
	// The identity that just signed up.
	//
	// required: true
	Identity *identity.Identity `json:"identity"`
}

The Response for Registration Flows via API

swagger:model registrationViaApiResponse

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,
	ct identity.CredentialsType,
	f *Flow,
	err error,
)

type ErrorHandlerProvider

type ErrorHandlerProvider interface{ RegistrationFlowErrorHandler() *ErrorHandler }

type Flow

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

	// 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 log in,
	// 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" faker:"url" db:"request_url"`

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

	// Messages contains a list of messages to be displayed in the Registration 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 registration flow has been
	// processed, but for example the password is incorrect, this will contain error messages.
	//
	// required: true
	Methods map[identity.CredentialsType]*FlowMethod `json:"methods" faker:"registration_flow_methods" db:"-"`

	// MethodsRaw is a helper struct field for gobuffalo.pop.
	MethodsRaw FlowMethodsRaw `json:"-" faker:"-" has_many:"selfservice_registration_flow_methods" fk_id:"selfservice_registration_flow_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"`

	// CSRFToken contains the anti-csrf token associated with this flow. Only set for browser flows.
	CSRFToken string `json:"-" db:"csrf_token"`
}

swagger:model registrationFlow

func NewFlow

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

func (*Flow) AfterCreate

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

func (*Flow) AfterFind

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

func (*Flow) AfterUpdate

func (f *Flow) AfterUpdate(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) GetID

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

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 flow method's credentials type.
	//
	// required: true
	Method identity.CredentialsType `json:"method" faker:"string" 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:"-" faker:"-" db:"id"`

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

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

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

swagger:model registrationFlowMethod

func (FlowMethod) TableName

func (u FlowMethod) TableName() string

type FlowMethodConfig

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

swagger:model registrationFlowMethodConfig

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[identity.CredentialsType]*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 {
	RegistrationFlowPersister() FlowPersister
}

type FlowPersister

type FlowPersister interface {
	UpdateRegistrationFlow(context.Context, *Flow) error
	CreateRegistrationFlow(context.Context, *Flow) error
	GetRegistrationFlow(context.Context, uuid.UUID) (*Flow, error)
	UpdateRegistrationFlowMethod(context.Context, uuid.UUID, identity.CredentialsType, *FlowMethod) error
}

type Handler

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

func NewHandler

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

func (*Handler) NewRegistrationFlow

func (h *Handler) NewRegistrationFlow(w http.ResponseWriter, r *http.Request, 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 {
	RegistrationHandler() *Handler
}

type HookExecutor

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

func NewHookExecutor

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

func (*HookExecutor) PostRegistrationHook

func (e *HookExecutor) PostRegistrationHook(w http.ResponseWriter, r *http.Request, ct identity.CredentialsType, a *Flow, i *identity.Identity) error

func (*HookExecutor) PreRegistrationHook

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

type HookExecutorProvider

type HookExecutorProvider interface {
	RegistrationExecutor() *HookExecutor
}

type HooksProvider

type HooksProvider interface {
	PreRegistrationHooks() []PreHookExecutor
	PostRegistrationPrePersistHooks(credentialsType identity.CredentialsType) []PostHookPrePersistExecutor
	PostRegistrationPostPersistHooks(credentialsType identity.CredentialsType) []PostHookPostPersistExecutor
}

type PostHookPostPersistExecutor

type PostHookPostPersistExecutor interface {
	ExecutePostRegistrationPostPersistHook(w http.ResponseWriter, r *http.Request, a *Flow, s *session.Session) error
}

type PostHookPostPersistExecutorFunc

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

func (PostHookPostPersistExecutorFunc) ExecutePostRegistrationPostPersistHook

func (f PostHookPostPersistExecutorFunc) ExecutePostRegistrationPostPersistHook(w http.ResponseWriter, r *http.Request, a *Flow, s *session.Session) error

type PostHookPrePersistExecutor

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

type PostHookPrePersistExecutorFunc

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

func (PostHookPrePersistExecutorFunc) ExecutePostRegistrationPrePersistHook

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

type PreHookExecutor

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

type PreHookExecutorFunc

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

func (PreHookExecutorFunc) ExecuteRegistrationPreHook

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

type Strategies

type Strategies []Strategy

func (Strategies) MustStrategy

func (s Strategies) MustStrategy(id identity.CredentialsType) Strategy

func (Strategies) RegisterPublicRoutes

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

func (Strategies) Strategy

func (s Strategies) Strategy(id identity.CredentialsType) (Strategy, error)

type Strategy

type Strategy interface {
	ID() identity.CredentialsType
	RegisterRegistrationRoutes(*x.RouterPublic)
	PopulateRegistrationMethod(r *http.Request, sr *Flow) error
}

type StrategyProvider

type StrategyProvider interface {
	RegistrationStrategies() Strategies
}

Jump to

Keyboard shortcuts

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