mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
54694c4fca
* [MISC] Ignore errcheck recommendations for legacy code Some of this is likely intended to stay how it is, some could use refactoring, for now we will mark is and ignore it from the linter to be potentially addressed in the future. * [MISC] Ensure files are gofmt-ed
31 lines
1.2 KiB
Go
31 lines
1.2 KiB
Go
package handlers
|
|
|
|
import (
|
|
"github.com/authelia/authelia/internal/authentication"
|
|
"github.com/authelia/authelia/internal/middlewares"
|
|
)
|
|
|
|
// ExtendedConfigurationBody the content returned by extended configuration endpoint
|
|
type ExtendedConfigurationBody struct {
|
|
AvailableMethods MethodList `json:"available_methods"`
|
|
SecondFactorEnabled bool `json:"second_factor_enabled"` // whether second factor is enabled or not
|
|
TOTPPeriod int `json:"totp_period"`
|
|
}
|
|
|
|
// ExtendedConfigurationGet get the extended configuration accessible to authenticated users.
|
|
func ExtendedConfigurationGet(ctx *middlewares.AutheliaCtx) {
|
|
body := ExtendedConfigurationBody{}
|
|
body.AvailableMethods = MethodList{authentication.TOTP, authentication.U2F}
|
|
body.TOTPPeriod = ctx.Configuration.TOTP.Period
|
|
|
|
if ctx.Configuration.DuoAPI != nil {
|
|
body.AvailableMethods = append(body.AvailableMethods, authentication.Push)
|
|
}
|
|
|
|
body.SecondFactorEnabled = ctx.Providers.Authorizer.IsSecondFactorEnabled()
|
|
ctx.Logger.Tracef("Second factor enabled: %v", body.SecondFactorEnabled)
|
|
|
|
ctx.Logger.Tracef("Available methods are %s", body.AvailableMethods)
|
|
ctx.SetJSONBody(body) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
|
}
|