jwt

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package JWT is able to generate and validate json web tokens. Follows https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(elements map[string]interface{}) (result map[string]interface{})

func Filter

func Filter(elements map[string]interface{}, keys ...string) map[string]interface{}

func ToString

func ToString(i interface{}) string

func ToTime

func ToTime(i interface{}) time.Time

Types

type Headers

type Headers struct {
	Extra map[string]interface{}
}

HeaderContext is the context for a jwt header.

func (*Headers) Add

func (h *Headers) Add(key string, value interface{})

func (*Headers) Get

func (h *Headers) Get(key string) interface{}

func (*Headers) ToMap

func (h *Headers) ToMap() map[string]interface{}

type IDTokenClaims

type IDTokenClaims struct {
	Issuer          string
	Subject         string
	Audience        string
	Nonce           string
	ExpiresAt       time.Time
	IssuedAt        time.Time
	AuthTime        time.Time
	AccessTokenHash []byte
	CodeHash        []byte
	Extra           map[string]interface{}
}

func (*IDTokenClaims) Add

func (c *IDTokenClaims) Add(key string, value interface{})

func (*IDTokenClaims) Get

func (c *IDTokenClaims) Get(key string) interface{}

func (*IDTokenClaims) ToMap

func (c *IDTokenClaims) ToMap() map[string]interface{}

type JWTClaims

type JWTClaims struct {
	Subject   string
	Issuer    string
	Audience  string
	JTI       string
	IssuedAt  time.Time
	NotBefore time.Time
	ExpiresAt time.Time
	Extra     map[string]interface{}
}

JWTClaims represent a token's claims.

func JWTClaimsFromMap

func JWTClaimsFromMap(m map[string]interface{}) *JWTClaims

func (*JWTClaims) Add

func (c *JWTClaims) Add(key string, value interface{})

func (JWTClaims) Get

func (c JWTClaims) Get(key string) interface{}

func (*JWTClaims) IsExpired

func (c *JWTClaims) IsExpired() bool

IsExpired checks if JWT is expired.

func (*JWTClaims) IsNotYetValid

func (c *JWTClaims) IsNotYetValid() bool

IsNotYetValid maskes sure that the JWT is not used before valid date.

func (*JWTClaims) ToMap

func (c *JWTClaims) ToMap() map[string]interface{}

type Mapper

type Mapper interface {
	ToMap() map[string]interface{}
	Add(key string, value interface{})
	Get(key string) interface{}
}

type RS256JWTStrategy

type RS256JWTStrategy struct {
	PrivateKey *rsa.PrivateKey
}

Enigma is responsible for generating and validating challenges.

func (*RS256JWTStrategy) Decode

func (j *RS256JWTStrategy) Decode(token string) (*jwt.Token, error)

func (*RS256JWTStrategy) Generate

func (j *RS256JWTStrategy) Generate(claims Mapper, header Mapper) (string, string, error)

Generate generates a new authorize code or returns an error. set secret

func (*RS256JWTStrategy) GetSignature

func (j *RS256JWTStrategy) GetSignature(token string) (string, error)

func (*RS256JWTStrategy) GetSigningMethodLength

func (c *RS256JWTStrategy) GetSigningMethodLength() int

func (*RS256JWTStrategy) Hash

func (c *RS256JWTStrategy) Hash(in []byte) ([]byte, error)

func (*RS256JWTStrategy) Validate

func (j *RS256JWTStrategy) Validate(token string) (string, error)

Validate : Validates a token and returns its signature or an error if the token is not valid.

Jump to

Keyboard shortcuts

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