presigned: Fix a bug in presigned request verification.

Additionally add Docker proxy configuration.
This commit is contained in:
Harshavardhana
2016-02-18 02:13:52 -08:00
parent d561f0cc0b
commit 91a092792a
12 changed files with 136 additions and 90 deletions

View File

@@ -16,12 +16,7 @@
package main
import (
"fmt"
"net/http"
jwtgo "github.com/dgrijalva/jwt-go"
)
import "net/http"
const (
signV4Algorithm = "AWS4-HMAC-SHA256"
@@ -69,15 +64,8 @@ func (a authHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Verify JWT authorization header is present.
if isRequestJWT(r) {
// Validate Authorization header to be valid.
jwt := InitJWT()
token, e := jwtgo.ParseFromRequest(r, func(token *jwtgo.Token) (interface{}, error) {
if _, ok := token.Method.(*jwtgo.SigningMethodHMAC); !ok {
return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"])
}
return jwt.secretAccessKey, nil
})
if e != nil || !token.Valid {
// Validate Authorization header if its valid.
if !isJWTReqAuthenticated(r) {
w.WriteHeader(http.StatusUnauthorized)
return
}