viewmodels

package
v0.0.0-...-c4f7e29 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func Embed

func Embed(data map[string]interface{}, s interface{})

func SliceContains

func SliceContains(slice []interface{}, value interface{}) bool

Types

type AlternativeStep

type AlternativeStep struct {
	Step  webapp.SessionStepKind
	Input map[string]string
	Data  map[string]string
}

type AlternativeStepsViewModel

type AlternativeStepsViewModel struct {
	AuthenticationStage   string
	AlternativeSteps      []AlternativeStep
	CanRequestDeviceToken bool
}

type AlternativeStepsViewModeler

type AlternativeStepsViewModeler struct {
	AuthenticationConfig *config.AuthenticationConfig
}

func (*AlternativeStepsViewModeler) AuthenticationAlternatives

func (a *AlternativeStepsViewModeler) AuthenticationAlternatives(graph *interaction.Graph, currentStepKind webapp.SessionStepKind) (*AlternativeStepsViewModel, error)

nolint: gocognit

func (*AlternativeStepsViewModeler) CreateAuthenticatorAlternatives

func (a *AlternativeStepsViewModeler) CreateAuthenticatorAlternatives(graph *interaction.Graph, currentStepKind webapp.SessionStepKind) (*AlternativeStepsViewModel, error)

nolint: gocognit

type AuthenticationBeginNode

type AuthenticationBeginNode interface {
	GetAuthenticationEdges() ([]interaction.Edge, error)
	GetAuthenticationStage() authn.AuthenticationStage
}

type AuthenticationPhoneOTPTriggerNode

type AuthenticationPhoneOTPTriggerNode interface {
	GetSelectedPhoneNumberForPhoneOTPAuthentication() string
}

type AuthenticationViewModel

type AuthenticationViewModel struct {
	IdentityCandidates     []identity.Candidate
	IdentityCount          int
	LoginIDDisabled        bool
	PhoneLoginIDEnabled    bool
	EmailLoginIDEnabled    bool
	UsernameLoginIDEnabled bool
	PasskeyEnabled         bool

	// NonPhoneLoginIDInputType is the "type" attribute for the non-phone <input>.
	// It is "email" or "text".
	NonPhoneLoginIDInputType string

	// NonPhoneLoginIDType is the type of non-phone login ID.
	// It is "email", "username" or "email_or_username".
	NonPhoneLoginIDType string

	// LoginIDContextualType is the type the end-user thinks they should enter.
	// It depends on q_login_id_input_type.
	// It is "email", "phone", "username", or "email_or_username".
	LoginIDContextualType string

	PasskeyRequestOptionsJSON string
}

type AuthenticationViewModeler

type AuthenticationViewModeler struct {
	Authentication *config.AuthenticationConfig
	LoginID        *config.LoginIDConfig
}

func (*AuthenticationViewModeler) NewWithCandidates

func (m *AuthenticationViewModeler) NewWithCandidates(candidates []identity.Candidate, form url.Values) AuthenticationViewModel

func (*AuthenticationViewModeler) NewWithGraph

type AuthflowBranch

type AuthflowBranch struct {
	Authentication        config.AuthenticationFlowAuthentication
	Index                 int
	Channel               model.AuthenticatorOOBChannel
	MaskedClaimValue      string
	OTPForm               otp.Form
	VerificationSkippable bool
}

type AuthflowBranchFilter

type AuthflowBranchFilter func([]AuthflowBranch) []AuthflowBranch

type AuthflowBranchViewModel

type AuthflowBranchViewModel struct {
	// FlowType is mainly for pages to tell if the flow is reauthentication or not.
	FlowType           authflow.FlowType
	ActionType         authflow.FlowActionType
	DeviceTokenEnabled bool
	Branches           []AuthflowBranch
}

type AuthflowViewModel

