loginid

package
v0.0.0-...-122f59b Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmailDomainAllowListTXT = resource.RegisterResource(resource.NewlineJoinedDescriptor{
	Path: "email_domain_allowlist.txt",
	Parse: func(data []byte) (interface{}, error) {
		return matchlist.New(string(data), true, false)
	},
})
View Source
var EmailDomainBlockListTXT = resource.RegisterResource(resource.NewlineJoinedDescriptor{
	Path: "email_domain_blocklist.txt",
	Parse: func(data []byte) (interface{}, error) {
		return matchlist.New(string(data), true, false)
	},
})
View Source
var FreeEmailProviderDomainsTXT = resource.RegisterResource(resource.NewlineJoinedDescriptor{
	Path: "free_email_provider_domain_list.txt",
	Parse: func(data []byte) (interface{}, error) {
		return matchlist.New(string(data), true, false)
	},
})

FreeEmailProviderDomainsTXT is provided by https://gist.github.com/tbrianjones/5992856/93213efb652749e226e69884d6c048e595c1280a

View Source
var ReservedNameTXT = resource.RegisterResource(resource.NewlineJoinedDescriptor{
	Path: "reserved_name.txt",
	Parse: func(data []byte) (interface{}, error) {
		return blocklist.New(string(data))
	},
})
View Source
var UsernameExcludedKeywordsTXT = resource.RegisterResource(resource.NewlineJoinedDescriptor{
	Path: "username_excluded_keywords.txt",
	Parse: func(data []byte) (interface{}, error) {
		return matchlist.New(string(data), true, true)
	},
})

Functions

This section is empty.

Types

type Checker

type Checker struct {
	Config             *config.LoginIDConfig
	TypeCheckerFactory *TypeCheckerFactory
}

func (*Checker) CheckType

func (c *Checker) CheckType(loginIDKey string, t model.LoginIDKeyType) bool

func (*Checker) LoginIDKeyClaimName

func (c *Checker) LoginIDKeyClaimName(loginIDKey string) (string, bool)

func (*Checker) ValidateOne

func (c *Checker) ValidateOne(loginID identity.LoginIDSpec, options CheckerOptions) error

type CheckerOptions

type CheckerOptions struct {
	EmailByPassBlocklistAllowlist bool
}

type EmailChecker

type EmailChecker struct {
	Config *config.LoginIDEmailConfig
	// DomainBlockList, DomainAllowList and BlockFreeEmailProviderDomains
	// are provided by TypeCheckerFactory based on config, so the related
	// resources will only be loaded when it is enabled
	// EmailChecker will not further check the config before performing
	// validation
	DomainBlockList               *matchlist.MatchList
	DomainAllowList               *matchlist.MatchList
	BlockFreeEmailProviderDomains *matchlist.MatchList
	Error                         error
}

func (*EmailChecker) Validate

func (c *EmailChecker) Validate(ctx *validation.Context, loginID string)

type EmailNormalizer

type EmailNormalizer struct {
	Config *config.LoginIDEmailConfig
}

func (*EmailNormalizer) ComputeUniqueKey

func (n *EmailNormalizer) ComputeUniqueKey(normalizeLoginID string) (string, error)

func (*EmailNormalizer) Normalize

func (n *EmailNormalizer) Normalize(loginID string) (string, error)

type Normalizer

type Normalizer interface {
	Normalize(loginID string) (string, error)
	ComputeUniqueKey(normalizeLoginID string) (string, error)
}

type NormalizerFactory

type NormalizerFactory struct {
	Config *config.LoginIDConfig
}

func (*NormalizerFactory) NormalizerWithLoginIDType

func (f *NormalizerFactory) NormalizerWithLoginIDType(loginIDKeyType model.LoginIDKeyType) Normalizer

type NullChecker

type NullChecker struct{}

func (*NullChecker) Validate

func (c *NullChecker) Validate(ctx *validation.Context, loginID string)

type NullNormalizer

type NullNormalizer struct{}

func (*NullNormalizer) ComputeUniqueKey

func (n *NullNormalizer) ComputeUniqueKey(normalizeLoginID string) (string, error)

func (*NullNormalizer) Normalize

func (n *NullNormalizer) Normalize(loginID string) (string, error)

type PhoneChecker

type PhoneChecker struct{}

func (*PhoneChecker) Validate

func (c *PhoneChecker) Validate(ctx *validation.Context, loginID string)

type PhoneNumberNormalizer

type PhoneNumberNormalizer struct {
}

func (*PhoneNumberNormalizer) ComputeUniqueKey

func (n *PhoneNumberNormalizer) ComputeUniqueKey(normalizeLoginID string) (string, error)

