1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-30 19:22:11 +00:00

feat(integrations): automatically disable googlereader/fever when not used #3543

When there is no user of Fever/GoogleReader, there is no need to expose their
endpoints. This reduces quite a bit the exposition surface of miniflux, while
not breaking any existing deployments, and is pretty self-contained.
This commit is contained in:
jvoisin 2025-08-02 22:58:36 +02:00
parent 10b2b36895
commit 0e28c0610a
5 changed files with 73 additions and 1 deletions

View file

@ -25,6 +25,21 @@ func newMiddleware(s *storage.Storage) *middleware {
return &middleware{s}
}
func (m *middleware) maybeUnauthorizedGoogleReader(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
googleReaderUsed, err := m.store.IsGoogleReaderUsed()
if err != nil {
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusInternalServerError)
return
}
if !googleReaderUsed {
sendUnauthorizedResponse(w)
}
next.ServeHTTP(w, r)
})
}
func (m *middleware) handleCORS(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")