authentication

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SocialLoginGoogle = "google"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthProviderEntity added in v0.3.1

type AuthProviderEntity interface {
	orm.Entity
	GetUniqueFieldName() string
	GetPassword() string
}

type Authentication

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

func NewAuthenticationService

func NewAuthenticationService(
	secret string,
	accessTokenTTL int,
	refreshTokenTTL int,
	otpTTL int,
	smsService sms.ISender,
	generatorService generator.Generator,
	clockService clock.Clock,
	passwordService *password.Password,
	jwtService *jwt.JWT,
	mailService *mail.Sender,
	socialServiceMapping map[string]social.IUserData,
) *Authentication

func (*Authentication) Authenticate

func (t *Authentication) Authenticate(ormService *orm.Engine, uniqueValue string, password string, entity AuthProviderEntity) (accessToken string, refreshToken string, err error)

func (*Authentication) AuthenticateByID added in v0.5.0

func (t *Authentication) AuthenticateByID(ormService *orm.Engine, id uint64, entity AuthProviderEntity) (accessToken string, refreshToken string, err error)

func (*Authentication) AuthenticateOTP added in v0.3.3

func (t *Authentication) AuthenticateOTP(ormService *orm.Engine, phone string, entity OTPProviderEntity) (accessToken string, refreshToken string, err error)

func (*Authentication) AuthenticateOTPEmail added in v0.5.8

func (t *Authentication) AuthenticateOTPEmail(ormService *orm.Engine, email string, entity OTPProviderEntity) (accessToken string, refreshToken string, err error)

func (*Authentication) GenerateAndSendOTP added in v0.3.3

func (t *Authentication) GenerateAndSendOTP(ormService *orm.Engine, mobile string, country string) (*GenerateOTP, error)

func (*Authentication) GenerateAndSendOTPEmail added in v0.5.8

func (t *Authentication) GenerateAndSendOTPEmail(ormService *orm.Engine, email string, template string, from string, title string) (*GenerateOTPEmail, error)

func (*Authentication) GenerateTokenPair added in v0.3.1

func (t *Authentication) GenerateTokenPair(id uint64, accessKey string, ttl int) (string, error)

func (*Authentication) LogoutAllSessions added in v0.3.1

func (t *Authentication) LogoutAllSessions(ormService *orm.Engine, id uint64)

func (*Authentication) LogoutCurrentSession added in v0.3.1

func (t *Authentication) LogoutCurrentSession(ormService *orm.Engine, accessKey string)

func (*Authentication) RefreshToken

func (t *Authentication) RefreshToken(ormService *orm.Engine, refreshToken string) (newAccessToken string, newRefreshToken string, err error)

func (*Authentication) VerifyAccessToken

func (t *Authentication) VerifyAccessToken(ormService *orm.Engine, accessToken string, entity orm.Entity) (map[string]string, error)

func (*Authentication) VerifyOTP added in v0.3.3

func (t *Authentication) VerifyOTP(code string, input *GenerateOTP) error

func (*Authentication) VerifyOTPEmail added in v0.5.8

func (t *Authentication) VerifyOTPEmail(code string, input *GenerateOTPEmail) error

func (*Authentication) VerifySocialLogin added in v0.6.2

func (t *Authentication) VerifySocialLogin(source, token string) (*social.UserData, error)

type GenerateOTP added in v0.3.3

type GenerateOTP struct {
	Mobile         string
	ExpirationTime string
	Token          string
}

type GenerateOTPEmail added in v0.5.8

type GenerateOTPEmail struct {
	Email          string
	ExpirationTime string
	Token          string
}

type OTPProviderEntity added in v0.3.3

type OTPProviderEntity interface {
	orm.Entity
	GetPhoneFieldName() string
	GetEmailFieldName() string
}

Jump to

Keyboard shortcuts

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