func (*PhoneNumberNormalizer) Normalize

func (n *PhoneNumberNormalizer) Normalize(loginID string) (string, error)

type Provider

type Provider struct {
	Store             *Store
	Config            *config.LoginIDConfig
	Checker           *Checker
	NormalizerFactory *NormalizerFactory
	Clock             clock.Clock
}

func (*Provider) Create

func (p *Provider) Create(i *identity.LoginID) error

func (*Provider) Delete

func (p *Provider) Delete(i *identity.LoginID) error

func (*Provider) Get

func (p *Provider) Get(userID, id string) (*identity.LoginID, error)

func (*Provider) GetByUniqueKey

func (p *Provider) GetByUniqueKey(uniqueKey string) (*identity.LoginID, error)

func (*Provider) GetByValue

func (p *Provider) GetByValue(value string) ([]*identity.LoginID, error)

func (*Provider) GetMany

func (p *Provider) GetMany(ids []string) ([]*identity.LoginID, error)

func (*Provider) IsLoginIDKeyType

func (p *Provider) IsLoginIDKeyType(loginIDKey string, loginIDKeyType model.LoginIDKeyType) bool

func (*Provider) List

func (p *Provider) List(userID string) ([]*identity.LoginID, error)

func (*Provider) ListByClaim

func (p *Provider) ListByClaim(name string, value string) ([]*identity.LoginID, error)

func (*Provider) New

func (p *Provider) New(userID string, spec identity.LoginIDSpec, options CheckerOptions) (*identity.LoginID, error)

func (*Provider) Normalize

func (p *Provider) Normalize(typ model.LoginIDKeyType, value string) (normalized string, uniqueKey string, err error)

func (*Provider) Update

func (p *Provider) Update(i *identity.LoginID) error

func (*Provider) ValidateOne

func (p *Provider) ValidateOne(loginID identity.LoginIDSpec, options CheckerOptions) error

func (*Provider) WithValue

func (p *Provider) WithValue(iden *identity.LoginID, value string, options CheckerOptions) (*identity.LoginID, error)

type ResourceManager

type ResourceManager interface {
	Read(desc resource.Descriptor, view resource.View) (interface{}, error)
}

type Store

type Store struct {
	SQLBuilder  *appdb.SQLBuilderApp
	SQLExecutor *appdb.SQLExecutor
}

func (*Store) Create

func (s *Store) Create(i *identity.LoginID) (err error)

func (*Store) Delete

func (s *Store) Delete(i *identity.LoginID) error

func (*Store) Get

func (s *Store) Get(userID, id string) (*identity.LoginID, error)

func (*Store) GetByLoginID

func (s *Store) GetByLoginID(loginIDKey string, loginID string) (*identity.LoginID, error)

func (*Store) GetByUniqueKey

func (s *Store) GetByUniqueKey(uniqueKey string) (*identity.LoginID, error)

func (*Store) GetMany

func (s *Store) GetMany(ids []string) ([]*identity.LoginID, error)

func (*Store) List

func (s *Store) List(userID string) ([]*identity.LoginID, error)

func (*Store) ListByClaim

func (s *Store) ListByClaim(name string, value string) ([]*identity.LoginID, error)

func (*Store) Update

func (s *Store) Update(i *identity.LoginID) error

type TypeChecker

type TypeChecker interface {
	Validate(ctx *validation.Context, loginID string)
}

type TypeCheckerFactory

type TypeCheckerFactory struct {
	Config    *config.LoginIDConfig
	Resources ResourceManager
}

func (*TypeCheckerFactory) NewChecker

func (f *TypeCheckerFactory) NewChecker(loginIDKeyType model.LoginIDKeyType, options CheckerOptions) TypeChecker

type UsernameChecker

type UsernameChecker struct {
	Config *config.LoginIDUsernameConfig
	// ReservedNames and ExcludedKeywords
	// are provided by TypeCheckerFactory based on config, so the related
	// resources will only be loaded when it is enabled
	// UsernameChecker will not further check the config before performing
	// validation
	ReservedNames    *blocklist.Blocklist
	ExcludedKeywords *matchlist.MatchList
	Error            error
}

func (*UsernameChecker) Validate

func (c *UsernameChecker) Validate(ctx *validation.Context, loginID string)

type UsernameNormalizer

type UsernameNormalizer struct {
	Config *config.LoginIDUsernameConfig
}

func (*UsernameNormalizer) ComputeUniqueKey

func (n *UsernameNormalizer) ComputeUniqueKey(normalizeLoginID string) (string, error)

func (*UsernameNormalizer) Normalize

func (n *UsernameNormalizer) Normalize(loginID string) (string, error)

Jump to

Keyboard shortcuts

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