jwt

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2019 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 EAppClaims added in v1.0.6

type EAppClaims struct {
	SessionIndex string `json:"sid,omitempty"`
	jwt.StandardClaims
}

EAppClaims are all the claims eApp uses in JWT

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, sessionIndex string, audience string) (string, time.Time, error)

NewToken generates a new Jwt signed token using a users account information id is the user id for the token. sessionIndex is the user session identifier provided by the SAML identity provider (facilitates Single Logout) audience is a JWT field that defines the intended recipient of the token

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) SessionIndex added in v1.0.7

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

SessionIndex returns the SAML user session identifier persisted in the token.

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) *EAppClaims

TokenClaims return all standard token claims.

Jump to

Keyboard shortcuts

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