type AuthflowViewModel struct {
	IdentityCandidates []map[string]interface{}

	LoginIDDisabled        bool
	PhoneLoginIDEnabled    bool
	EmailLoginIDEnabled    bool
	UsernameLoginIDEnabled bool
	PasskeyEnabled         bool

	// NonPhoneLoginIDInputType is the "type" attribute for the non-phone <input>.
	// It is "email" or "text".
	NonPhoneLoginIDInputType string

	// NonPhoneLoginIDType is the type of non-phone login ID.
	// It is "email", "username" or "email_or_username".
	NonPhoneLoginIDType string

	// LoginIDKey is the key the end-user has chosen.
	// It is "email", "phone", or "username".
	LoginIDKey string

	// LoginIDInputType is the input the end-user has chosen.
	// It is "email", "phone" or "text".
	LoginIDInputType string

	// LoginIDContextualType is the type the end-user thinks they should enter.
	// It depends on LoginIDInputType.
	// It is "email", "phone", "username", or "email_or_username".
	LoginIDContextualType string

	PasskeyRequestOptionsJSON string
}

type AuthflowViewModeler

type AuthflowViewModeler struct {
	Authentication *config.AuthenticationConfig
	LoginID        *config.LoginIDConfig
}

func (*AuthflowViewModeler) NewWithAuthflow

nolint: gocognit

type BaseLogger

type BaseLogger struct{ *log.Logger }

func NewBaseLogger

func NewBaseLogger(lf *log.Factory) BaseLogger

type BaseViewModel

type BaseViewModel struct {
	RequestURI                  string
	ColorScheme                 string
	CSPNonce                    string
	CSRFField                   htmltemplate.HTML
	Translations                TranslationService
	HasAppSpecificAsset         func(id string) bool
	StaticAssetURL              func(id string) (url string)
	GeneratedStaticAssetURL     func(id string) (url string)
	DarkThemeEnabled            bool
	WatermarkEnabled            bool
	AllowedPhoneCountryCodeJSON string
	PinnedPhoneCountryCodeJSON  string
	GeoIPCountryCode            string
	FormJSON                    string
	// ClientURI is the home page of the client.
	ClientURI             string
	ClientName            string
	SliceContains         func([]interface{}, interface{}) bool
	MakeURL               func(path string, pairs ...string) string
	MakeCurrentStepURL    func(pairs ...string) string
	RawError              *apierrors.APIError
	Error                 interface{}
	SessionStepURLs       []string
	ForgotPasswordEnabled bool
	PublicSignupDisabled  bool
	PageLoadedAt          int
	IsNativePlatform      bool
	FlashMessageType      string
	ResolvedLanguageTag   string
	ResolvedCLDRLocale    string
	HTMLDir               string
	// IsSupportedMobilePlatform is true when the user agent is iOS or Android.
	IsSupportedMobilePlatform   bool
	GoogleTagManagerContainerID string
	TutorialMessageType         string
	// HasThirdPartyApp indicates whether the project has third-party client
	HasThirdPartyClient bool
	AuthUISentryDSN     string

	FirstNonPasskeyPrimaryAuthenticatorType string
	// websocket is used in interaction only, we disable it in authflow
	WebsocketDisabled bool

	ShouldFocusInput bool
	LogUnknownError  func(err map[string]interface{}) string
}

BaseViewModel contains data that are common to all pages.

func (*BaseViewModel) SetError

func (m *BaseViewModel) SetError(err error)

func (*BaseViewModel) SetFormJSON

func (m *BaseViewModel) SetFormJSON(form url.Values)

func (*BaseViewModel) SetTutorial

func (m *BaseViewModel) SetTutorial(name httputil.TutorialCookieName)

type BaseViewModeler

type BaseViewModeler struct {
	TrustProxy            config.TrustProxy
	OAuth                 *config.OAuthConfig
	AuthUI                *config.UIConfig
	AuthUIFeatureConfig   *config.UIFeatureConfig
	StaticAssets          StaticAssetResolver
	ForgotPassword        *config.ForgotPasswordConfig
	Authentication        *config.AuthenticationConfig
	GoogleTagManager      *config.GoogleTagManagerConfig
	ErrorCookie           ErrorCookie
	Translations          TranslationService
	Clock                 clock.Clock
	FlashMessage          FlashMessage
	DefaultLanguageTag    template.DefaultLanguageTag
	SupportedLanguageTags template.SupportedLanguageTags
	AuthUISentryDSN       config.AuthUISentryDSN
	OAuthClientResolver   WebappOAuthClientResolver
	Logger                BaseLogger
}

func (*BaseViewModeler) ViewModel

nolint: gocognit

func (*BaseViewModeler) ViewModelForAuthFlow

func (m *BaseViewModeler) ViewModelForAuthFlow(r *http.Request, rw http.ResponseWriter) BaseViewModel

type ChangePasswordGetter

type ChangePasswordGetter interface {
	GetChangeReason() *interaction.AuthenticatorUpdateReason
}

type ChangePasswordViewModel

type ChangePasswordViewModel struct {
	Force  bool
	Reason string
}

type ChangePasswordViewModeler

type ChangePasswordViewModeler struct {
	Authentication *config.AuthenticationConfig
	LoginID        *config.LoginIDConfig
}

func (*ChangePasswordViewModeler) NewWithAuthflow

func (*ChangePasswordViewModeler) NewWithGraph

type CreateAuthenticatorBeginNode

type CreateAuthenticatorBeginNode interface {
	GetCreateAuthenticatorEdges() ([]interaction.Edge, error)
	GetCreateAuthenticatorStage() authn.AuthenticationStage
}

type CustomAttribute

type CustomAttribute struct {
	Value          interface{}
	Label          string
	EnumValueLabel string
	Pointer        string
	Type           string
	IsEditable     bool
	Minimum        *float64
	Maximum        *float64
	Enum           []CustomAttributeEnum
}

type CustomAttributeEnum

type CustomAttributeEnum struct {
	Value string
	Label string
}

type EnsureVerificationBeginNode

type EnsureVerificationBeginNode interface {
	GetVerifyIdentityEdges() ([]interaction.Edge, error)
}

type ErrorCookie

type ErrorCookie interface {
	GetError(r *http.Request) (*webapp.ErrorState, bool)
	ResetRecoverableError() *http.Cookie
}

type FlashMessage

type FlashMessage interface {
	Pop(r *http.Request, rw http.ResponseWriter) string
}

type IdentityCandidatesGetter

type IdentityCandidatesGetter interface {
	GetIdentityCandidates() []identity.Candidate
}

type LoginLinkTriggerNode

type LoginLinkTriggerNode interface {
	GetLoginLinkOTPTarget() string
}

type OOBOTPTriggerNode

type OOBOTPTriggerNode interface {
	GetOOBOTPTarget() string
}

type PasswordPolicyViewModel

type PasswordPolicyViewModel struct {
	PasswordPolicies    []password.Policy
	IsNew               bool
	PasswordRulesString string
}

func NewPasswordPolicyViewModel

func NewPasswordPolicyViewModel(policies []password.Policy, rules string, apiError *apierrors.APIError, opt *PasswordPolicyViewModelOptions) PasswordPolicyViewModel

nolint: gocognit

type PasswordPolicyViewModelOptions

type PasswordPolicyViewModelOptions struct {
	IsNew bool
}

func GetDefaultPasswordPolicyViewModelOptions

func GetDefaultPasswordPolicyViewModelOptions() *PasswordPolicyViewModelOptions

type PhoneOTPAlternativeStepsViewModel

type PhoneOTPAlternativeStepsViewModel struct {
	PhoneOTPAlternativeSteps []AlternativeStep
}

func (*PhoneOTPAlternativeStepsViewModel) AddAlternatives

func (m *PhoneOTPAlternativeStepsViewModel) AddAlternatives(graph *interaction.Graph, currentStepKind webapp.SessionStepKind) error

type SettingsAuthenticatorService

type SettingsAuthenticatorService interface {
	List(userID string, filters ...authenticator.Filter) ([]*authenticator.Info, error)
}

type SettingsIdentityService

type SettingsIdentityService interface {
	ListByUser(userID string) ([]*identity.Info, error)
}

type SettingsMFAService

type SettingsMFAService interface {
	HasDeviceTokens(userID string) (bool, error)
}

type SettingsProfileIdentityService

type SettingsProfileIdentityService interface {
	ListByUser(userID string) ([]*identity.Info, error)
}

type SettingsProfileUserService

type SettingsProfileUserService interface {
	Get(userID string, role accesscontrol.Role) (*model.User, error)
}

type SettingsProfileViewModel

type SettingsProfileViewModel struct {
	FormattedName    string
	EndUserAccountID string
	FormattedNames   string
	Today            string

	Timezones          []tzutil.Timezone
	Alpha2             []string
	Languages          []string
	Emails             []string
	PhoneNumbers       []string
	PreferredUsernames []string

	IsReadable                    func(jsonpointer string) bool
	IsEditable                    func(jsonpointer string) bool
	GetCustomAttributeByPointer   func(jsonpointer string) *CustomAttribute
	IsStandardAttributesAllHidden bool

	Name                 string
	GivenName            string
	FamilyName           string
	MiddleName           string
	Nickname             string
	Picture              string
	Profile              string
	Website              string
	Email                string
	PhoneNumber          string
	PreferredUsername    string
	Gender               string
	Birthdate            string
	Zoneinfo             string
	ZoneinfoTimezone     *tzutil.Timezone
	Locale               string
	AddressStreetAddress string
	AddressLocality      string
	AddressRegion        string
	AddressPostalCode    string
	AddressCountry       string

	CustomAttributes []CustomAttribute
}

type SettingsProfileViewModeler

type SettingsProfileViewModeler struct {
	Localization      *config.LocalizationConfig
	UserProfileConfig *config.UserProfileConfig
	Users             SettingsProfileUserService
	Identities        SettingsProfileIdentityService
	Clock             clock.Clock
}

func (*SettingsProfileViewModeler) ViewModel

nolint: gocognit

type SettingsViewModel

type SettingsViewModel struct {
	Authenticators           []*authenticator.Info
	HasDeviceTokens          bool
	ListRecoveryCodesAllowed bool
	ShowBiometric            bool

	HasSecondaryTOTP        bool
	HasSecondaryOOBOTPEmail bool
	HasSecondaryOOBOTPSMS   bool
	SecondaryPassword       *authenticator.Info
	HasMFA                  bool

	ShowSecondaryTOTP        bool
	ShowSecondaryOOBOTPEmail bool
	ShowSecondaryOOBOTPSMS   bool
	ShowSecondaryPassword    bool
	ShowMFA                  bool

	LatestPrimaryPasskey *authenticator.Info
	ShowPrimaryPasskey   bool
}

type SettingsViewModeler

type SettingsViewModeler struct {
	Authenticators SettingsAuthenticatorService
	MFA            SettingsMFAService
	Authentication *config.AuthenticationConfig
	Biometric      *config.BiometricConfig
}

func (*SettingsViewModeler) ViewModel

func (m *SettingsViewModeler) ViewModel(userID string) (*SettingsViewModel, error)

nolint: gocognit

type StaticAssetResolver

type StaticAssetResolver interface {
	HasAppSpecificAsset(id string) bool
	StaticAssetURL(id string) (url string, err error)
	GeneratedStaticAssetURL(id string) (url string, err error)
}

type TranslationService

type TranslationService interface {
	HasKey(key string) (bool, error)
	RenderText(key string, args interface{}) (string, error)
}

type WebappOAuthClientResolver

type WebappOAuthClientResolver interface {
	ResolveClient(clientID string) *config.OAuthClientConfig
}

type WhatsappOTPTriggerNode

type WhatsappOTPTriggerNode interface {
	GetPhone() string
}

Jump to

Keyboard shortcuts

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