authtype

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SocialAuthTypeGoogle   = auth.AuthTypeGoogle
	SocialAuthTypeApple    = auth.AuthTypeApple
	SocialAuthTypeFacebook = auth.AuthTypeFacebook
	SocialAuthTypeVK       = auth.AuthTypeVK
)

Variables

This section is empty.

Functions

func DefaultSelector

func DefaultSelector(c *gin.Context, t Type) string

Types

type AuthMethod

type AuthMethod struct {
	Type   Type
	Key    string
	Sender sender.Sender

	SignUpRequest          AuthRequest
	SignInRequest          AuthRequest
	CheckUserExistsRequest CheckUserExistsRequest

	SocialSignInRequest SocialAuthRequest
	SocialAuthType      auth.Type

	CodeGenerator code.Generator
	CodeLength    int

	DisableLink bool
}

AuthMethod stores request structures, key and sender that use to send confirmation/recovery codes.

type AuthMethods

type AuthMethods struct {
	List          list
	ExistingTypes map[Type]bool
	Selector      Selector
}

AuthMethods is list of AuthType by key and selector for select AuthType

func New

func New(selector Selector) *AuthMethods

New create AuthMethods (list of AuthMethod). If selector is nil - used default selector

func (*AuthMethods) Add

func (a *AuthMethods) Add(cfg AuthMethod) *AuthMethods

Add new AuthType in AuthTypes list

func (*AuthMethods) CheckFieldsDefine

func (a *AuthMethods) CheckFieldsDefine(u user.User) (ok bool, badFields map[string][]string)

CheckFieldsDefine checks whether all fields required for queries defined in models

func (*AuthMethods) CheckMergeModuleSupport added in v1.3.0

func (a *AuthMethods) CheckMergeModuleSupport() (ok bool, badAuthMethods map[string]string)

func (*AuthMethods) IsEmpty

func (a *AuthMethods) IsEmpty() bool

func (*AuthMethods) Select

func (a *AuthMethods) Select(c *gin.Context, t Type) *AuthMethod

Select uses the selector and returns the found method of authorization

if selector returned the empty key and in auth list only one method - use first method as default and return it if selector returned the empty key and in auth list only one method of t Type - return this method

type AuthRequest

type AuthRequest interface {
	GetUID() (uid string)
	GetPassword() (password string)
}

AuthRequest is basic sign-up/sign-in interface

type AuthRequestFieldable

type AuthRequestFieldable interface {
	Fields() map[string]interface{}
}

AuthRequestFieldable is additional sign-up/sign-in interface for use additional fields

type CheckLoginFieldRequestByEmail

type CheckLoginFieldRequestByEmail struct {
	Email string `json:"email" form:"email" binding:"required"`
}

func (CheckLoginFieldRequestByEmail) GetUID

func (r CheckLoginFieldRequestByEmail) GetUID() (uid string)

type CheckUserExistsRequest

type CheckUserExistsRequest interface {
	GetUID() (uid string)
}

type MergeConfirmRequest added in v1.3.0

type MergeConfirmRequest interface {
	GetConfirmMerge() bool
}

type Selector

type Selector func(c *gin.Context, t Type) (senderKey string)

Selector defines the key of authorization type using gin context

type SignUpRequestByEmail

type SignUpRequestByEmail struct {
	Email        string `json:"email" form:"email" binding:"required"`
	Password     string `json:"password" form:"password" binding:"required"`
	ConfirmMerge bool   `json:"confirmMerge" form:"confirmMerge"`
}

func (SignUpRequestByEmail) GetConfirmMerge added in v1.3.0

func (r SignUpRequestByEmail) GetConfirmMerge() bool

func (SignUpRequestByEmail) GetPassword

func (r SignUpRequestByEmail) GetPassword() (password string)

func (SignUpRequestByEmail) GetUID

func (r SignUpRequestByEmail) GetUID() (uid string)

type SocialAuthRequest

type SocialAuthRequest interface {
	GetToken() string
}

type SocialSignInRequest

type SocialSignInRequest struct {
	Token        string `json:"token" binding:"required"`
	ConfirmMerge bool   `json:"confirmMerge"`
}

func (*SocialSignInRequest) GetConfirmMerge added in v1.3.0

func (r *SocialSignInRequest) GetConfirmMerge() bool

func (*SocialSignInRequest) GetToken

func (r *SocialSignInRequest) GetToken() string

type Type

type Type int
const (
	Password Type = iota
	Social
	OTP
)

Jump to

Keyboard shortcuts

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