feat(authentication): disabled users in yaml file (#4193)

Allows setting users as disabled.
pull/4194/head
James Elliott 2022-10-18 09:10:53 +11:00 committed by GitHub
parent b993c290b0
commit d610874be4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -31,21 +31,25 @@ users:
groups: groups:
- admins - admins
- dev - dev
disabled: false
harry: harry:
displayname: "Harry Potter" displayname: "Harry Potter"
password: "$argon2id$v=19$m=65536,t=3,p=2$BpLnfgDsc2WD8F2q$o/vzA4myCqZZ36bUGsDY//8mKUYNZZaR0t4MFFSs+iM" password: "$argon2id$v=19$m=65536,t=3,p=2$BpLnfgDsc2WD8F2q$o/vzA4myCqZZ36bUGsDY//8mKUYNZZaR0t4MFFSs+iM"
email: harry.potter@authelia.com email: harry.potter@authelia.com
groups: [] groups: []
disabled: false
bob: bob:
displayname: "Bob Dylan" displayname: "Bob Dylan"
password: "$argon2id$v=19$m=65536,t=3,p=2$BpLnfgDsc2WD8F2q$o/vzA4myCqZZ36bUGsDY//8mKUYNZZaR0t4MFFSs+iM" password: "$argon2id$v=19$m=65536,t=3,p=2$BpLnfgDsc2WD8F2q$o/vzA4myCqZZ36bUGsDY//8mKUYNZZaR0t4MFFSs+iM"
email: bob.dylan@authelia.com email: bob.dylan@authelia.com
groups: groups:
- dev - dev
disabled: false
james: james:
displayname: "James Dean" displayname: "James Dean"
password: "$argon2id$v=19$m=65536,t=3,p=2$BpLnfgDsc2WD8F2q$o/vzA4myCqZZ36bUGsDY//8mKUYNZZaR0t4MFFSs+iM" password: "$argon2id$v=19$m=65536,t=3,p=2$BpLnfgDsc2WD8F2q$o/vzA4myCqZZ36bUGsDY//8mKUYNZZaR0t4MFFSs+iM"
email: james.dean@authelia.com email: james.dean@authelia.com
disabled: false
``` ```
## Passwords ## Passwords

View File

@ -145,6 +145,10 @@ func (m *DatabaseModel) ReadToFileUserDatabase(db *FileUserDatabase) (err error)
var udm *DatabaseUserDetails var udm *DatabaseUserDetails
for user, details := range m.Users { for user, details := range m.Users {
if details.Disabled {
continue
}
if udm, err = details.ToDatabaseUserDetailsModel(user); err != nil { if udm, err = details.ToDatabaseUserDetailsModel(user); err != nil {
return fmt.Errorf("failed to parse hash for user '%s': %w", user, err) return fmt.Errorf("failed to parse hash for user '%s': %w", user, err)
} }
@ -206,6 +210,7 @@ type UserDetailsModel struct {
DisplayName string `yaml:"displayname" valid:"required"` DisplayName string `yaml:"displayname" valid:"required"`
Email string `yaml:"email"` Email string `yaml:"email"`
Groups []string `yaml:"groups"` Groups []string `yaml:"groups"`
Disabled bool `yaml:"disabled"`
} }
// ToDatabaseUserDetailsModel converts a UserDetailsModel into a *DatabaseUserDetails. // ToDatabaseUserDetailsModel converts a UserDetailsModel into a *DatabaseUserDetails.