mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-25 13:39:22 +00:00
auth middleware basepath tweaks
This commit is contained in:
parent
e9f6a0a1d2
commit
73b7144394
@ -17,11 +17,6 @@ type authMiddleware struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *authMiddleware) handler(c *router.Context) {
|
func (m *authMiddleware) handler(c *router.Context) {
|
||||||
basepath := m.basepath
|
|
||||||
if basepath == "" {
|
|
||||||
basepath = "/"
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.HasPrefix(c.Req.URL.Path, m.public) {
|
if strings.HasPrefix(c.Req.URL.Path, m.public) {
|
||||||
c.Next()
|
c.Next()
|
||||||
return
|
return
|
||||||
@ -31,7 +26,7 @@ func (m *authMiddleware) handler(c *router.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Req.URL.Path != basepath {
|
if c.Req.URL.Path != m.basepath {
|
||||||
// TODO: check ajax
|
// TODO: check ajax
|
||||||
c.Out.WriteHeader(http.StatusForbidden)
|
c.Out.WriteHeader(http.StatusForbidden)
|
||||||
return
|
return
|
||||||
|
@ -23,7 +23,7 @@ func (s *Server) handler() http.Handler {
|
|||||||
a := &authMiddleware{
|
a := &authMiddleware{
|
||||||
username: s.Username,
|
username: s.Username,
|
||||||
password: s.Password,
|
password: s.Password,
|
||||||
basepath: BasePath,
|
basepath: BasePath + "/",
|
||||||
public: BasePath + "/static",
|
public: BasePath + "/static",
|
||||||
}
|
}
|
||||||
r.Use(a.handler)
|
r.Use(a.handler)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user