Help us shape the future of Go! Take the 2026 Go Developer Survey

authentication

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

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,
	ormService *orm.Engine,
	smsService sms.ISender,
	generatorService generator.Generator,
	clockService clock.Clock,
	cacheService *orm.RedisCache,
	passwordService *password.Password,
	jwtService *jwt.JWT,
) *Authentication

func (*Authentication) Authenticate

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

func (*Authentication) AuthenticateOTP added in v0.3.3

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

func (*Authentication) GenerateAndSendOTP added in v0.3.3

func (t *Authentication) GenerateAndSendOTP(mobile string, country string) (*GenerateOTP, 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(id uint64)

func (*Authentication) LogoutCurrentSession added in v0.3.1

func (t *Authentication) LogoutCurrentSession(accessKey string)

func (*Authentication) RefreshToken

func (t *Authentication) RefreshToken(refreshToken string) (newAccessToken string, newRefreshToken string, err error)

func (*Authentication) VerifyAccessToken

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

type GenerateOTP added in v0.3.3

type GenerateOTP struct {
	Mobile         string
	ExpirationTime time.Time
	Token          string
}

type OTPProviderEntity added in v0.3.3

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

Jump to

Keyboard shortcuts

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