Use base64 encoded user name as their base dir

This is safe in all circumstance and leaves it up to the auth backend to
use whatever name they like for authentication.
This commit is contained in:
Conrad Hoffmann 2022-03-10 17:41:30 +01:00
parent 04be038c05
commit 07c19a6f6c

View File

@ -45,8 +45,8 @@ func (b *filesystemBackend) pathForContext(ctx context.Context) (string, error)
if !ok {
panic("Invalid data in auth context!")
}
//TODO sanitize user name or at least check if valid dir name?
path := filepath.Join(b.path, authCtx.UserName)
userDir := base64.RawStdEncoding.EncodeToString([]byte(authCtx.UserName))
path := filepath.Join(b.path, userDir)
_, err := os.Stat(path)
if os.IsNotExist(err) {