mirror of
https://gitea.com/gitea/gitea-mirror.git
synced 2026-03-20 11:50:27 +00:00
Refactor auth middleware (#36848)
Principles: let the caller decide what it needs, but not let the framework (middleware) guess what it should do. Then a lot of hacky code can be removed. And some FIXMEs can be fixed. This PR introduces a new kind of middleware: "PreMiddleware", it will be executed before all other middlewares on the same routing level, then a route can declare its options for other middlewares. By the way, allow the workflow badge to be accessed by Basic or OAuth2 auth. Fixes: https://github.com/go-gitea/gitea/pull/36830 Fixes: https://github.com/go-gitea/gitea/issues/36859
This commit is contained in:
@@ -180,8 +180,9 @@ func InitWebInstalled(ctx context.Context) {
|
||||
// NormalRoutes represents non install routes
|
||||
func NormalRoutes() *web.Router {
|
||||
r := web.NewRouter()
|
||||
r.Use(common.ProtocolMiddlewares()...)
|
||||
r.Use(common.MaintenanceModeHandler())
|
||||
r.BeforeRouting(common.ProtocolMiddlewares()...)
|
||||
|
||||
r.AfterRouting(common.MaintenanceModeHandler())
|
||||
|
||||
r.Mount("/", web_routers.Routes())
|
||||
r.Mount("/api/v1", apiv1.Routes())
|
||||
|
||||
Reference in New Issue
Block a user