viewmodels

package
v0.0.0-...-81dc835 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PreviewDummyPhoneNumberMasked = "PHONE NUMBER"
	PreviewDummyEmailMasked       = "johndoe*******@example.com"
)

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
	BotProtectionRequired 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
	LoginIDDefaultValue  string
	LoginIDInputReadOnly bool
	AlternativesDisabled bool

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

	PhoneLoginIDBotProtectionRequired    bool
	EmailLoginIDBotProtectionRequired    bool
	UsernameLoginIDBotProtectionRequired bool
	PasskeyBotProtectionRequired         bool
	OAuthBotProtectionRequired           bool
}

type AuthflowViewModeler

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

func (*AuthflowViewModeler) NewWithAccountRecoveryAuthflow

func (m *AuthflowViewModeler) NewWithAccountRecoveryAuthflow(f *authflow.FlowResponse, r *http.Request) AuthflowViewModel

func (*AuthflowViewModeler) NewWithAuthflow

nolint: gocognit

func (*AuthflowViewModeler) NewWithConfig

func (m *AuthflowViewModeler) NewWithConfig() AuthflowViewModel

nolint: gocognit

type BaseLogger

type BaseLogger struct{ *log.Logger }

func NewBaseLogger

func NewBaseLogger(lf *log.Factory) BaseLogger

type BaseViewModel

type BaseViewModel struct {
	RequestURI                  string
	HasXStep                    bool
	ColorScheme                 string
	CSPNonce                    string
	CSRFField                   htmltemplate.HTML
	Translations                TranslationsCompat
	HasAppSpecificAsset         func(id string) bool
	StaticAssetURL              func(id string) (url string)
	GeneratedStaticAssetURL     func(id string) (url string)
	DarkThemeEnabled            bool
	LightThemeEnabled           bool
	WatermarkEnabled            bool
	AllowedPhoneCountryCodeJSON string
	PinnedPhoneCountryCodeJSON  string
	GeoIPCountryCode            string
	FormJSON                    string
	BrandPageURI                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
	MakeURLWithBackURL    func(path string, pairs ...string) string
	MakeBackURL           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
	AuthUIWindowMessageAllowedOrigins string

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

	InlinePreview bool

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

	BotProtectionEnabled          bool
	BotProtectionProviderType     string
	BotProtectionProviderSiteKey  string
	ResolvedBotProtectionLanguage 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
	BotProtection                     *config.BotProtectionConfig
	ErrorService                      ErrorService
	Translations                      TranslationService
	Clock                             clock.Clock
	FlashMessage                      FlashMessage
	DefaultLanguageTag                template.DefaultLanguageTag
	SupportedLanguageTags             template.SupportedLanguageTags
	AuthUISentryDSN                   config.AuthUISentryDSN
	AuthUIWindowMessageAllowedOrigins config.AuthUIWindowMessageAllowedOrigins
	OAuthClientResolver               WebappOAuthClientResolver
	Logger                            BaseLogger
}

func (*BaseViewModeler) ViewModel

nolint: gocognit

func (*BaseViewModeler) ViewModelForAuthFlow

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

func (*BaseViewModeler) ViewModelForInlinePreviewAuthFlow

