diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-04-06 18:53:33 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-04-06 18:53:33 +0800 |
commit | c76ad944920300be58446ddd1a50c8d693957774 (patch) | |
tree | ec9aed051e82deb3c479ab1b7ab50aa2c07d9efb /vendor/github.com/dgrijalva/jwt-go/none.go | |
parent | 3d8de95f999de6f52f0c1605eb2913278f1d87d2 (diff) | |
download | go-tangerine-c76ad944920300be58446ddd1a50c8d693957774.tar go-tangerine-c76ad944920300be58446ddd1a50c8d693957774.tar.gz go-tangerine-c76ad944920300be58446ddd1a50c8d693957774.tar.bz2 go-tangerine-c76ad944920300be58446ddd1a50c8d693957774.tar.lz go-tangerine-c76ad944920300be58446ddd1a50c8d693957774.tar.xz go-tangerine-c76ad944920300be58446ddd1a50c8d693957774.tar.zst go-tangerine-c76ad944920300be58446ddd1a50c8d693957774.zip |
.travis, build: autodelete old unstable archives (#13867)
This commit adds a build step to travis to auto-delete unstable archives older than
14 days (our regular release schedule) from Azure via ci.go purge.
The commit also pulls in the latest Azure storage code, also switching over from
the old import path (github.com/Azure/azure-sdk-for-go) to the new split one
(github.com/Azure/azure-storage-go).
Diffstat (limited to 'vendor/github.com/dgrijalva/jwt-go/none.go')
-rw-r--r-- | vendor/github.com/dgrijalva/jwt-go/none.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/vendor/github.com/dgrijalva/jwt-go/none.go b/vendor/github.com/dgrijalva/jwt-go/none.go new file mode 100644 index 000000000..f04d189d0 --- /dev/null +++ b/vendor/github.com/dgrijalva/jwt-go/none.go @@ -0,0 +1,52 @@ +package jwt + +// Implements the none signing method. This is required by the spec +// but you probably should never use it. +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" +} + +// Only allow 'none' alg type if UnsafeAllowNoneSignatureType is specified as the key +func (m *signingMethodNone) Verify(signingString, signature string, key interface{}) (err error) { + // Key must be UnsafeAllowNoneSignatureType to prevent accidentally + // accepting 'none' signing method + if _, ok := key.(unsafeNoneMagicConstant); !ok { + return NoneSignatureTypeDisallowedError + } + // If signing method is none, signature must be an empty string + if signature != "" { + return NewValidationError( + "'none' signing method with non-empty signature", + ValidationErrorSignatureInvalid, + ) + } + + // Accept 'none' signing method. + return nil +} + +// Only allow 'none' signing if UnsafeAllowNoneSignatureType is specified as the key +func (m *signingMethodNone) Sign(signingString string, key interface{}) (string, error) { + if _, ok := key.(unsafeNoneMagicConstant); ok { + return "", nil + } + return "", NoneSignatureTypeDisallowedError +} |