Merge branch 'master' of github.com:didi/nightingale
This commit is contained in:
commit
6b646e3510
2
control
2
control
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# release version
|
# release version
|
||||||
version=2.3.0
|
version=2.4.1
|
||||||
|
|
||||||
CWD=$(cd $(dirname $0)/; pwd)
|
CWD=$(cd $(dirname $0)/; pwd)
|
||||||
cd $CWD
|
cd $CWD
|
||||||
|
|
|
@ -59,3 +59,7 @@ redis:
|
||||||
# conn: 500
|
# conn: 500
|
||||||
# read: 3000
|
# read: 3000
|
||||||
# write: 3000
|
# write: 3000
|
||||||
|
|
||||||
|
tokens:
|
||||||
|
- 7dcd606e0462f9df2fea0bf505c9e622
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ type Config struct {
|
||||||
Cleaner cleanerSection `yaml:"cleaner"`
|
Cleaner cleanerSection `yaml:"cleaner"`
|
||||||
Link linkSection `yaml:"link"`
|
Link linkSection `yaml:"link"`
|
||||||
Notify map[string][]string `yaml:"notify"`
|
Notify map[string][]string `yaml:"notify"`
|
||||||
|
Tokens []string `yaml:"tokens"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type linkSection struct {
|
type linkSection struct {
|
||||||
|
|
|
@ -5,10 +5,12 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/model"
|
"github.com/didi/nightingale/src/model"
|
||||||
|
"github.com/didi/nightingale/src/modules/monapi/config"
|
||||||
|
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/toolkits/pkg/errors"
|
"github.com/toolkits/pkg/errors"
|
||||||
|
"github.com/toolkits/pkg/slice"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Logined() gin.HandlerFunc {
|
func Logined() gin.HandlerFunc {
|
||||||
|
@ -74,7 +76,7 @@ const internalToken = "monapi-builtin-token"
|
||||||
func CheckHeaderToken() gin.HandlerFunc {
|
func CheckHeaderToken() gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
token := c.GetHeader("x-srv-token")
|
token := c.GetHeader("x-srv-token")
|
||||||
if token != internalToken {
|
if token != internalToken && !slice.ContainsString(config.Get().Tokens, token) {
|
||||||
errors.Bomb("token[%s] invalid", token)
|
errors.Bomb("token[%s] invalid", token)
|
||||||
}
|
}
|
||||||
c.Next()
|
c.Next()
|
||||||
|
|
|
@ -127,6 +127,8 @@ func Config(r *gin.Engine) {
|
||||||
v1 := r.Group("/v1/portal").Use(middleware.CheckHeaderToken())
|
v1 := r.Group("/v1/portal").Use(middleware.CheckHeaderToken())
|
||||||
{
|
{
|
||||||
v1.POST("/endpoint", endpointImport)
|
v1.POST("/endpoint", endpointImport)
|
||||||
|
v1.GET("/tree", treeGet)
|
||||||
|
v1.GET("/endpoints/bynodeids", endpointByNodeIdsGets)
|
||||||
}
|
}
|
||||||
|
|
||||||
transferProxy := r.Group("/api/transfer")
|
transferProxy := r.Group("/api/transfer")
|
||||||
|
|
Loading…
Reference in New Issue