auth

package
v0.0.0-...-21d6f6e Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoPublicKeyFunc  = errors.New("no-public-key-func")
	ErrNoPrivateKeyFunc = errors.New("no-private-key-func")
	ErrInvalidAuthToken = errors.New("invalid-token")
	ErrExpiredAuthToken = errors.New("token-expired")
	ErrNoAuthToken      = errors.New("no-auth-token")
)
View Source
var (
	EmptyExpiringToken = NewToken(0 * time.Second)
)

Functions

func RsaPrivateKeyFromPem

func RsaPrivateKeyFromPem(source func() []byte) (*rsa.PrivateKey, error)

func RsaPublicKeyFromPem

func RsaPublicKeyFromPem(source func() []byte) (func(*jwt.Token) (interface{}, error), error)

Types

type Token

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

JWT token that uses RSA public/private key pairs for signing and verification. The signer uses a RSA private key to sign while the receiver verifies the key using the public key to verify the signature.

func NewToken

func NewToken(ttl time.Duration) *Token

func TokenFromHttp

func TokenFromHttp(req *http.Request, key func() []byte, now func() time.Time) (*Token, error)

parses from header or query https://github.com/dgrijalva/jwt-go/blob/master/token.go#L94 Either Authorization: Bearer .... Or query parameter 'access_token=...'

func TokenFromString

func TokenFromString(tokenString string, key func() []byte, now func() time.Time) (*Token, error)

func (*Token) Add

func (this *Token) Add(key string, value interface{}) *Token

func (*Token) Get

func (this *Token) Get(key string) interface{}

func (*Token) GetString

func (this *Token) GetString(key string) string

func (*Token) HasKey

func (this *Token) HasKey(key string) bool

func (*Token) SetExpiration

func (this *Token) SetExpiration(d time.Duration)

func (*Token) SetHeader

func (this *Token) SetHeader(header http.Header, key func() []byte) error

func (*Token) SignedString

func (this *Token) SignedString(key func() []byte) (string, error)

Jump to

Keyboard shortcuts

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