Documentation ¶
Index ¶
- Constants
- func IsJWS(s string) bool
- func IsJWTUnsecured(s string) bool
- func PayloadToMap(i interface{}) (map[string]interface{}, error)
- func UnsecuredJWTVerifier() jose.SignatureVerifier
- func VerifyEdDSA(pubKey *verifier.PublicKey, message, signature []byte) error
- func VerifyRS256(pubKey *verifier.PublicKey, message, signature []byte) error
- type BasicVerifier
- type Claims
- type JSONWebToken
- type JoseED25519Signer
- type JoseEd25519Verifier
- type KeyResolver
- type KeyResolverFunc
- type ParseOpt
- type RS256Signer
- type RS256Verifier
Constants ¶
const ( // TypeJWT defines JWT type. TypeJWT = "JWT" // AlgorithmNone used to indicate unsecured JWT. AlgorithmNone = "none" )
Variables ¶
This section is empty.
Functions ¶
func IsJWTUnsecured ¶ added in v0.1.3
IsJWTUnsecured checks if JWT is an unsecured JWT of valid structure.
func PayloadToMap ¶ added in v0.1.9
PayloadToMap transforms interface to map.
func UnsecuredJWTVerifier ¶
func UnsecuredJWTVerifier() jose.SignatureVerifier
UnsecuredJWTVerifier provides verifier for unsecured JWT.
func VerifyEdDSA ¶
VerifyEdDSA verifies EdDSA signature.
Types ¶
type BasicVerifier ¶
type BasicVerifier struct {
// contains filtered or unexported fields
}
BasicVerifier defines basic Signed JWT verifier based on Issuer Claim and Key ID JOSE Header.
func GetVerifier ¶ added in v0.1.9
func GetVerifier(publicKey *verifier.PublicKey) (*BasicVerifier, error)
GetVerifier returns new BasicVerifier based on *verifier.PublicKey.
func NewVerifier ¶
func NewVerifier(resolver KeyResolver) *BasicVerifier
NewVerifier creates a new basic Verifier.
type Claims ¶
Claims defines JSON Web Token Claims (https://tools.ietf.org/html/rfc7519#section-4)
type JSONWebToken ¶
type JSONWebToken struct { Headers jose.Headers Payload map[string]interface{} // contains filtered or unexported fields }
JSONWebToken defines JSON Web Token (https://tools.ietf.org/html/rfc7519)
func NewUnsecured ¶ added in v0.1.3
func NewUnsecured(claims interface{}, headers jose.Headers) (*JSONWebToken, error)
NewUnsecured creates new unsecured JSON Web Token based on input claims.
func Parse ¶
func Parse(jwtSerialized string, opts ...ParseOpt) (*JSONWebToken, []byte, error)
Parse parses input JWT in serialized form into JSON Web Token. Currently JWS and unsecured JWT is supported.
func (*JSONWebToken) DecodeClaims ¶
func (j *JSONWebToken) DecodeClaims(c interface{}) error
DecodeClaims fills input c with claims of a token.
func (*JSONWebToken) LookupStringHeader ¶
func (j *JSONWebToken) LookupStringHeader(name string) string
LookupStringHeader makes look up of particular header with string value.
type JoseED25519Signer ¶ added in v0.1.9
type JoseED25519Signer struct {
// contains filtered or unexported fields
}
JoseED25519Signer is a Jose compliant signer.
func NewEd25519Signer ¶ added in v0.1.9
func NewEd25519Signer(privKey []byte) *JoseED25519Signer
NewEd25519Signer returns a Jose compliant signer that can be passed as a signer to jwt.NewSigned().
func (JoseED25519Signer) Headers ¶ added in v0.1.9
func (s JoseED25519Signer) Headers() jose.Headers
Headers returns the signer's headers map.
type JoseEd25519Verifier ¶ added in v0.1.9
type JoseEd25519Verifier struct {
// contains filtered or unexported fields
}
JoseEd25519Verifier is a Jose compliant verifier.
func NewEd25519Verifier ¶ added in v0.1.9
func NewEd25519Verifier(pubKey []byte) (*JoseEd25519Verifier, error)
NewEd25519Verifier returns a Jose compliant verifier that can be passed as a verifier option to jwt.Parse().
type KeyResolver ¶
type KeyResolver interface { // Resolve resolves public key. Resolve(what, kid string) (*verifier.PublicKey, error) }
KeyResolver resolves public key based on what and kid.
type KeyResolverFunc ¶ added in v0.1.3
KeyResolverFunc defines function.
type ParseOpt ¶
type ParseOpt func(opts *parseOpts)
ParseOpt is the JWT Parser option.
func WithIgnoreClaimsMapDecoding ¶ added in v0.3.0
WithIgnoreClaimsMapDecoding option is for ignore decoding claims into .Payload map[string]interface. Decoding to map[string]interface is pretty expensive, so this option can be used for performance critical operations.
func WithJWTDetachedPayload ¶
WithJWTDetachedPayload option is for definition of JWT detached payload.
func WithSignatureVerifier ¶
func WithSignatureVerifier(signatureVerifier jose.SignatureVerifier) ParseOpt
WithSignatureVerifier option is for definition of JWT detached payload.
type RS256Signer ¶ added in v0.1.9
type RS256Signer struct {
// contains filtered or unexported fields
}
RS256Signer is a Jose complient signer.
func NewRS256Signer ¶ added in v0.1.9
func NewRS256Signer(privKey *rsa.PrivateKey, headers map[string]interface{}) *RS256Signer
NewRS256Signer returns a Jose compliant signer that can be passed as a signer to jwt.NewSigned().
func (RS256Signer) Headers ¶ added in v0.1.9
func (s RS256Signer) Headers() jose.Headers
Headers returns the signer's headers map.
type RS256Verifier ¶ added in v0.1.9
type RS256Verifier struct {
// contains filtered or unexported fields
}
RS256Verifier is a Jose compliant verifier.
func NewRS256Verifier ¶ added in v0.1.9
func NewRS256Verifier(pubKey *rsa.PublicKey) *RS256Verifier
NewRS256Verifier returns a Jose compliant verifier that can be passed as a verifier option to jwt.Parse().