adjust auth middleware init with proxy

This commit is contained in:
Umputun
2018-02-14 14:51:37 -06:00
parent 480bb700ad
commit 2c90863e04
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -68,7 +68,7 @@ func (s *Server) Run(port int) {
router.Use(tollbooth_chi.LimitHandler(tollbooth.NewLimiter(10, nil)))
// all request by default allow anonymous access
router.Use(auth.Auth(s.SessionStore, s.Admins, maybeWithDevMode(auth.Anonymous)))
router.Use(auth.Auth(s.SessionStore, s.AvatarProxy, s.Admins, maybeWithDevMode(auth.Anonymous)))
router.Use(AppInfo("remark42", s.Version), Ping, Logger(LogAll))
router.Use(context.ClearHandler) // if you aren't using gorilla/mux, you need to wrap your handlers with context.ClearHandler
@@ -99,7 +99,7 @@ func (s *Server) Run(port int) {
rapi.Get("/config", s.configCtrl)
// protected routes, require auth
rapi.With(auth.Auth(s.SessionStore, s.Admins, maybeWithDevMode(auth.Full))).Group(func(rauth chi.Router) {
rapi.With(auth.Auth(s.SessionStore, s.AvatarProxy, s.Admins, maybeWithDevMode(auth.Full))).Group(func(rauth chi.Router) {
rauth.Post("/comment", s.createCommentCtrl)
rauth.Put("/comment/{id}", s.updateCommentCtrl)
rauth.Get("/user", s.userInfoCtrl)
+1 -1
View File
@@ -80,7 +80,7 @@ func TestServer_CreateAndGet(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, "<p><strong>test</strong> <em>123</em> http://radio-t.com</p>", comment.Text)
assert.Equal(t, store.User{Name: "developer one", ID: "dev",
Picture: "/api/v1/avatar/dev.png",
Picture: "https://friends.radio-t.com/resources/images/rt_logo_64.png",
Profile: "https://radio-t.com/info/", Admin: true, Blocked: false, IP: ""},
comment.User)
t.Logf("%+v", comment)