This drastically improves the user feedback surrounding rate limited
endpoints displaying information about how long the user should wait.
This also drastically improves the related tooling including adding a
react hook and go funcs to ensure the desired outcome is always
achieved.
Adds the `--config.filters.template.delimiter.left` and
`--config.filters.template.delimiter.right` options which customize the
delimiters used by the template file filter, allowing configuration
files to remain valid for their own file type so they can be linted.
This does not address validation against a schema.
In addition the `--config.experimental.filters` flag is renamed to
`--config.filters`, and the deprecated `expand-env` filter is removed in
favor of the `template` filter.
---------
Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
Co-authored-by: Amir Zarrinkafsh <3339418+nightah@users.noreply.github.com>
Adds the config.filters.values option and
X_AUTHELIA_CONFIG_FILTERS_VALUES environment variable to load YAML,
JSON, or TOML values files which are deep-merged in order and exposed to
the template filter as .Values, similar to Helm.
Exported symbols are documented inconsistently and nothing enforces it.
`revive` ships an `exported` rule which would cover part of this,
however the `revive` settings only specify `confidence` and declare no
rules, and golangci-lint v2 runs no `revive` rules at all unless they
are listed, so the gap went unnoticed. `godoclint` is enabled in
preference to configuring `revive` because its rules are individually
selectable, which allows requiring documentation without also adopting
the naming and stuttering checks.
The `require-doc`, `require-pkg-doc` and `require-stdlib-doclink` rules
are enabled alongside the default set and `no-unused-link`. `max-len`
remains disabled as its 77 character default conflicts with the
documentation already in the tree. Test files are excluded because
golangci-lint forces `require-doc` to include them regardless of the
linter configuration, which would otherwise require documentation for
every exported test helper.
This documents 681 exported symbols, adds a package comment to the 34
packages which lack one, and converts 131 plain text references to
standard library identifiers into doc links. Packages of more than one
file carry their comment in `doc.go` following the existing
`experimental/embed/doc.go`, and the single file command packages carry
it above `package main`.
`mockgen` is invoked with `-write_package_comment=false` as the package
comment it writes into the generated mocks is a second package comment
for `internal/authentication` and `internal/notification`. golangci-lint
applies `single-pkg-doc` to test files even though `require-doc` skips
them, so the generated comment cannot satisfy the requirement but does
conflict with the comment which does.
The JSON schemas are regenerated as `authelia-gen` sources the
descriptions of the `internal/configuration/schema` types from their
comments.
Additionally `issues.exclude-dirs` is replaced with
`linters.exclusions.paths` as the former is not part of the version 2
configuration schema. It was silently ignored, so `internal/mocks` was
never excluded and `golangci-lint config verify` failed.
Documenting `ValidateExtra` exposed an inconsistency in it. A single
valued extra attribute whose value has a known type that isn't the
configured type is rejected, however the equivalent multi valued case
fell through the type switch and returned no error, so an `integer`
attribute holding strings validated successfully. The multi valued
branch now returns an error in the same way the single valued branch
does. A regression test covers a multi valued attribute holding strings
against an `integer` `value_type` alongside the existing compatible
cases.
Signed-off-by: Amir Zarrinkafsh <3339418+nightah@users.noreply.github.com>
This fixes a choice that was made early in the development lifecycle of
v4. Effectively it hardens both the key derivation process for the
encryption key for storage by using HKDF which is purpose built for
deriving this kind of key, and also implements a column specific
additional authenticated data measure. Using the AAD effectively
prevents data from one column being moved to another column should
someone have access to the underlying database. At the present time none
of the columns used would theoretically have any meaningful affect
however this is a simple hardening measure that can be implemented now
to prevent the possibility now or in the future. It should also be noted
the use of encryption on the database is a defense in depth decision we
made, and this just hardens this implementation even more.
This excludes the HTTP 200 OK status code from several rate limits and
generally refactors the rate limiters. In addition it includes endpoints
that may benefit in rate limiting in certain scenarios.
---------
Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
Co-authored-by: Amir Zarrinkafsh <3339418+nightah@users.noreply.github.com>
This adds a lot of tests to Authelia's backend, with the intention of
bringing us above 80% coverage and attaining the OpenSSF Silver rating.
Closes#6744
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Duo MFA responses now include expiration, transaction ID and
verification code.
* TOTP export can produce per-user PNG images.
* New certificate-pool factory support for customizable system cert
loading.
* **Bug Fixes**
* Unified clock usage across auth, consent, OAuth2/OIDC, sessions and
2FA for consistent timestamps and expiries.
* **Refactor**
* Centralized provider initialization and standardized random/clock
construction; improved Duo error handling and logging; CLI I/O
decoupled.
* **Chores**
* CLI exit codes adjusted to treat config-creation as successful.
* **Tests**
* Added/updated tests for crypto, debug, Duo, TOTP, OAuth2/OIDC and many
CLI flows.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
Co-authored-by: Amir Zarrinkafsh <3339418+nightah@users.noreply.github.com>
This fixes an issue where the regulation max_retries value does not
match the documented default. Effectively the documentation is wrong as
this has never been the default however it makes more sense to set it to
the documented value.
This allows a relaxed cache policy for the MDS3. The strict mode is recommended but this allows for a more relaxed update profile.
Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
This adds a highly experimental option for developers looking to embed Authelia within another go binary.
Closes#5803
Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>