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 = NewValidationError ("'none' signature type is not allowed" , ValidationErrorSignatureInvalid )
RegisterSigningMethod (SigningMethodNone .Alg (), func () SigningMethod {
return SigningMethodNone
})
}
func (m *signingMethodNone ) Alg () string {
return "none"
}
func (m *signingMethodNone ) Verify (signingString , signature string , key interface {}) (err error ) {
if _ , ok := key .(unsafeNoneMagicConstant ); !ok {
return NoneSignatureTypeDisallowedError
}
if signature != "" {
return NewValidationError (
"'none' signing method with non-empty signature" ,
ValidationErrorSignatureInvalid ,
)
}
return nil
}
func (m *signingMethodNone ) Sign (signingString string , key interface {}) (string , error ) {
if _ , ok := key .(unsafeNoneMagicConstant ); ok {
return "" , nil
}
return "" , NoneSignatureTypeDisallowedError
}
The pages are generated with Golds v0.6.7 . (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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds .