zhangqian
2023-10-13 581cb45bb6a5cb928dfa920abf9c51652aae2da5
接口白名单
1个文件已修改
8 ■■■■■ 已修改文件
middleware/user.go 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
middleware/user.go
@@ -32,7 +32,15 @@
    }
}
var whiteList = map[string]struct{}{ //白名单地址列表
    "/api/code/getCodeList": {},
    "/api/data/getAllData":  {},
}
func CheckAuth(apiPath string, token string) bool {
    if _, ok := whiteList[apiPath]; ok {
        return true
    }
    cli := user.NewUserServiceClient(userConn)
    ctx, cancel := context.WithTimeout(context.Background(), time.Second)
    defer cancel()