update compose and remove default admins
This commit is contained in:
+1
-1
@@ -21,7 +21,7 @@ var opts struct {
|
||||
BoltPath string `long:"bolt" env:"BOLTDB_PATH" default:"/tmp" description:"parent dir for bolt files"`
|
||||
Sites []string `long:"site" env:"SITE" default:"remark" description:"site names" env-delim:","`
|
||||
RemarkURL string `long:"url" env:"REMARK_URL" default:"https://remark42.com" description:"url to remark"`
|
||||
Admins []string `long:"admin" env:"ADMIN" default:"umputun@gmail.com" description:"admin(s) names" env-delim:","`
|
||||
Admins []string `long:"admin" env:"ADMIN" description:"admin(s) names" env-delim:","`
|
||||
|
||||
DevMode bool `long:"dev" env:"DEV" description:"development mode, no auth enforced"`
|
||||
Dbg bool `long:"dbg" env:"DEBUG" description:"debug mode"`
|
||||
|
||||
+13
-7
@@ -53,23 +53,27 @@ func (s *Server) Run() {
|
||||
return modes
|
||||
}
|
||||
|
||||
s.respCache = cache.New(time.Hour, 5*time.Minute)
|
||||
if len(s.Admins) > 0 {
|
||||
log.Printf("[DEBUG] admins %+v", s.Admins)
|
||||
}
|
||||
|
||||
// cache for responses. Flushes completely on any modification
|
||||
s.respCache = cache.New(4*time.Hour, 15*time.Minute)
|
||||
|
||||
router := chi.NewRouter()
|
||||
router.Use(middleware.RealIP, Recoverer)
|
||||
router.Use(middleware.Throttle(1000), middleware.Timeout(60*time.Second))
|
||||
router.Use(auth.Auth(s.SessionStore, s.Admins, maybeDevMode(auth.Anonymous)))
|
||||
router.Use(Limiter(10), AppInfo("remark", s.Version), Ping, Logger(LogAll))
|
||||
router.Use(Limiter(10), AppInfo("remark42", s.Version), Ping, Logger(LogAll))
|
||||
router.Use(auth.Auth(s.SessionStore, s.Admins, maybeDevMode(auth.Anonymous))) // all request by default allow anonymous access
|
||||
|
||||
// If you aren't using gorilla/mux, you need to wrap your handlers with context.ClearHandler
|
||||
router.Use(context.ClearHandler)
|
||||
router.Use(context.ClearHandler) // if you aren't using gorilla/mux, you need to wrap your handlers with context.ClearHandler
|
||||
|
||||
// auth routes for all providers
|
||||
router.Route("/auth", func(r chi.Router) {
|
||||
r.Mount("/google", s.AuthGoogle.Routes())
|
||||
r.Mount("/github", s.AuthGithub.Routes())
|
||||
r.Mount("/facebook", s.AuthFacebook.Routes())
|
||||
r.Get("/logout", s.AuthGoogle.LogoutHandler) // shortcut, can be any of providers, does the same
|
||||
r.Get("/logout", s.AuthGoogle.LogoutHandler) // shortcut, can be any of providers, all logouts do the same
|
||||
})
|
||||
|
||||
// api routes
|
||||
@@ -94,6 +98,7 @@ func (s *Server) Run() {
|
||||
|
||||
})
|
||||
|
||||
// add robots and file server for static content from /web
|
||||
router.Get("/robots.txt", func(w http.ResponseWriter, r *http.Request) {
|
||||
render.PlainText(w, r, "User-agent: *\nDisallow: /auth/\nDisallow: /api/\n")
|
||||
})
|
||||
@@ -326,7 +331,7 @@ func httpError(w http.ResponseWriter, r *http.Request, code int, err error, deta
|
||||
render.JSON(w, r, JSON{"error": err.Error(), "details": details})
|
||||
}
|
||||
|
||||
// renderJSONWithHTML allows html tags
|
||||
// renderJSONWithHTML allows html tags and forces charset=utf-8
|
||||
func renderJSONWithHTML(w http.ResponseWriter, r *http.Request, v interface{}) {
|
||||
buf := &bytes.Buffer{}
|
||||
enc := json.NewEncoder(buf)
|
||||
@@ -342,6 +347,7 @@ func renderJSONWithHTML(w http.ResponseWriter, r *http.Request, v interface{}) {
|
||||
_, _ = w.Write(buf.Bytes())
|
||||
}
|
||||
|
||||
// serves static files from /web
|
||||
func (s *Server) addFileServer(r chi.Router, path string, root http.FileSystem) {
|
||||
fs := http.StripPrefix(path, http.FileServer(root))
|
||||
|
||||
|
||||
+7
-4
@@ -18,12 +18,15 @@ services:
|
||||
- "8080:8080"
|
||||
|
||||
environment:
|
||||
- REMARK_URL=http://remark.umputun.com:8080
|
||||
- BOLTDB_FILE=/srv/var/remark.db
|
||||
- SESSION_STORE=/srv/var
|
||||
- REMARK_URL=https://demo.remark42.com
|
||||
- BOLTDB_PATH=/srv/var/db
|
||||
- BACKUP_PATH=/srv/var/backup
|
||||
- SESSION_STORE=/srv/var/session
|
||||
- DEV=true # development mode flag. It turns authentication off, be careful!
|
||||
- DEBUG=true
|
||||
|
||||
volumes:
|
||||
- ./var:/srv/var
|
||||
- ./web:/srv/web # maps web directory directly and propagate local changes to container without redeploy
|
||||
- ./web:/srv/web # maps web directory directly to propagate local changes to container without redeploy
|
||||
|
||||
command: /srv/remark server
|
||||
|
||||
@@ -45,5 +45,3 @@ GET https://demo.remark42.com/api/v1/count?site=remark&url=https://radio-t.com/p
|
||||
|
||||
### list commented posts
|
||||
GET https://demo.remark42.com/api/v1/list?site=remark
|
||||
|
||||
###
|
||||
|
||||
Reference in New Issue
Block a user