mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 02:37:24 +08:00
hack: scheduler ping/version escape auth
This commit is contained in:
+1
-1
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user