Description: Fix build with github.com/dgrijalva/jwt-go v2
Author: Guillem Jover <gjover@sipwise.com>
Last-Update: 2016-12-02

---
 services/httpd/handler.go |   11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

--- a/services/httpd/handler.go
+++ b/services/httpd/handler.go
@@ -901,21 +901,14 @@
 					return
 				}
 
-				claims, ok := token.Claims.(jwt.MapClaims)
-				if !ok {
-					h.httpError(w, "problem authenticating token", http.StatusInternalServerError)
-					h.Logger.Print("Could not assert JWT token claims as jwt.MapClaims")
-					return
-				}
-
 				// Make sure an expiration was set on the token.
-				if exp, ok := claims["exp"].(float64); !ok || exp <= 0.0 {
+				if exp, ok := token.Claims["exp"].(float64); !ok || exp <= 0.0 {
 					h.httpError(w, "token expiration required", http.StatusUnauthorized)
 					return
 				}
 
 				// Get the username from the token.
-				username, ok := claims["username"].(string)
+				username, ok := token.Claims["username"].(string)
 				if !ok {
 					h.httpError(w, "username in token must be a string", http.StatusUnauthorized)
 					return
--- a/services/httpd/handler_test.go
+++ b/services/httpd/handler_test.go
@@ -193,13 +193,13 @@
 	h.ServeHTTP(w, req)
 	if w.Code != http.StatusUnauthorized {
 		t.Fatalf("unexpected status: %d: %s", w.Code, w.Body.String())
-	} else if !strings.Contains(w.Body.String(), `{"error":"Token is expired`) {
+	} else if !strings.Contains(w.Body.String(), `{"error":"token is expired`) {
 		t.Fatalf("unexpected body: %s", w.Body.String())
 	}
 
 	// Test handler with JWT token that has no expiration set.
 	token, _ := MustJWTToken("user1", h.Config.SharedSecret, false)
-	delete(token.Claims.(jwt.MapClaims), "exp")
+	delete(token.Claims, "exp")
 	signedToken, err := token.SignedString([]byte(h.Config.SharedSecret))
 	if err != nil {
 		t.Fatal(err)
@@ -707,11 +707,11 @@
 // MustJWTToken returns a new JWT token and signed string or panics trying.
 func MustJWTToken(username, secret string, expired bool) (*jwt.Token, string) {
 	token := jwt.New(jwt.GetSigningMethod("HS512"))
-	token.Claims.(jwt.MapClaims)["username"] = username
+	token.Claims["username"] = username
 	if expired {
-		token.Claims.(jwt.MapClaims)["exp"] = time.Now().Add(-time.Second).Unix()
+		token.Claims["exp"] = time.Now().Add(-time.Second).Unix()
 	} else {
-		token.Claims.(jwt.MapClaims)["exp"] = time.Now().Add(time.Minute * 10).Unix()
+		token.Claims["exp"] = time.Now().Add(time.Minute * 10).Unix()
 	}
 	signed, err := token.SignedString([]byte(secret))
 	if err != nil {
