auth

package
v0.0.0-...-a8786dc Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccessUuidKey = contextKey(contextKey{key: "access-uuid"})
View Source
var ErrExpiredToken = errors.New("token expired")
View Source
var ErrIncompatibleVersion = errors.New("incompatible version of argon2")
View Source
var ErrInvalidHash = errors.New("the encoded hash is not in the correct format")
View Source
var RefreshUserIDKey = contextKey(contextKey{"refresh-user-id"})
View Source
var RefreshUuidKey = contextKey(contextKey{"refresh-uuid"})
View Source
var UserIDKey = contextKey(contextKey{key: "user-id"})

Functions

func FetchAuth

func FetchAuth(ctx context.Context, authD *TokenMetaDetails) (int64, error)

func TokenValid

func TokenValid(r *http.Request, name string, secret string) error

func VerifyToken

func VerifyToken(r *http.Request, name string, secret string) (*jwt.Token, error)

Types

type AuthService

type AuthService interface {
	GetUserID(context.Context) (int64, error)
	AuthMiddleware(http.Handler) http.Handler
	GetPasswordHash(string) ([]byte, error)
	VerifyPasswordHash(string, []byte) (bool, error)
	Login(context.Context, int64, string) error
	Logout(context.Context) error
	Refresh(context.Context, string) (int64, error)
}

func NewAuth

func NewAuth(aSecret string, rSecret string) AuthService

type CookieAccess

type CookieAccess struct {
	Writer http.ResponseWriter
}

func (*CookieAccess) RemoveToken

func (access *CookieAccess) RemoveToken(name string)

func (*CookieAccess) SetToken

func (access *CookieAccess) SetToken(name string, token string, expiration time.Time)

SetToken sets an httponly cookie with a provided token. Intended To be used in a resolver which as the CookieAccess struct passed into it via the context via a Middleware.

type TokenDetails

type TokenDetails struct {
	AccessToken  string
	RefreshToken string
	AccessUuid   string
	RefreshUuid  string
	AtExpires    int64
	RtExpires    int64
}

type TokenMetaDetails

type TokenMetaDetails struct {
	Uuid   string
	UserId int64
}

func ExtractTokenMetadata

func ExtractTokenMetadata(r *http.Request, tokenType string, secret string) (*TokenMetaDetails, error)

Jump to

Keyboard shortcuts

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