Files

24 lines
704 B
Go
Raw Permalink Normal View History

2026-05-15 16:53:05 +02:00
package middleware
import (
"net/http"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/ocis-pkg/mfa"
2026-06-19 10:43:41 +02:00
revactx "github.com/owncloud/reva/v2/pkg/ctx"
2026-05-15 16:53:05 +02:00
)
// 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) {
2026-06-19 10:43:41 +02:00
if !revactx.HasMFA(r.Context()) {
2026-05-15 16:53:05 +02:00
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)
})
}
}