2019-04-24 21:52:08 +00:00
|
|
|
package middlewares
|
|
|
|
|
|
|
|
import (
|
2021-08-11 01:04:35 +00:00
|
|
|
"github.com/authelia/authelia/v4/internal/authentication"
|
2019-04-24 21:52:08 +00:00
|
|
|
)
|
|
|
|
|
2022-04-08 04:13:47 +00:00
|
|
|
// Require1FA check if user has enough permissions to execute the next handler.
|
|
|
|
func Require1FA(next RequestHandler) RequestHandler {
|
2019-04-24 21:52:08 +00:00
|
|
|
return func(ctx *AutheliaCtx) {
|
2023-01-25 09:36:40 +00:00
|
|
|
if s, err := ctx.GetSession(); err != nil || s.AuthenticationLevel < authentication.OneFactor {
|
2019-04-24 21:52:08 +00:00
|
|
|
ctx.ReplyForbidden()
|
|
|
|
return
|
|
|
|
}
|
2020-05-05 19:35:32 +00:00
|
|
|
|
2019-04-24 21:52:08 +00:00
|
|
|
next(ctx)
|
|
|
|
}
|
|
|
|
}
|