auth

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package auth contains code to ensure users are authorized to use the server after they have logged in.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JwtTokenizer

type JwtTokenizer struct {
	TokenizerConfig
	// contains filtered or unexported fields
}

JwtTokenizer creates java web tokens.

func (*JwtTokenizer) Create

func (j *JwtTokenizer) Create(username string, points int) (string, error)

Create converts a user to a token string.

func (*JwtTokenizer) ReadUsername

func (j *JwtTokenizer) ReadUsername(tokenString string) (string, error)

ReadUsername extracts the username from the token string.

type TokenizerConfig

type TokenizerConfig struct {
	// TimeFunc is a function which should supply the current time since the unix epoch.
	// This is used for setting token lifespan.
	TimeFunc func() int64
	// ValidSec is the length of time the token is valid from the issuing time, in seconds.
	ValidSec int64
}

TokenizerConfig contains fields which describe a Tokenizer.

func (TokenizerConfig) NewTokenizer

func (cfg TokenizerConfig) NewTokenizer(key interface{}) (*JwtTokenizer, error)

NewTokenizer creates a Tokenizer that users the random number generator to generate tokens.

Jump to

Keyboard shortcuts

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