session

package
v0.0.0-...-500edce Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClaims

func GetClaims(claims jwt.Claims) (name string, exp float64)

func NewInMemorySessionPersistance

func NewInMemorySessionPersistance(addr, password string, logger log.Logger) (*inMemorySessionPersistance, error)

func NewToken

func NewToken(exp int64, username string, secret []byte) (string, error)

NewToken creates a new JWT using the HS256 signing algorithm.

The following claims are set:

  • exp
  • name

func VerifyToken

func VerifyToken(tokenString string, secret []byte) (jwt.Claims, error)

Types

type Manager

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

func NewManager

func NewManager(persistance Persistance, secret []byte) *Manager

func (*Manager) GetSessionToken

func (s *Manager) GetSessionToken(name string) (string, error)

GetSessionToken creates and then returns a new token for the given user.

func (*Manager) InvlidateAllTokens

func (s *Manager) InvlidateAllTokens(username string) error

InvlidateAllTokens invalidates all tokens of a user by putting them on the black list.

func (*Manager) InvlidateToken

func (s *Manager) InvlidateToken(token string) error

InvlidateToken puts the token on the black list.

func (*Manager) ValidateToken

func (s *Manager) ValidateToken(token string) (string, error)

ValidateToken Checks if the token is valid and/or black listed.

type Persistance

type Persistance interface {
	BlackList(username string, token string, exp float64) error
	IsBlackListed(username string, token string) (bool, error)
	Store(username string, token string, exp int64) error
	BlackListAll(username string) error
}

Jump to

Keyboard shortcuts

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