jwt

package
v0.0.0-...-dd668d6 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: Apache-2.0 Imports: 15 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RS256 = jwt.SigningMethodRS256
	RS384 = jwt.SigningMethodRS384
	RS512 = jwt.SigningMethodRS512
)

Functions

This section is empty.

Types

type Claims

type Claims struct {
	*jwt.StandardClaims
	*auth.User
	Renewed int `json:"renewed"`
}

type JWTClient

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

func NewJWTClient

func NewJWTClient(options ...JWTClientOption) (*JWTClient, error)

func (*JWTClient) Authorized

func (j *JWTClient) Authorized(t *Token, perms ...PermFunc) error

func (*JWTClient) AuthorizedGrpc

func (j *JWTClient) AuthorizedGrpc(ctx context.Context, perms ...PermFunc) error

func (*JWTClient) AuthorizedHandler

func (j *JWTClient) AuthorizedHandler(handler http.Handler, perms ...PermFunc) http.Handler

func (*JWTClient) ParseToken

func (j *JWTClient) ParseToken(token string) (*Token, error)

func (*JWTClient) ParseTokenContext

func (j *JWTClient) ParseTokenContext(ctx context.Context) (*Token, error)

func (*JWTClient) ParseTokenHeader

func (j *JWTClient) ParseTokenHeader(r *http.Request) (*Token, error)

func (*JWTClient) ParseTokenReader

func (j *JWTClient) ParseTokenReader(reader io.ReadCloser) (*Token, error)

func (*JWTClient) PublicKey

func (j *JWTClient) PublicKey() *rsa.PublicKey

func (*JWTClient) PublicKeyPEM

func (j *JWTClient) PublicKeyPEM() []byte

type JWTClientOption

type JWTClientOption func(*JWTClient) error

func WithLoadPublicKey

func WithLoadPublicKey(publicKeyFile string) JWTClientOption

func WithPublicKey

func WithPublicKey(publicKey []byte) JWTClientOption

type JWTServer

type JWTServer struct {
	*JWTClient
	// contains filtered or unexported fields
}

func NewJWTServer

func NewJWTServer(signingAlgo SigningAlgo, expiration time.Duration, skew time.Duration, options ...JWTServerOption) (*JWTServer, error)

func (*JWTServer) NewToken

func (j *JWTServer) NewToken(u *auth.User, policies ...PolicyFunc) *Token

func (*JWTServer) PrivateKey

func (j *JWTServer) PrivateKey() *rsa.PrivateKey

func (*JWTServer) PrivateKeyPEM

func (j *JWTServer) PrivateKeyPEM() []byte

func (*JWTServer) RenewToken

func (j *JWTServer) RenewToken(t *Token)

func (*JWTServer) SignToken

func (j *JWTServer) SignToken(t *Token) (string, error)

type JWTServerOption

type JWTServerOption func(*JWTServer) error

func WithKeys

func WithKeys(privateKey []byte, publicKey []byte) JWTServerOption

func WithLoadKeys

func WithLoadKeys(privateKeyFile string, publicKeyFile string) JWTServerOption

type PermFunc

type PermFunc func(c *Claims) error

type PolicyFunc

type PolicyFunc func(c *Claims)

type SigningAlgo

type SigningAlgo *jwt.SigningMethodRSA

type Token

type Token struct {
	SignedToken string
	*jwt.Token
}

func LoadSignedToken

func LoadSignedToken(tokenFile string) (*Token, error)

func (*Token) GetRequestMetadata

func (t *Token) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

func (*Token) RequireTransportSecurity

func (t *Token) RequireTransportSecurity() bool

Jump to

Keyboard shortcuts

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