* feat: metadata autopropagation * feat: autoprop support for MFA / vault mode * fix: replace some http clients with reva ones * chore: required lib update * fix: adjust unit tests and generate new mocks * fix: apply autopropagation to all regular graph routes * chore: updated reva dependency * fix: return the right decorator for the thumbnails * fix: remove autopropagation headers in the proxy
25 lines
704 B
Go
25 lines
704 B
Go
package middleware
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/mfa"
|
|
revactx "github.com/owncloud/reva/v2/pkg/ctx"
|
|
)
|
|
|
|
// RequireMFA middleware is used to require the user in context to have MFA satisfied
|
|
func RequireMFA(logger log.Logger) func(next http.Handler) http.Handler {
|
|
return func(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
if !revactx.HasMFA(r.Context()) {
|
|
l := logger.SubloggerWithRequestID(r.Context())
|
|
l.Error().Str("path", r.URL.Path).Msg("MFA required but not satisfied")
|
|
mfa.SetRequiredStatus(w)
|
|
return
|
|
}
|
|
next.ServeHTTP(w, r)
|
|
})
|
|
}
|
|
}
|