hack: scheduler ping/version escape auth

This commit is contained in:
Qiu Jian
2018-11-03 10:21:19 +08:00
parent 732243efba
commit 7e463a4644
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -2,6 +2,7 @@ package proxy
import (
"context"
"crypto/tls"
"fmt"
"net/http"
"net/http/httputil"
@@ -9,7 +10,6 @@ import (
"yunion.io/x/log"
"yunion.io/x/onecloud/pkg/httperrors"
"crypto/tls"
)
type EndpointGenerator func(context.Context, http.ResponseWriter, *http.Request) (string, error)
+10
View File
@@ -3,6 +3,7 @@ package middleware
import (
"fmt"
"net/http"
"strings"
"gopkg.in/gin-gonic/gin.v1"
@@ -15,6 +16,15 @@ const (
func KeystoneTokenVerifyMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
// hack
escapeAuth := []string{"ping", "version", "metrics"}
for _, s := range escapeAuth {
if strings.HasSuffix(c.Request.URL.Path, s) {
c.Next()
return
}
}
token := c.Request.Header.Get(XAuthTokenKey)
if len(token) == 0 {
c.AbortWithError(http.StatusBadRequest, fmt.Errorf("Not found %s in http header.", XAuthTokenKey))