jwt

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2018 License: CC0-1.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Issuer is the JWT issuer.
	Issuer = "eqip"
)

Variables

View Source
var (
	// JwtSecret is the secret used to generate tokens.
	JwtSecret = ""

	// JwtSigningMethod is the algorithm used for signing tokens.
	JwtSigningMethod = jwt.SigningMethodHS256

	// AuthBearerRegexp is a regular expression to extract the authorization token.
	AuthBearerRegexp = regexp.MustCompile("Bearer\\s(.*)")
)

Functions

This section is empty.

Types

type Service added in v0.5.3

type Service struct {
	Env api.Settings
}

Service is an implementation of JWT service handling.

func (Service) CheckToken added in v0.5.3

func (service Service) CheckToken(request *http.Request) (string, int, error)

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

func (Service) ConfigureEnvironment added in v0.5.3

func (service Service) ConfigureEnvironment(size int) error

ConfigureEnvironment ensure the secret is set prior to use.

func (Service) CurrentAudience added in v0.5.3

func (service Service) CurrentAudience(request *http.Request) string

CurrentAudience is the currently valid audience from the token.

func (Service) ExtractToken added in v0.5.3

func (service Service) ExtractToken(request *http.Request) string

ExtractToken returns the token from an HTTP request header.

func (Service) KeyFunc added in v0.5.3

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

KeyFunc ensures the signing method of the token.

func (Service) NewToken added in v0.5.3

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

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

func (Service) ParseWithClaims added in v0.5.3

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

ParseWithClaims parses the token with standard claims..

func (Service) Secret added in v0.5.3

func (service Service) Secret() []byte

Secret returns the secret to use with JWT tokens.

func (Service) TargetAudiences added in v0.5.3

func (service Service) TargetAudiences() []string

TargetAudiences which are accepted based on the configured environment.

func (Service) Timeout added in v0.5.3

func (service Service) 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 (Service) TokenClaims added in v0.5.3

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

TokenClaims return all standard token claims.

Jump to

Keyboard shortcuts

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