2019-12-07 16:40:42 +00:00
|
|
|
package handlers
|
|
|
|
|
2020-06-21 13:40:37 +00:00
|
|
|
import (
|
2021-08-11 01:04:35 +00:00
|
|
|
"github.com/authelia/authelia/v4/internal/authentication"
|
|
|
|
"github.com/authelia/authelia/v4/internal/middlewares"
|
2020-06-21 13:40:37 +00:00
|
|
|
)
|
2019-12-07 16:40:42 +00:00
|
|
|
|
2020-06-21 13:40:37 +00:00
|
|
|
// ConfigurationGet get the configuration accessible to authenticated users.
|
2019-12-07 16:40:42 +00:00
|
|
|
func ConfigurationGet(ctx *middlewares.AutheliaCtx) {
|
2022-03-03 11:20:43 +00:00
|
|
|
body := configurationBody{
|
|
|
|
AvailableMethods: make(MethodList, 0, 3),
|
2019-12-07 16:40:42 +00:00
|
|
|
}
|
2020-06-21 13:40:37 +00:00
|
|
|
|
2022-03-03 11:20:43 +00:00
|
|
|
if ctx.Providers.Authorizer.IsSecondFactorEnabled() {
|
|
|
|
if !ctx.Configuration.TOTP.Disable {
|
|
|
|
body.AvailableMethods = append(body.AvailableMethods, authentication.TOTP)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !ctx.Configuration.Webauthn.Disable {
|
|
|
|
body.AvailableMethods = append(body.AvailableMethods, authentication.Webauthn)
|
|
|
|
}
|
|
|
|
|
|
|
|
if ctx.Configuration.DuoAPI != nil {
|
|
|
|
body.AvailableMethods = append(body.AvailableMethods, authentication.Push)
|
|
|
|
}
|
|
|
|
}
|
2021-06-18 01:38:01 +00:00
|
|
|
|
2020-06-21 13:40:37 +00:00
|
|
|
ctx.Logger.Tracef("Available methods are %s", body.AvailableMethods)
|
2020-12-16 01:47:31 +00:00
|
|
|
|
2022-03-03 11:20:43 +00:00
|
|
|
if err := ctx.SetJSONBody(body); err != nil {
|
2020-12-16 01:47:31 +00:00
|
|
|
ctx.Logger.Errorf("Unable to set configuration response in body: %s", err)
|
|
|
|
}
|
2019-12-07 16:40:42 +00:00
|
|
|
}
|