jwt

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2018 License: CC0-1.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Issuer               = "eqip"
	BasicAuthAudience    = "Basic"
	TwoFactorAudience    = "2FA"
	SingleSignOnAudience = "SSO"
)

Variables

View Source
var (
	JwtSecret        = Secret()
	JwtSigningMethod = jwt.SigningMethodHS256
	AuthBearerRegexp = regexp.MustCompile("Bearer\\s(.*)")
	Expiration       = Timeout()
)

Functions

func CheckToken

func CheckToken(r *http.Request, validTokenFunc func(string, string) (bool, error), audiences ...string) (string, error)

CheckToken tests if the token is valid and is of the correct audience.

func ConfigureEnvironment

func ConfigureEnvironment(size int) error

ConfigureEnvironment ensure the secret is set prior to use.

func CurrentAudience

func CurrentAudience(r *http.Request) string

CurrentAudience is the currently valid audience from the token.

func ExtractToken

func ExtractToken(r *http.Request) string

ExtractToken returns the token from an HTTP request header.

func KeyFunc

func KeyFunc(token *jwt.Token) (interface{}, error)

KeyFunc ensures the signing method of the token.

func NewToken

func NewToken(id int, audience string) (string, time.Time, error)

NewToken generates a new Jwt signed token using a users account information

func ParseWithClaims

func ParseWithClaims(tokenString string) (*jwt.Token, error)

ParseWithClaims parses the token with standard claims..

func Secret

func Secret() []byte

Secret returns the secret to use with JWT tokens.

func Timeout

func Timeout() time.Duration

Timeout returns the duration in time for how long a session is considered valid. Per policy this defaults to 15 minutes.

func TokenClaims

func TokenClaims(token *jwt.Token) *jwt.StandardClaims

TokenClaims return all standard token claims.

Types

This section is empty.

Jump to

Keyboard shortcuts

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