mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
40fb13ba3c
* Add period TOPT config key to define the time in seconds each OTP is rotated * Add skew TOTP config to define how many keys either side of the current one should be considered valid * Add tests and set minimum values * Update config template * Use unix epoch for position calculation and Fix QR gen * This resolves the timer resetting improperly at the 0 seconds mark and allows for periods longer than 1 minute * Generate QR based on period * Fix OTP timer graphic
35 lines
1.2 KiB
Go
35 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 whether second factor is enabled
|
|
SecondFactorEnabled bool `json:"second_factor_enabled"`
|
|
|
|
// TOTP Period
|
|
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)
|
|
}
|