devfeel/dotweb

Exclude不生效

EriconYu opened this issue · 1 comments

func InitAuthN(app dotweb.DotWeb) {
au := NewAuthN()
au.Exclude("/")
au.Exclude("/index")
au.Exclude("/list")
au.Exclude("/login")
au.Exclude("/logout")
au.Exclude("/view/
")
au.Exclude("/v1/machines/queryall")
au.Exclude("/v1/machines/queryIP/:IP")
app.Use(au)
}
type AuthN struct {
dotweb.BaseMiddlware
}
func (a *AuthN) Handle(ctx dotweb.Context) error {
golog.Info("authN middleware handle...")
golog.Info("URI is ", ctx.Request().RequestURI)
//check authN cookie
golog.Info("authN middleware handle want auth...")
cookie, _ := ctx.ReadCookie("skymachid")
golog.Info("cookie is ", cookie)
if cookie == nil {
golog.Error("cookie not present!")
return ctx.Redirect(http.StatusFound, "/login")
}
if (cookie.Expires.Unix() - time.Now().Unix()) >= 0 {
golog.Error("cookie out of date!")
delete(cookies, cookie.Value)
return ctx.Redirect(http.StatusFound, "/login")
}
user := cookies[cookie.Value]
golog.Info("user is ", user)
a.Next(ctx)
golog.Info("authN middleware handle auth pass...")
return nil
}
func NewAuthN() *AuthN {
return &AuthN{}
}

以上Exclude代码不生效,有的好用有的不好用,我这里马上要发车了,求大佬速速搞定,感激涕零,跪谢不已……

it's fixed on version 1.4.3