Documentation
¶
Index ¶
- Constants
- func EncodeSegment(seg []byte) string
- type Claims
- func (c Claims) Add(val ...interface{}) error
- func (c Claims) Bool(k string) bool
- func (c Claims) Int(k string) int
- func (c Claims) Marshal() string
- func (c Claims) String(k string) string
- func (c Claims) Time(k string) *time.Time
- func (c Claims) To(val interface{}) error
- func (c Claims) Valid() error
- type Config
- type Key
- type Option
- type Parser
- type Provider
- func Load(cfgfile string, crypto *cryptoprov.Crypto) (Provider, error)
- func MustNew(cfg *Config, crypto *cryptoprov.Crypto, ops ...Option) Provider
- func New(cfg *Config, crypto *cryptoprov.Crypto, ops ...Option) (Provider, error)
- func NewFromCryptoSigner(signer crypto.Signer, ops ...Option) (Provider, error)
- type Signer
- type SignerInfo
- type VerifyConfig
Constants ¶
const ( // DefaultNotBefore offset for NotBefore DefaultNotBefore = -2 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func EncodeSegment ¶
EncodeSegment returns JWT specific base64url encoding with padding stripped
Types ¶
type Claims ¶
Claims provides generic claims on map
func (Claims) String ¶
String will return the named claim as a string, if the underlying type is not a string, it will try and co-oerce it to a string.
type Config ¶
type Config struct {
// Issuer specifies issuer claim
Issuer string `json:"issuer" yaml:"issuer"`
// KeyID specifies ID of the current key
KeyID string `json:"kid" yaml:"kid"`
// Keys specifies list of issuer's keys
Keys []*Key `json:"keys" yaml:"keys"`
PrivateKey string `json:"private_key" yaml:"private_key"`
}
Config provides OAuth2 configuration
func LoadConfig ¶
LoadConfig returns configuration loaded from a file
type Key ¶
type Key struct {
// ID of the key
ID string `json:"id" yaml:"id"`
Seed string `json:"seed" yaml:"seed"`
}
Key for JWT signature
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
A Option modifies the default behavior of Provider.
func WithHeaders ¶
WithHeaders allows to specify extra headers or override defaults
type Parser ¶
type Parser interface {
// ParseToken returns jwt.StandardClaims
ParseToken(authorization string, cfg *VerifyConfig) (Claims, error)
}
Parser specifies JWT parser interface
type Provider ¶
Provider specifies JWT provider interface
func Load ¶
func Load(cfgfile string, crypto *cryptoprov.Crypto) (Provider, error)
Load returns new provider
func MustNew ¶
func MustNew(cfg *Config, crypto *cryptoprov.Crypto, ops ...Option) Provider
MustNew returns new provider
type Signer ¶
type Signer interface {
// SignToken returns signed JWT token
SignToken(id, subject string, audience []string, expiry time.Duration, extraClaims Claims) (string, Claims, error)
// PublicKey is returned for assymetric signer
PublicKey() crypto.PublicKey
}
Signer specifies JWT signer interface
type SignerInfo ¶
type SignerInfo struct {
// contains filtered or unexported fields
}
SignerInfo represents JWT signer
func NewSignerInfo ¶
func NewSignerInfo(signer crypto.Signer) (*SignerInfo, error)
NewSignerInfo returns *SignerInfo
type VerifyConfig ¶
type VerifyConfig struct {
// ExpectedSubject validates the sub claim of a JWT matches this value
ExpectedSubject string
// ExpectedAudience validates that the aud claim of a JWT contains this value
ExpectedAudience string
}
VerifyConfig expreses the possible options for validating a JWT