jwt

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2020 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultExpired  = time.Minute * 10
	ErrNoToken      = errors.New("no token")
	ErrTokenExpired = errors.New("expired token, yo")
)
View Source
var (
	ErrECDSAVerification = jwt.ErrECDSAVerification
)

Functions

func BytesToECDSA

func BytesToECDSA(b []byte) (*btcec.PrivateKey, error)

BytesToECDSA returns *btcec.PrivateKey from b

func FromECDSA

func FromECDSA(key *btcec.PrivateKey) ([]byte, error)

FromECDSA serializes private key to bytes

func HexToECDSA

func HexToECDSA(hexkey string) (*btcec.PrivateKey, error)

HexToECDSA parses a hex encoded private key

func LoadECDSA

func LoadECDSA(file string) (*btcec.PrivateKey, error)

LoadECDSA loads a secp256k1 private key from the given file made with SaveKey

func NewKey

func NewKey() (*btcec.PrivateKey, error)

NewKey generates a new *btcec.PrivateKey

func NewToken

func NewToken(token TokenFormat) *jwt.Token

func NewWallet

func NewWallet(rpcnode, keystore string, tgunclient *tgun.Client) *aquawallet

func S256

func S256() elliptic.Curve

S256 returns an instance of the secp256k1 curve.

func SaveKey

func SaveKey(key *btcec.PrivateKey, file string) error

SaveKey writes key to file, hex encoded.

Types

type Config

type Config struct {
	Debug, CheckIP, CheckUA bool
}

type Permissions

type Permissions map[string]bool

func NewPermissions

func NewPermissions(perm ...string) Permissions

type System

type System struct {
	Config *Config
	// contains filtered or unexported fields
}

func NewSystem

func NewSystem(addr, dbpath, keypath string, config *Config) (*System, error)

func (*System) AddPerm

func (s *System) AddPerm(u, perm string) error

AddPerm adds a permission/role to a user. 1 READ 1 WRITE

func (*System) AuthenticateSession

func (s *System) AuthenticateSession(r *http.Request) (*TokenFormat, error)

AuthenticateSession returns error if session can not be verified

func (*System) ParseTokenForm

func (s *System) ParseTokenForm(r *http.Request) (*jwt.Token, *TokenFormat, error)

ParseTokenForm from a form["token"], parse the form before calling

func (*System) ParseTokenString

func (s *System) ParseTokenString(tokenString string) (*jwt.Token, *TokenFormat, error)

ParseTokenString from a string

func (*System) Pubkey

func (s *System) Pubkey() ecdsa.PublicKey

func (*System) RemovePerm

func (s *System) RemovePerm(u, perm string) error

RemovePerm removes a permission from user u. 1 READ 1 WRITE

func (*System) Serve

func (s *System) Serve() error

func (*System) ServeHTTP

func (s *System) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is the main entrypoint / router, passing GET requests to s.nextStepGET(w,r)

type TokenFormat

type TokenFormat struct {
	Username  string
	Time      time.Time // issued
	Expires   time.Time // if set, overrides DefaultExpired per token
	UserAgent string
	IP        string
	UserInfo  UserInfo
	jwt.StandardClaims
}

type UserInfo

type UserInfo struct {
	Permissions Permissions
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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