jwt

package
v0.0.0-...-be43ff6 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestCertificates = [][]string{
	{"../example/cert/rs256-private.pem",
		`-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA4f5wg5l2hKsTeNem/V41fGnJm6gOdrj8ym3rFkEU/wT8RDtn
SgFEZOQpHEgQ7JL38xUfU0Y3g6aYw9QT0hJ7mCpz9Er5qLaMXJwZxzHzAahlfA0i
cqabvJOMvQtzD6uQv6wPEyZtDTWiQi9AXwBpHssPnpYGIn20ZZuNlX2BrClciHhC
PUIIZOQn/MmqTD31jSyjoQoV7MhhMTATKJx2XrHhR+1DcKJzQBSTAGnpYVaqpsAR
ap+nwRipr3nUTuxyGohBTSmjJ2usSeQXHI3bODIRe1AuTyHceAbewn8b462yEWKA
Rdpd9AjQW5SIVPfdsz5B6GlYQ5LdYKtznTuy7wIDAQABAoIBAQCwia1k7+2oZ2d3
n6agCAbqIE1QXfCmh41ZqJHbOY3oRQG3X1wpcGH4Gk+O+zDVTV2JszdcOt7E5dAy
MaomETAhRxB7hlIOnEN7WKm+dGNrKRvV0wDU5ReFMRHg31/Lnu8c+5BvGjZX+ky9
POIhFFYJqwCRlopGSUIxmVj5rSgtzk3iWOQXr+ah1bjEXvlxDOWkHN6YfpV5ThdE
KdBIPGEVqa63r9n2h+qazKrtiRqJqGnOrHzOECYbRFYhexsNFz7YT02xdfSHn7gM
IvabDDP/Qp0PjE1jdouiMaFHYnLBbgvlnZW9yuVf/rpXTUq/njxIXMmvmEyyvSDn
FcFikB8pAoGBAPF77hK4m3/rdGT7X8a/gwvZ2R121aBcdPwEaUhvj/36dx596zvY
mEOjrWfZhF083/nYWE2kVquj2wjs+otCLfifEEgXcVPTnEOPO9Zg3uNSL0nNQghj
FuD3iGLTUBCtM66oTe0jLSslHe8gLGEQqyMzHOzYxNqibx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xyGohBTSmjJ2usSeQXHI3b
ODIRe1AuTyHceAbewn8b462yEWKARdpd9AjQW5SIVPfdsz5B6GlYQ5LdYKtznTuy
7wIDAQAB
-----END PUBLIC KEY-----
`,
	},
}

Functions

func LoadCertificate

func LoadCertificate(path string) ([]byte, error)

Helper func: Read certificate from specified file

Types

type ClaimsCarrier

type ClaimsCarrier map[string]interface{}

func NewClaimsCarrier

func NewClaimsCarrier(id, issuer, subject, audience string, expiresAt, notBefore, issuedAt time.Time) ClaimsCarrier

TODO NewClaimsCarrier should require a request object instead

func (ClaimsCarrier) AssertExpired

func (c ClaimsCarrier) AssertExpired() bool

func (ClaimsCarrier) AssertNotYetValid

func (c ClaimsCarrier) AssertNotYetValid() bool

func (ClaimsCarrier) GetAudience

func (c ClaimsCarrier) GetAudience() string

func (ClaimsCarrier) GetExpiresAt

func (c ClaimsCarrier) GetExpiresAt() time.Time

func (ClaimsCarrier) GetID

func (c ClaimsCarrier) GetID() string

func (ClaimsCarrier) GetIssuedAt

func (c ClaimsCarrier) GetIssuedAt() time.Time

func (ClaimsCarrier) GetIssuer

func (c ClaimsCarrier) GetIssuer() string

func (ClaimsCarrier) GetNotBefore

func (c ClaimsCarrier) GetNotBefore() time.Time

func (ClaimsCarrier) GetSubject

func (c ClaimsCarrier) GetSubject() string

func (ClaimsCarrier) String

func (c ClaimsCarrier) String() string

type JWT

type JWT struct {
	// contains filtered or unexported fields
}

func New

func New(privateKey, publicKey []byte) *JWT

func (*JWT) GenerateAccessToken

func (j *JWT) GenerateAccessToken(data *osin.AccessData, generateRefresh bool) (accessToken string, refreshToken string, err error)

func (*JWT) SignToken

func (j *JWT) SignToken(claims map[string]interface{}, header map[string]interface{}) (string, error)

Create, sign, and return a token.

func (*JWT) VerifyToken

func (j *JWT) VerifyToken(tokenData []byte) (*jwt.Token, error)

Verify a token and output the claims.

type Map

type Map map[string]interface{}

func Unmarshal

func Unmarshal(data []byte) (Map, error)

func (Map) Marshall

func (m Map) Marshall() ([]byte, error)

Jump to

Keyboard shortcuts

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