2022-04-03 11:58:27 +00:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/authelia/authelia/v4/internal/middlewares"
|
|
|
|
)
|
|
|
|
|
2022-06-10 01:34:43 +00:00
|
|
|
// PasswordPolicyConfigurationGET get the password policy configuration.
|
|
|
|
func PasswordPolicyConfigurationGET(ctx *middlewares.AutheliaCtx) {
|
2022-06-14 07:20:13 +00:00
|
|
|
policyResponse := PasswordPolicyBody{
|
2022-04-03 11:58:27 +00:00
|
|
|
Mode: "disabled",
|
|
|
|
}
|
|
|
|
|
|
|
|
if ctx.Configuration.PasswordPolicy.Standard.Enabled {
|
|
|
|
policyResponse.Mode = "standard"
|
|
|
|
policyResponse.MinLength = ctx.Configuration.PasswordPolicy.Standard.MinLength
|
|
|
|
policyResponse.MaxLength = ctx.Configuration.PasswordPolicy.Standard.MaxLength
|
|
|
|
policyResponse.RequireLowercase = ctx.Configuration.PasswordPolicy.Standard.RequireLowercase
|
|
|
|
policyResponse.RequireUppercase = ctx.Configuration.PasswordPolicy.Standard.RequireUppercase
|
|
|
|
policyResponse.RequireNumber = ctx.Configuration.PasswordPolicy.Standard.RequireNumber
|
|
|
|
policyResponse.RequireSpecial = ctx.Configuration.PasswordPolicy.Standard.RequireSpecial
|
2022-04-08 23:21:49 +00:00
|
|
|
} else if ctx.Configuration.PasswordPolicy.ZXCVBN.Enabled {
|
2022-04-03 11:58:27 +00:00
|
|
|
policyResponse.Mode = "zxcvbn"
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
if err = ctx.SetJSONBody(policyResponse); err != nil {
|
|
|
|
ctx.Logger.Errorf("Unable to send password Policy: %s", err)
|
|
|
|
}
|
|
|
|
}
|