-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/gf: if env is production,swagger or openapi set auth config,eg: auth or password #3898
Comments
I spent two hours thinking and figured out, he wants an authentication mechanism for swagger api path when he takes the whole project online in public. We might provide basic auth mechanism in |
Let me try adding this feature |
Why not just adding an auth middleware for the |
在中间件中获取不到路由path,目前这个方式需要由下往上改造, @gqcn 辛苦确认一下,或许直接在ghttp中加一个中间件,无需用户自定义中间件 |
单就openapi相关的参数的话,path可以通过config获取,然后可以直接操作路由: path, err := g.Config().Get(ctx, "server.openapiPath")
if err != nil {
return err
}
s.BindMiddleware(path.String(),
service.Middleware().Auth,
service.Middleware().IsAdmin,
) 这样应该是可以的?而且和项目自身的鉴权统一的话也更方便管理,感觉另外加一个单独的鉴权有点怪怪的 |
What do you want to ask?
swagger setting auth config
The text was updated successfully, but these errors were encountered: