auth clean up and redirect fixes
This commit is contained in:
@@ -51,7 +51,7 @@ func NewRouter(
|
||||
authMiddleware := middleware.NewAuth(
|
||||
logger.WithGroup("auth-middleware"),
|
||||
auth,
|
||||
auth_api.NewLoginURL,
|
||||
//auth_api.NewLoginURL,
|
||||
accts,
|
||||
)
|
||||
|
||||
@@ -81,9 +81,9 @@ func NewRouter(
|
||||
logger.WithGroup("templates"),
|
||||
r.Group(
|
||||
"/ui",
|
||||
stripPrefix("/ui"),
|
||||
authMiddleware.AddIdentityToRequest,
|
||||
authMiddleware.AddIdentity,
|
||||
),
|
||||
"/ui",
|
||||
contentDir,
|
||||
rawEvents,
|
||||
accts,
|
||||
@@ -113,7 +113,7 @@ func NewRouter(
|
||||
sse_api.Routes(
|
||||
api.Group(
|
||||
"/events",
|
||||
authMiddleware.AddIdentityToRequest,
|
||||
authMiddleware.AddIdentity,
|
||||
response.Handler(authMiddleware.Authenticate()),
|
||||
),
|
||||
apiLogger.WithGroup("/events"),
|
||||
@@ -122,7 +122,7 @@ func NewRouter(
|
||||
accounts_api.Routes(
|
||||
api.Group(
|
||||
"/accounts",
|
||||
authMiddleware.AddIdentityToRequest,
|
||||
authMiddleware.AddIdentity,
|
||||
response.Handler(authMiddleware.Authenticate()),
|
||||
),
|
||||
apiLogger.WithGroup("/accounts"),
|
||||
@@ -165,22 +165,5 @@ func fileServer(urlPrefix, dir string, beforeServe func(c *gin.Context)) gin.Han
|
||||
scfs.ServeHTTP(c.Writer, r)
|
||||
c.Abort()
|
||||
}
|
||||
|
||||
// TODO: need a c.Next()?
|
||||
}
|
||||
}
|
||||
|
||||
func stripPrefix(prefix string) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if !strings.HasPrefix(c.Request.URL.Path, prefix) {
|
||||
return
|
||||
}
|
||||
|
||||
c.Request.URL.Path = c.Request.URL.Path[len(prefix):]
|
||||
defer func() {
|
||||
c.Request.URL.Path = prefix + c.Request.URL.Path
|
||||
}()
|
||||
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user