user

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareHashAndPassword

func CompareHashAndPassword(hashedPwd, pwd []byte) error

func GenerateHashedSaltPassword

func GenerateHashedSaltPassword(pwd []byte) ([]byte, error)

Types

type Claims

type Claims struct {
	Username string `json:"username"`
	jwt.RegisteredClaims
}

Create a struct that will be encoded to a JWT. We add jwt.RegisteredClaims as an embedded type, to provide fields like expiry time

type JWTIssuer

type JWTIssuer struct {
	ExpirationTime time.Duration
	Key            string
}

func (*JWTIssuer) Issue

func (j *JWTIssuer) Issue(username string) (string, error)

func (*JWTIssuer) Validate

func (j *JWTIssuer) Validate(token string) (string, error)

type Service

type Service interface {
	Register(ctx context.Context, loginName, pwd string) (string, error)
	Login(ctx context.Context, loginName, pwd string, auth bool) (bool, string, error)

	GetPubKey(ctx context.Context, loginName string, keyName string) ([]byte, error)
	ListPubKeys(ctx context.Context, loginName string) ([]query.Key, error)
	CreatePubKey(ctx context.Context, loginName, keyName string, pubKey []byte) error

	ValidateJWT(token string) (string, error)
}

func NewService

func NewService(querier query.Querier,
	secret string, expirationTimeDefault time.Duration) Service

Jump to

Keyboard shortcuts

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