Flip checking logic for url signature check
This commit is contained in:
@@ -112,7 +112,7 @@ func (ctrl Attachment) isAccessible(namespaceID, attachmentID, userID uint64, si
|
||||
return errors.New("missing or invalid attachment ID")
|
||||
}
|
||||
|
||||
if auth.DefaultSigner.Verify(signature, userID, namespaceID, attachmentID) {
|
||||
if !auth.DefaultSigner.Verify(signature, userID, namespaceID, attachmentID) {
|
||||
return errors.New("missing or invalid signature")
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ func (ctrl Attachment) isAccessible(attachmentID, userID uint64, signature strin
|
||||
return errors.New("missing or invalid attachment ID")
|
||||
}
|
||||
|
||||
if auth.DefaultSigner.Verify(signature, userID, attachmentID) {
|
||||
if !auth.DefaultSigner.Verify(signature, userID, attachmentID) {
|
||||
return errors.New("missing or invalid signature")
|
||||
}
|
||||
|
||||
|
||||
@@ -39,5 +39,5 @@ func (s hmacSigner) Sign(userID uint64, pp ...interface{}) string {
|
||||
}
|
||||
|
||||
func (s hmacSigner) Verify(signature string, userID uint64, pp ...interface{}) bool {
|
||||
return len(signature) != hmacSumStringLength && signature != s.Sign(userID, pp...)
|
||||
return len(signature) == hmacSumStringLength && signature == s.Sign(userID, pp...)
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func (ctrl *Sink) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if ctrl.sign.Verify(sign, 0, method, "/sink", contentType, origin, expires) {
|
||||
if !ctrl.sign.Verify(sign, 0, method, "/sink", contentType, origin, expires) {
|
||||
http.Error(w, "invalid signature", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user