2020-02-29 07:43:59 +07:00
|
|
|
---
|
|
|
|
layout: default
|
|
|
|
title: File
|
2021-08-03 04:23:40 +07:00
|
|
|
parent: Authentication Backends
|
2020-02-29 07:43:59 +07:00
|
|
|
grand_parent: Configuration
|
|
|
|
nav_order: 1
|
|
|
|
---
|
|
|
|
|
|
|
|
# File
|
|
|
|
|
|
|
|
**Authelia** supports a file as a users database.
|
|
|
|
|
2021-04-11 18:25:03 +07:00
|
|
|
|
2020-02-29 07:43:59 +07:00
|
|
|
## Configuration
|
|
|
|
|
|
|
|
Configuring Authelia to use a file is done by specifying the path to the
|
|
|
|
file in the configuration file.
|
|
|
|
|
2020-04-11 11:46:07 +07:00
|
|
|
```yaml
|
|
|
|
authentication_backend:
|
|
|
|
disable_reset_password: false
|
|
|
|
file:
|
2020-06-17 13:25:35 +07:00
|
|
|
path: /config/users.yml
|
2020-04-11 11:46:07 +07:00
|
|
|
password:
|
|
|
|
algorithm: argon2id
|
2022-06-02 06:18:45 +07:00
|
|
|
iterations: 3
|
2020-04-11 11:46:07 +07:00
|
|
|
salt_length: 16
|
2022-06-02 06:18:45 +07:00
|
|
|
key_length: 32
|
|
|
|
parallelism: 4
|
2021-03-03 16:19:28 +07:00
|
|
|
memory: 64
|
2020-04-11 11:46:07 +07:00
|
|
|
```
|
|
|
|
|
2020-02-29 07:43:59 +07:00
|
|
|
## Format
|
|
|
|
|
2020-03-06 08:38:02 +07:00
|
|
|
The format of the users file is as follows.
|
2020-02-29 07:43:59 +07:00
|
|
|
|
2020-04-11 11:46:07 +07:00
|
|
|
```yaml
|
|
|
|
users:
|
|
|
|
john:
|
2020-06-19 17:50:21 +07:00
|
|
|
displayname: "John Doe"
|
2020-04-11 11:46:07 +07:00
|
|
|
password: "$argon2id$v=19$m=65536,t=3,p=2$BpLnfgDsc2WD8F2q$o/vzA4myCqZZ36bUGsDY//8mKUYNZZaR0t4MFFSs+iM"
|
|
|
|
email: john.doe@authelia.com
|
|
|
|
groups:
|
|
|
|
- admins
|
|
|
|
- dev
|
|
|
|
harry:
|
2020-06-19 17:50:21 +07:00
|
|
|
displayname: "Harry Potter"
|
2020-04-11 11:46:07 +07:00
|
|
|
password: "$argon2id$v=19$m=65536,t=3,p=2$BpLnfgDsc2WD8F2q$o/vzA4myCqZZ36bUGsDY//8mKUYNZZaR0t4MFFSs+iM"
|
|
|
|
email: harry.potter@authelia.com
|
|
|
|
groups: []
|
|
|
|
bob:
|
2020-06-19 17:50:21 +07:00
|
|
|
displayname: "Bob Dylan"
|
2020-04-11 11:46:07 +07:00
|
|
|
password: "$argon2id$v=19$m=65536,t=3,p=2$BpLnfgDsc2WD8F2q$o/vzA4myCqZZ36bUGsDY//8mKUYNZZaR0t4MFFSs+iM"
|
|
|
|
email: bob.dylan@authelia.com
|
|
|
|
groups:
|
|
|
|
- dev
|
|
|
|
james:
|
2020-06-19 17:50:21 +07:00
|
|
|
displayname: "James Dean"
|
2020-04-11 11:46:07 +07:00
|
|
|
password: "$argon2id$v=19$m=65536,t=3,p=2$BpLnfgDsc2WD8F2q$o/vzA4myCqZZ36bUGsDY//8mKUYNZZaR0t4MFFSs+iM"
|
|
|
|
email: james.dean@authelia.com
|
|
|
|
```
|
2020-02-29 07:43:59 +07:00
|
|
|
|
|
|
|
This file should be set with read/write permissions as it could be updated by users
|
|
|
|
resetting their passwords.
|
2020-03-09 09:02:14 +07:00
|
|
|
|
2020-03-06 15:40:56 +07:00
|
|
|
|
2021-04-11 18:25:03 +07:00
|
|
|
## Options
|
|
|
|
|
|
|
|
### path
|
|
|
|
<div markdown="1">
|
|
|
|
type: string (path)
|
2021-09-16 07:20:42 +07:00
|
|
|
{: .label .label-config .label-purple }
|
2021-04-11 18:25:03 +07:00
|
|
|
required: yes
|
|
|
|
{: .label .label-config .label-red }
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
### password
|
|
|
|
|
|
|
|
#### algorithm
|
|
|
|
<div markdown="1">
|
|
|
|
type: string
|
2021-09-16 07:20:42 +07:00
|
|
|
{: .label .label-config .label-purple }
|
2021-04-11 18:25:03 +07:00
|
|
|
default: argon2id
|
|
|
|
{: .label .label-config .label-blue }
|
|
|
|
required: no
|
|
|
|
{: .label .label-config .label-green }
|
|
|
|
</div>
|
|
|
|
|
2022-05-12 06:44:37 +07:00
|
|
|
Controls the hashing algorithm used for hashing new passwords. Value must be one of `argon2id` or `sha512`.
|
2021-04-11 18:25:03 +07:00
|
|
|
|
|
|
|
|
|
|
|
#### iterations
|
|
|
|
<div markdown="1">
|
|
|
|
type: integer
|
|
|
|
{: .label .label-config .label-purple }
|
|
|
|
required: no
|
|
|
|
{: .label .label-config .label-green }
|
|
|
|
</div>
|
|
|
|
|
|
|
|
Controls the number of hashing iterations done by the other hashing settings.
|
|
|
|
|
2022-06-02 06:18:45 +07:00
|
|
|
When using `argon2id` the minimum is 3, which is also the recommended and default value.
|
2021-04-11 18:25:03 +07:00
|
|
|
|
2022-06-02 06:18:45 +07:00
|
|
|
When using `sha512` the minimum is 1000, and 50000 is the recommended and default value.
|
2021-04-11 18:25:03 +07:00
|
|
|
|
|
|
|
|
|
|
|
#### salt_length
|
|
|
|
<div markdown="1">
|
|
|
|
type: integer
|
2021-09-16 07:20:42 +07:00
|
|
|
{: .label .label-config .label-purple }
|
2021-04-11 18:25:03 +07:00
|
|
|
default: 16
|
|
|
|
{: .label .label-config .label-blue }
|
|
|
|
required: no
|
|
|
|
{: .label .label-config .label-green }
|
|
|
|
</div>
|
|
|
|
|
|
|
|
Controls the length of the random salt added to each password before hashing. It's recommended this value is set to 16,
|
|
|
|
and there is no documented reason why you'd set it to anything other than this, however the minimum is 8.
|
|
|
|
|
|
|
|
|
|
|
|
#### parallelism
|
|
|
|
<div markdown="1">
|
|
|
|
type: integer
|
2021-09-16 07:20:42 +07:00
|
|
|
{: .label .label-config .label-purple }
|
2022-06-02 06:18:45 +07:00
|
|
|
default: 4
|
2021-04-11 18:25:03 +07:00
|
|
|
{: .label .label-config .label-blue }
|
|
|
|
required: no
|
|
|
|
{: .label .label-config .label-green }
|
|
|
|
</div>
|
|
|
|
|
|
|
|
This setting is specific to `argon2id` and unused with `sha512`. Sets the number of threads used when hashing passwords,
|
|
|
|
which affects the effective cost of hashing.
|
|
|
|
|
|
|
|
|
|
|
|
#### memory
|
2022-06-02 06:18:45 +07:00
|
|
|
<div markdown="1">
|
|
|
|
type: integer
|
|
|
|
{: .label .label-config .label-purple }
|
|
|
|
default: 64
|
|
|
|
{: .label .label-config .label-blue }
|
|
|
|
required: no
|
|
|
|
{: .label .label-config .label-green }
|
|
|
|
</div>
|
2021-04-11 18:25:03 +07:00
|
|
|
|
|
|
|
This setting is specific to `argon2id` and unused with `sha512`. Sets the amount of memory allocated to a single
|
|
|
|
password hashing action. This memory is released by go after the hashing process completes, however the operating system
|
|
|
|
may not reclaim it until it needs the memory which may make Authelia appear to be using more memory than it technically
|
|
|
|
is.
|
|
|
|
|
2020-02-29 07:43:59 +07:00
|
|
|
## Passwords
|
|
|
|
|
2020-03-06 08:38:02 +07:00
|
|
|
The file contains hashed passwords instead of plain text passwords for security reasons.
|
2020-02-29 07:43:59 +07:00
|
|
|
|
2021-04-11 18:25:03 +07:00
|
|
|
You can use Authelia binary or docker image to generate the hash of any password. The
|
|
|
|
hash-password command has many tunable options, you can view them with the
|
2020-03-06 08:38:02 +07:00
|
|
|
`authelia hash-password --help` command. For example if you wanted to improve the entropy
|
2021-04-11 18:25:03 +07:00
|
|
|
you could generate a 16 byte salt and provide it with the `--salt` flag.
|
2022-06-02 06:18:45 +07:00
|
|
|
Example: `authelia hash-password --salt abcdefghijklhijl -- 'yourpassword'`. For argon2id the salt must
|
2020-03-06 08:38:02 +07:00
|
|
|
always be valid for base64 decoding (characters a through z, A through Z, 0 through 9, and +/).
|
2020-02-29 07:43:59 +07:00
|
|
|
|
2020-12-16 07:07:51 +07:00
|
|
|
Passwords passed to `hash-password` should be single quoted if using special characters to prevent parameter substitution.
|
2020-03-06 08:38:02 +07:00
|
|
|
For instance to generate a hash with the docker image just run:
|
2020-02-29 07:43:59 +07:00
|
|
|
|
2022-06-02 06:18:45 +07:00
|
|
|
$ docker run authelia/authelia:latest authelia hash-password -- 'yourpassword'
|
2020-04-11 11:46:07 +07:00
|
|
|
Password hash: $argon2id$v=19$m=65536$3oc26byQuSkQqksq$zM1QiTvVPrMfV6BVLs2t4gM+af5IN7euO0VB6+Q8ZFs
|
2020-03-06 08:38:02 +07:00
|
|
|
|
2021-09-16 07:20:42 +07:00
|
|
|
You may also use the `--config` flag to point to your existing configuration. When used, the values defined in the config will be used instead.
|
|
|
|
|
2020-03-06 08:38:02 +07:00
|
|
|
Full CLI Help Documentation:
|
|
|
|
|
|
|
|
```
|
|
|
|
Hash a password to be used in file-based users database. Default algorithm is argon2id.
|
|
|
|
|
|
|
|
Usage:
|
2022-06-02 06:18:45 +07:00
|
|
|
authelia hash-password [flags] -- <password>
|
2020-03-06 08:38:02 +07:00
|
|
|
|
|
|
|
Flags:
|
2022-06-02 06:18:45 +07:00
|
|
|
-c, --config strings Configuration files
|
2020-03-06 08:38:02 +07:00
|
|
|
-h, --help help for hash-password
|
2022-06-02 06:18:45 +07:00
|
|
|
-i, --iterations int set the number of hashing iterations (default 3)
|
2020-03-06 08:38:02 +07:00
|
|
|
-k, --key-length int [argon2id] set the key length param (default 32)
|
2021-03-03 16:19:28 +07:00
|
|
|
-m, --memory int [argon2id] set the amount of memory param (in MB) (default 64)
|
2022-06-02 06:18:45 +07:00
|
|
|
-p, --parallelism int [argon2id] set the parallelism param (default 4)
|
2020-03-06 08:38:02 +07:00
|
|
|
-s, --salt string set the salt string
|
|
|
|
-l, --salt-length int set the auto-generated salt length (default 16)
|
2022-06-02 06:18:45 +07:00
|
|
|
-z, --sha512 use sha512 as the algorithm (changes iterations to 50000, change with -i)
|
2020-03-06 08:38:02 +07:00
|
|
|
```
|
|
|
|
|
2021-04-11 18:25:03 +07:00
|
|
|
### Password hash algorithm
|
2020-03-09 09:02:14 +07:00
|
|
|
|
2021-04-11 18:25:03 +07:00
|
|
|
The default hash algorithm is Argon2id version 19 with a salt. Argon2id is currently considered
|
|
|
|
the best hashing algorithm, and in 2015 won the
|
2020-03-06 08:38:02 +07:00
|
|
|
[Password Hashing Competition](https://en.wikipedia.org/wiki/Password_Hashing_Competition).
|
2021-04-11 18:25:03 +07:00
|
|
|
It benefits from customizable parameters allowing the cost of computing a hash to scale
|
|
|
|
into the future which makes it harder to brute-force. Argon2id was implemented due to community
|
2020-03-06 08:38:02 +07:00
|
|
|
feedback as you can see in this closed [issue](https://github.com/authelia/authelia/issues/577).
|
|
|
|
|
2021-04-11 18:25:03 +07:00
|
|
|
For backwards compatibility and user choice support for the SHA512 algorithm is still available.
|
|
|
|
While it's a reasonable hashing function given high enough iterations, as hardware improves it
|
2020-04-11 10:54:18 +07:00
|
|
|
has a higher chance of being brute-forced.
|
2020-03-06 08:38:02 +07:00
|
|
|
|
2021-04-11 18:25:03 +07:00
|
|
|
Hashes are identifiable as argon2id or SHA512 by their prefix of either `$argon2id$` and `$6$`
|
2020-03-06 08:38:02 +07:00
|
|
|
respectively, as described in this [wiki page](https://en.wikipedia.org/wiki/Crypt_(C)).
|
2020-03-06 15:40:56 +07:00
|
|
|
|
2020-04-11 10:54:18 +07:00
|
|
|
**Important Note:** When using argon2id Authelia will appear to remain using the memory allocated
|
|
|
|
to creating the hash. This is due to how [Go](https://golang.org/) allocates memory to the heap when
|
|
|
|
generating an argon2id hash. Go periodically garbage collects the heap, however this doesn't remove
|
|
|
|
the memory allocation, it keeps it allocated even though it's technically unused. Under memory
|
|
|
|
pressure the unused allocated memory will be reclaimed by the operating system, you can test
|
2021-04-11 18:25:03 +07:00
|
|
|
this on linux with:
|
2020-04-11 11:46:07 +07:00
|
|
|
|
|
|
|
$ stress-ng --vm-bytes $(awk '/MemFree/{printf "%d\n", $2 * 0.9;}' < /proc/meminfo)k --vm-keep -m 1
|
2021-04-11 18:25:03 +07:00
|
|
|
|
2020-04-11 10:54:18 +07:00
|
|
|
If this is not desirable we recommend investigating the following options in order of most to least secure:
|
2021-04-11 18:25:03 +07:00
|
|
|
1. using the [LDAP authentication provider](./ldap.md)
|
|
|
|
2. adjusting the [memory](#memory) parameter
|
|
|
|
3. changing the [algorithm](#algorithm)
|
|
|
|
|
2020-03-06 15:40:56 +07:00
|
|
|
### Password hash algorithm tuning
|
2021-04-11 18:25:03 +07:00
|
|
|
|
|
|
|
All algorithm tuning for Argon2id is supported. The only configuration variables that affect
|
2020-03-06 15:40:56 +07:00
|
|
|
SHA512 are iterations and salt length. The configuration variables are unique to the file
|
|
|
|
authentication provider, thus they all exist in a key under the file authentication configuration
|
2020-04-11 10:54:18 +07:00
|
|
|
key called `password`. We have set what are considered as sane and recommended defaults
|
2021-04-11 18:25:03 +07:00
|
|
|
to cater for a reasonable system, if you're unsure about which settings to tune, please see the
|
2020-03-09 09:02:14 +07:00
|
|
|
parameters below, or for a more in depth understanding see the referenced documentation in
|
|
|
|
[Argon2 links](./file.md#argon2-links).
|
|
|
|
|
2022-06-02 06:18:45 +07:00
|
|
|
#### Recommended Parameters: Argon2id
|
2020-03-09 09:02:14 +07:00
|
|
|
|
2022-06-02 06:18:45 +07:00
|
|
|
This table is adapted from [RFC9106 Parameter Choice]:
|
2020-03-09 09:02:14 +07:00
|
|
|
|
2022-06-02 06:18:45 +07:00
|
|
|
| Situation | Iterations (t) | Parallelism (p) | Memory (m) | Salt Size | Key Size |
|
|
|
|
|:-----------:|:--------------:|:---------------:|:----------:|:---------:|:--------:|
|
|
|
|
| Low Memory | 3 | 4 | 64 | 16 | 32 |
|
|
|
|
| Recommended | 1 | 4 | 2048 | 16 | 32 |
|
2020-03-09 09:02:14 +07:00
|
|
|
|
2021-04-11 18:25:03 +07:00
|
|
|
## Argon2 Links
|
|
|
|
|
2022-06-02 06:18:45 +07:00
|
|
|
- [Go Documentation](https://godoc.org/golang.org/x/crypto/argon2)
|
|
|
|
- Argon2 Specification [RFC9106]
|
|
|
|
- [OWASP Password Storage Cheatsheet]
|
2020-03-09 09:02:14 +07:00
|
|
|
|
2022-06-02 06:18:45 +07:00
|
|
|
[RFC9106]: https://www.rfc-editor.org/rfc/rfc9106.html
|
|
|
|
[RFC9106 Parameter Choice]: https://www.rfc-editor.org/rfc/rfc9106.html#section-4
|
|
|
|
[OWASP Password Storage Cheatsheet]: https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
|