adjust auth middleware init with proxy
This commit is contained in:
+2
-2
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user