Documentation ¶
Index ¶
- Variables
- func ParsePublicKey(pem []byte) (interface{}, error)
- func ReadPublicKeyFile(filepath string) (interface{}, error)
- type JWTAuth
- func (auth *JWTAuth) Check(c server.ClientAuthentication) (verified bool)
- func (auth *JWTAuth) Debugf(format string, v ...interface{})
- func (auth *JWTAuth) Errorf(format string, v ...interface{})
- func (auth *JWTAuth) GetUser(token *Token) *server.User
- func (auth *JWTAuth) SetLogger(logger Logger)
- func (auth *JWTAuth) Verify(uToken string, claims jwt.Claims) (token *jwt.Token, err error)
- type KeyProvider
- type Logger
- type Token
Constants ¶
This section is empty.
Variables ¶
var StrictMode = false
StrictMode is a global config if true, any token without exp will be rejected
Functions ¶
func ParsePublicKey ¶
ParsePublicKey tries to parse rsa, ecdsa public key in PEM format from bytes
func ReadPublicKeyFile ¶
ReadPublicKeyFile tries to parse rsa, ecdsa public key in PEM format in file
Types ¶
type JWTAuth ¶
type JWTAuth struct { PublicKeys []KeyProvider // contains filtered or unexported fields }
JWTAuth implements server.Authentication interface
func (*JWTAuth) Check ¶
func (auth *JWTAuth) Check(c server.ClientAuthentication) (verified bool)
Check returns true if connection is valid
func (*JWTAuth) Verify ¶
Verify will return a parsed token if it passes validation, or an error if any part of the token fails validation. Possible errors include malformed tokens, unknown/unspecified signing algorithms, missing secret key, tokens that are not valid yet (i.e., 'nbf' field), tokens that are expired, and tokens that fail signature verification (forged)
type KeyProvider ¶
type KeyProvider interface {
PublicKey() (interface{}, error)
}
KeyProvider is interface to provide public keys
func NewLazyPublicKeyFileProvider ¶
func NewLazyPublicKeyFileProvider(value string) (KeyProvider, error)
NewLazyPublicKeyFileProvider returns a new lazy public key proivder from file
func NewPublicKeyProvider ¶
func NewPublicKeyProvider(pem []byte) (KeyProvider, error)
NewPublicKeyProvider returns a new public key provider parsed from PEM formatted bytes
type Logger ¶
type Logger interface { // Log an error Errorf(format string, v ...interface{}) // Log a debug statement Debugf(format string, v ...interface{}) }
Logger interface compatible with NATS Server