summaryrefslogtreecommitdiff
path: root/internal/authentication/file_user_provider.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/authentication/file_user_provider.go')
-rw-r--r--internal/authentication/file_user_provider.go31
1 files changed, 29 insertions, 2 deletions
diff --git a/internal/authentication/file_user_provider.go b/internal/authentication/file_user_provider.go
index 4c92c7cdf..02e0faa81 100644
--- a/internal/authentication/file_user_provider.go
+++ b/internal/authentication/file_user_provider.go
@@ -16,6 +16,7 @@ import (
"github.com/go-crypt/crypt/algorithm/shacrypt"
"github.com/authelia/authelia/v4/internal/configuration/schema"
+ "github.com/authelia/authelia/v4/internal/expression"
"github.com/authelia/authelia/v4/internal/logging"
)
@@ -34,10 +35,22 @@ func NewFileUserProvider(config *schema.AuthenticationBackendFile) (provider *Fi
config: config,
mutex: &sync.Mutex{},
timeoutReload: time.Now().Add(-1 * time.Second),
- database: NewFileUserDatabase(config.Path, config.Search.Email, config.Search.CaseInsensitive),
+ database: NewFileUserDatabase(config.Path, config.Search.Email, config.Search.CaseInsensitive, getExtra(config)),
}
}
+func getExtra(config *schema.AuthenticationBackendFile) (extra map[string]expression.ExtraAttribute) {
+ extra = make(map[string]expression.ExtraAttribute, len(config.ExtraAttributes))
+
+ if len(config.ExtraAttributes) != 0 {
+ for name, attribute := range config.ExtraAttributes {
+ extra[name] = attribute
+ }
+ }
+
+ return extra
+}
+
// Reload the database.
func (p *FileUserProvider) Reload() (reloaded bool, err error) {
now := time.Now()
@@ -94,6 +107,20 @@ func (p *FileUserProvider) GetDetails(username string) (details *UserDetails, er
return d.ToUserDetails(), nil
}
+func (p *FileUserProvider) GetDetailsExtended(username string) (details *UserDetailsExtended, err error) {
+ var d FileUserDatabaseUserDetails
+
+ if d, err = p.database.GetUserDetails(username); err != nil {
+ return nil, err
+ }
+
+ if d.Disabled {
+ return nil, ErrUserNotFound
+ }
+
+ return d.ToExtendedUserDetails(), nil
+}
+
// UpdatePassword update the password of the given user.
func (p *FileUserProvider) UpdatePassword(username string, newPassword string) (err error) {
var details FileUserDatabaseUserDetails
@@ -142,7 +169,7 @@ func (p *FileUserProvider) StartupCheck() (err error) {
}
if p.database == nil {
- p.database = NewFileUserDatabase(p.config.Path, p.config.Search.Email, p.config.Search.CaseInsensitive)
+ p.database = NewFileUserDatabase(p.config.Path, p.config.Search.Email, p.config.Search.CaseInsensitive, getExtra(p.config))
}
if err = p.database.Load(); err != nil {