feat(backend): enable disabling of basic authentication (#13169)

* !feat(backend): disable basic authentication by default

* align PR

* add PR number

* fix schema creation/discovery

* mask basic auth

* fix error code

* reduce diff

* adjust changelog message

* fix test (needs basic auth which is now off by default)

* switch to default on; retain warning

* update test for new default

* fix assertation
This commit is contained in:
Matthias Mair authored and GitHub committed 2026-11-10 13:32:38 +11:00
1 parent be9639266d
commit a8a867400d
15 files changed
+90 -5

No files matched your search

+5 -1
View File
@@ -49,6 +49,10 @@ Token authentication is recommended as it provides much faster API access and is
Users can authenticate against the API using basic authentication - specifically a valid combination of `username` and `password` credentials.
!!! warning "Can be disabled"
Basic authentication can be disabled. This is controlled by the setting `INVENTREE_BASIC_AUTH_ENABLED` (or `basic_auth_enabled` in the [configuration file](../start/config.md#authentication)) to `False`. A warning ([INVE-W18](../settings/error_codes.md#inve-w18)) is logged and shown to staff users while it is enabled.
Basic authentication attempts might run into rate limits during authentication on busy instances, as this is a likely place of attacks. Prefer Token or OAuth2 authentication instead.
!!! warning "Multi factor authentication"
@@ -63,7 +67,7 @@ Each user is assigned an authentication token which can be used to access the AP
#### Requesting a Token
If a user does not already have an access token, they can request one via the user interface under the security user settings or the API interface, using a basic authentication request.
If a user does not already have an access token, they can request one via the user interface under the security user settings or the API interface, using a basic authentication request (only if [basic authentication](#basic-auth) is enabled).
!!! warning "Tokens are only available once"
Regardless of the request path used to obtain the token, it will only be displayed or provided once. Ensure that you copy and store it securely when it is first issued. Requesting a token with the same name will re-issue a new token, invalidating all previous ones of the same name.
+7
View File
@@ -262,6 +262,13 @@ The `middleware` list provided in the configuration file does not include the au
The middleware has been added automatically. To remove this warning, add it to the `middleware` list in your configuration file (after `django_structlog.middlewares.RequestMiddleware`).
#### INVE-W18
**Basic authentication is enabled - Backend**
Basic (username:password) authentication against the API is enabled via the `INVENTREE_BASIC_AUTH_ENABLED` / `basic_auth_enabled` setting. Sending the user password with every request increases the impact of leaked credentials and makes the API a simpler target for brute-force attacks. Basic authentication also bypasses the interactive login flow and does not work for users with multi-factor authentication enabled.
It is recommended to disable basic authentication and use [Token or OAuth2 authentication](../api/index.md#authentication) instead - see the [Authentication settings](../start/config.md#authentication).
#### INVE-W20
**Password authentication not allowed due to MFA - Backend**
+1
View File
@@ -453,6 +453,7 @@ InvenTree provides allowance for additional sign-in options. The following optio
{{ configsetting("INVENTREE_MFA_ENABLED") }} Enable multi-factor authentication support for the InvenTree server |
{{ configsetting("INVENTREE_MFA_SUPPORTED_TYPES") }} List of supported multi-factor authentication types |
{{ configsetting("INVENTREE_USE_JWT") }} Enable support for JSON Web Tokens (JWT) for authentication |
{{ configsetting("INVENTREE_BASIC_AUTH_ENABLED") }} Enable/Disable basic (username:password) authentication against the API. See [Basic Auth](../api/index.md#basic-auth) |
### Single Sign On