func (m *BaseViewModeler) ViewModelForInlinePreviewAuthFlow(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 ErrorService

type ErrorService interface {
	PopError(ctx context.Context, w http.ResponseWriter, r *http.Request) (*webapp.ErrorState, bool)
}

type FlashMessage

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

type IdentityCandidatesGetter

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

type InlinePreviewAuthflowBranchViewModeler

type InlinePreviewAuthflowBranchViewModeler struct {
	AppConfig *config.AppConfig
}

func (*InlinePreviewAuthflowBranchViewModeler) NewAuthflowBranchViewModelForInlinePreviewCreatePassword

func (m *InlinePreviewAuthflowBranchViewModeler) NewAuthflowBranchViewModelForInlinePreviewCreatePassword() AuthflowBranchViewModel

func (*InlinePreviewAuthflowBranchViewModeler) NewAuthflowBranchViewModelForInlinePreviewEnterOOBOTP

func (m *InlinePreviewAuthflowBranchViewModeler) NewAuthflowBranchViewModelForInlinePreviewEnterOOBOTP() AuthflowBranchViewModel

func (*InlinePreviewAuthflowBranchViewModeler) NewAuthflowBranchViewModelForInlinePreviewEnterPassword

func (m *InlinePreviewAuthflowBranchViewModeler) NewAuthflowBranchViewModelForInlinePreviewEnterPassword() AuthflowBranchViewModel

func (*InlinePreviewAuthflowBranchViewModeler) NewAuthflowBranchViewModelForInlinePreviewEnterTOTP

func (m *InlinePreviewAuthflowBranchViewModeler) NewAuthflowBranchViewModelForInlinePreviewEnterTOTP() AuthflowBranchViewModel
func (m *InlinePreviewAuthflowBranchViewModeler) NewAuthflowBranchViewModelForInlinePreviewOOBOTPLink() AuthflowBranchViewModel

func (*InlinePreviewAuthflowBranchViewModeler) NewAuthflowBranchViewModelForInlinePreviewUsePasskey

func (m *InlinePreviewAuthflowBranchViewModeler) NewAuthflowBranchViewModelForInlinePreviewUsePasskey() AuthflowBranchViewModel

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(ctx context.Context, userID string, filters ...authenticator.Filter) ([]*authenticator.Info, error)
}

type SettingsIdentityService

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

type SettingsMFAService

type SettingsMFAService interface {
	CountDeviceTokens(ctx context.Context, userID string) (int, error)
	ListRecoveryCodes(ctx context.Context, userID string) ([]*mfa.RecoveryCode, error)
}

type SettingsProfileIdentityService

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

type SettingsProfileUserService

type SettingsProfileUserService interface {
	Get(ctx context.Context, 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

	EmailIdentityIDs    []string
	UsernameIdentityIDs []string
	PhoneIdentityIDs    []string
}

type SettingsProfileViewModeler

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

func (*SettingsProfileViewModeler) ViewModel

nolint: gocognit

type SettingsUserService

type SettingsUserService interface {
	Get(ctx context.Context, userID string, role accesscontrol.Role) (*model.User, error)
}

type SettingsViewModel

type SettingsViewModel struct {
	Zoneinfo string

	Authenticators           []*authenticator.Info
	NumberOfDeviceTokens     int
	HasDeviceTokens          bool
	ListRecoveryCodesAllowed bool
	HasRecoveryCodes         bool
	ShowBiometric            bool

	HasSecondaryTOTP        bool
	HasSecondaryOOBOTPEmail bool
	HasSecondaryOOBOTPSMS   bool
	OOBOTPSMSDefaultChannel string
	SecondaryPassword       *authenticator.Info
	HasMFA                  bool
	PhoneOTPMode            string

	ShowSecondaryTOTP        bool
	ShowSecondaryOOBOTPEmail bool
	ShowSecondaryOOBOTPSMS   bool
	ShowSecondaryPassword    bool
	ShowMFA                  bool

	LatestPrimaryPasskey *authenticator.Info
	ShowPrimaryPasskey   bool
}

type SettingsViewModeler

type SettingsViewModeler struct {
	Clock               clock.Clock
	Users               SettingsUserService
	Authenticators      SettingsAuthenticatorService
	MFA                 SettingsMFAService
	AuthenticatorConfig *config.AuthenticatorConfig
	Authentication      *config.AuthenticationConfig
	Biometric           *config.BiometricConfig
}

func (*SettingsViewModeler) ViewModel

func (m *SettingsViewModeler) ViewModel(ctx context.Context, userID string) (*SettingsViewModel, error)

nolint: gocognit

type StaticAssetResolver

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

type TranslationService

type TranslationService interface {
	HasKey(ctx context.Context, key string) (bool, error)
	RenderText(ctx context.Context, key string, args interface{}) (string, error)
}

type TranslationsCompat

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

type TranslationsCompatImpl

type TranslationsCompatImpl struct {
	Context            context.Context // This context is intentionally contained in a struct.
	TranslationService TranslationService
}

func (*TranslationsCompatImpl) HasKey

func (t *TranslationsCompatImpl) HasKey(key string) (bool, error)

func (*TranslationsCompatImpl) RenderText

func (t *TranslationsCompatImpl) 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