Add a password policy for distillery users

This commit is contained in:
Tom Wiesing 2023-01-10 11:10:38 +01:00
parent ab9998881b
commit 6f257bd27f
No known key found for this signature in database
9 changed files with 185 additions and 76 deletions

View file

@ -135,6 +135,11 @@ func (du disUser) runDelete(context wisski_distillery.Context) error {
return user.Delete(context.Context)
}
var errPasswordPolicy = exit.Error{
Message: "password policy failed: %s",
ExitCode: exit.ExitGeneric,
}
func (du disUser) runSetPassword(context wisski_distillery.Context) error {
user, err := context.Environment.Auth().User(context.Context, du.Positionals.User)
if err != nil {
@ -160,8 +165,8 @@ func (du disUser) runSetPassword(context wisski_distillery.Context) error {
if passwd != passwd1 {
return errPasswordsNotIdentical
}
if len(passwd) == 0 {
return errPasswordsNotIdentical
if err := user.CheckPasswordPolicy(passwd); err != nil {
return errPasswordPolicy.WithMessageF(err)
}
}