session

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeSignature

func MakeSignature(size int) ([]byte, error)

MakeSignature generates a cryptographically-secure pseudo-random token, based on a given number of random bytes, for signing purposes.

Types

type SessionManager

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

SessionManager generates and validates JWT tokens for login sessions.

func MakeSessionManager

func MakeSessionManager(secretKey []byte) SessionManager

MakeSessionManager creates a new session manager with the given secret key.

func (SessionManager) Create

func (mgr SessionManager) Create(subject string) (string, error)

Create creates a new token for a given subject (user) and returns it as a string.

func (SessionManager) LoginLocalUser

func (mgr SessionManager) LoginLocalUser(username, password string, users map[string]string) (string, error)

LoginLocalUser checks if a username/password combo is correct and creates a new token if so. [TODO] This may belong elsewhere.

func (SessionManager) Parse

func (mgr SessionManager) Parse(tokenString string) (*SessionManagerTokenClaims, error)

Parse tries to parse the provided string and returns the token claims.

type SessionManagerTokenClaims

type SessionManagerTokenClaims struct {
	//Foo string `json:"foo"`
	jwt.StandardClaims
}

SessionManagerTokenClaims holds claim metadata for a token.

Jump to

Keyboard shortcuts

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