auth

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	UserKey     = "X-Auth-User"
	TokenKey    = "X-Auth-Token"
	TelegramKey = "X-Auth-Telegram"
)

Variables

View Source
var ErrInvalidAccessToken = errors.New("invalid auth token")
View Source
var ErrUserAlreadyExists = errors.New("user with such credentials already exist")
View Source
var ErrUserDoesNotExist = errors.New("user does not exist")

Functions

func GetTelegramUsername added in v1.0.3

func GetTelegramUsername(ctx context.Context) (string, error)

func GetUserInfo

func GetUserInfo(ctx context.Context) (*userInfo, error)

func HashPassword

func HashPassword(password, salt string) string

func NewAuthorizer

func NewAuthorizer(key string, expireDuration time.Duration) *authorizer

func ParseToken

func ParseToken(accessToken string, signingKey []byte) (string, string, int64, error)

Types

type Claims

type Claims struct {
	jwt.StandardClaims
	Username string `json:"username"`
	Password string `json:"password"`
	UserID   int64  `json:"user_id"`
}

Jump to

Keyboard shortcuts

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