package jwt
var SigningMethodNone *signingMethodNone
const UnsafeAllowNoneSignatureType unsafeNoneMagicConstant = "none signing method allowed"
var NoneSignatureTypeDisallowedError error
type signingMethodNone struct {}
type unsafeNoneMagicConstant string
func init () {
SigningMethodNone = &signingMethodNone {}
NoneSignatureTypeDisallowedError = newError ("'none' signature type is not allowed" , ErrTokenUnverifiable )
RegisterSigningMethod (SigningMethodNone .Alg (), func () SigningMethod {
return SigningMethodNone
})
}
func (m *signingMethodNone ) Alg () string {
return "none"
}
func (m *signingMethodNone ) Verify (signingString string , sig []byte , key interface {}) (err error ) {
if _ , ok := key .(unsafeNoneMagicConstant ); !ok {
return NoneSignatureTypeDisallowedError
}
if len (sig ) != 0 {
return newError ("'none' signing method with non-empty signature" , ErrTokenUnverifiable )
}
return nil
}
func (m *signingMethodNone ) Sign (signingString string , key interface {}) ([]byte , error ) {
if _ , ok := key .(unsafeNoneMagicConstant ); ok {
return []byte {}, nil
}
return nil , NoneSignatureTypeDisallowedError
}
The pages are generated with Golds v0.7.6 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .