From 2c90863e043434792c81253f262a7ad918e2078a Mon Sep 17 00:00:00 2001 From: Umputun Date: Wed, 14 Feb 2018 14:51:37 -0600 Subject: [PATCH] adjust auth middleware init with proxy --- app/rest/server.go | 4 ++-- app/rest/server_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/rest/server.go b/app/rest/server.go index cdfc8548..db1ac141 100644 --- a/app/rest/server.go +++ b/app/rest/server.go @@ -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) diff --git a/app/rest/server_test.go b/app/rest/server_test.go index a80ca8b7..e5eaccc9 100644 --- a/app/rest/server_test.go +++ b/app/rest/server_test.go @@ -80,7 +80,7 @@ func TestServer_CreateAndGet(t *testing.T) { assert.Nil(t, err) assert.Equal(t, "

test 123 http://radio-t.com

", 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)