session

package
v0.3.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeCookieMetadata added in v0.3.3

func MakeCookieMetadata(key, value string, flags ...string) string

MakeCookieMetadata generates a string representing a Web cookie. Yum!

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) (jwt.Claims, error)

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

func (SessionManager) SignClaims added in v0.3.3

func (mgr SessionManager) SignClaims(claims jwt.Claims) (string, error)

Jump to

Keyboard shortcuts

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