auth MW refactor
This commit is contained in:
parent
a7530a6324
commit
0903bc55eb
7 changed files with 15 additions and 148 deletions
|
|
@ -65,23 +65,5 @@ func (r *router) Set() *gin.Engine {
|
|||
//swagger
|
||||
r.engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
|
||||
r.engine.Use(authMiddleware(mwDeps{
|
||||
prefix: r.apiPrefix,
|
||||
excludeRoutes: &r.excludeRoutes,
|
||||
tokenProv: r.tokenProv,
|
||||
}))
|
||||
|
||||
return r.engine
|
||||
}
|
||||
|
||||
func (r *router) ExcludeRoutes(routes []shared.ExcludeRoute) {
|
||||
log.Debug("Excluded routes:")
|
||||
excludedRoutes := make(map[string]shared.ExcludeRoute, len(routes))
|
||||
|
||||
for _, route := range routes {
|
||||
log.Debugf("%s %s", route.Method, route.Route)
|
||||
ex := joinPaths(r.apiPrefix, route.Route)
|
||||
excludedRoutes[ex] = shared.ExcludeRoute{Route: ex, Method: route.Method}
|
||||
}
|
||||
r.excludeRoutes = excludedRoutes
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue