jwt

package
v0.0.0-...-d00273e Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2016 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(secret string, alg gojwt.SigningMethod, token Token) (string, error)

Types

type AuthHandler

type AuthHandler func(login string, password string) interface{}

type Config

type Config struct {
	UsernameField string
	PasswordField string
	IdentityKey   string
	AuthPrefix    string

	AccessExpirationDelta  time.Duration
	RefreshExpirationDelta time.Duration

	HeaderInvalidHandler ErrorHandler
	TokenInvalidHandler  ErrorHandler
	TokenExpireHandler   ErrorHandler

	AuthErrorHandler       ErrorHandler
	LoginResponseHandler   ResponseHandler
	RefreshResponseHandler ResponseHandler
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(secret string) Config

type ErrorHandler

type ErrorHandler func(c *echo.Context)

type IdentityHandler

type IdentityHandler func(identity interface{}) interface{}

type Jwt

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

func NewJwt

func NewJwt(config Config, authenticate AuthHandler, identity IdentityHandler) Jwt

func (*Jwt) AuthRequired

func (jwt *Jwt) AuthRequired() echo.HandlerFunc

Auth required middleware.

func (*Jwt) GenerateAccessToken

func (jwt *Jwt) GenerateAccessToken(identity interface{}) (string, error)

Generate access token from identity. Use this method for generating tokens in your handlers.

func (*Jwt) GenerateRefreshToken

func (jwt *Jwt) GenerateRefreshToken(identity interface{}) (string, error)

Generate refresh token from identity. Use this method for generating tokens in your handlers.

func (*Jwt) LoginHandler

func (jwt *Jwt) LoginHandler() echo.HandlerFunc

Login handler. Override authenticate function and return identity for user.

func (*Jwt) RefreshTokenHandler

func (jwt *Jwt) RefreshTokenHandler() echo.HandlerFunc

Refresh token handler. Use this handler for refreshing access and refresh tokens by old refresh token.

func (*Jwt) TokenFromString

func (jwt *Jwt) TokenFromString(tokenString string) (*Token, error)

Get token object from token string. Use this method for parsing token object from token header in your custom handlers.

type ResponseHandler

type ResponseHandler func(c *echo.Context, identity interface{}, accessToken string, refreshToken string)

type Token

type Token struct {
	Identity      interface{}
	UnixTimestamp int64
	Type          TokenType
}

func Decode

func Decode(secret string, alg gojwt.SigningMethod, tokenString string) (*Token, error)

func (*Token) IsExpired

func (t *Token) IsExpired() bool

type TokenType

type TokenType byte
const (
	AccessToken TokenType = iota
	RefreshToken
)

Jump to

Keyboard shortcuts

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