mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-02 03:30:54 +00:00
feat(backend): add oauth2 (#9333)
* feat(backend): add oauth2 * fix import * Add inventree roles * refactor to make lookup more efficient * fix single scope definitions * cleanup * fix schema * reduce auth methods * fix OAuth validator * re-enable token and basic auth again * Add models to role mapping * change scope args * add debug step for schema generation * add oauth config for schema generation * improve token -> permission mapping * fix req * extend checks to ensure normal auth also passes * fix api version * fix ignore * fix rule name * bump api version * remove old modelref * move scope definition * make test results easier to work with * add tests to ensure scopes are in sync with rulesets * fix docstring * fix various permissions and their mapping to oauth * refactor * simplify * fix permission mapping * ignore failure cases * fix unauthenticated access * flag oAuth2 till it is done * Add OIDC support * add RSA key generation and docs * fix test * move imports * update ignore * feat(backend): Add API Schema stats * add scope stats * fix name * fix scope output * feat(backend): test custom command * add warning for unknown scopes * reduce diff in launch.json * cleanup diff * add error code for ruleset / scope issues * update structure * add oauth docs * add experimetnal feature docs * simplify metadata endpoint * add importer model * refactor(backend): simplify metadata endpoint * fix imports * simplify even more * remove unneeded schema tooling * fix permission mappings * fix testing * fix role calculations * fix mapping * remove importer change to unblock this * remove importer scope everywhere * fix merge conflict in test * add missing models * fix api version * fix OASToken matcher * revert permission class change * reduce size of test log by writing schema * fix permissions * fix file path * extend schema to remove need for TokenMatchesOASRequirements * cleanup permissions file * add base object permission
This commit is contained in:
@ -218,31 +218,35 @@ You can either specify the password directly using `INVENTREE_ADMIN_PASSWORD`, o
|
||||
!!! info "Administrator Account"
|
||||
Providing `INVENTREE_ADMIN` credentials will result in the provided account being created with *superuser* permissions when InvenTree is started.
|
||||
|
||||
## Secret Key
|
||||
## Secret Key material
|
||||
|
||||
InvenTree requires a secret key for providing cryptographic signing - this should be a secret (and unpredictable) value.
|
||||
InvenTree requires secret keys for providing cryptographic signing and oidc private keys- this should be a secret (and unpredictable) value.
|
||||
|
||||
!!! info "Auto-Generated Key"
|
||||
If none of the following options are specified, InvenTree will automatically generate a secret key file (stored in `secret_key.txt`) on first run.
|
||||
!!! info "Auto-Generated material"
|
||||
If none of the following options are specified, InvenTree will automatically generate a secret key file (stored in `secret_key.txt`) and a oidc key file (stored in `oidc.pem`) on first run.
|
||||
|
||||
The secret key can be provided in multiple ways, with the following (descending) priorities:
|
||||
The secret key material can be provided in multiple ways, with the following (descending) priorities:
|
||||
|
||||
**Pass Secret Key via Environment Variable**
|
||||
**Pass Secret Key Material via Environment Variable**
|
||||
|
||||
A secret key string can be passed directly using the environment variable `INVENTREE_SECRET_KEY`
|
||||
A oidc private key can be passed directly using the environment variable `INVENTREE_OIDC_PRIVATE_KEY`
|
||||
|
||||
**Pass Secret Key File via Environment Variable**
|
||||
**Pass Secret Key Material File via Environment Variable**
|
||||
|
||||
A file containing the secret key can be passed via the environment variable `INVENTREE_SECRET_KEY_FILE`
|
||||
A PEM-encoded file containing the oidc private key can be passed via the environment variable `INVENTREE_OIDC_PRIVATE_KEY_FILE`
|
||||
|
||||
**Fallback to Default Secret Key File**
|
||||
**Fallback to Default Secret Key Material**
|
||||
|
||||
If not specified via environment variables, the fallback secret_key file (automatically generated as part of InvenTree installation) will be used.
|
||||
If not specified via environment variables, the fallback files (automatically generated as part of InvenTree installation) will be used.
|
||||
|
||||
| Environment Variable | Configuration File | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| INVENTREE_SECRET_KEY | secret_key | Raw secret key value | *Not specified* |
|
||||
| INVENTREE_SECRET_KEY_FILE | secret_key_file | File containing secret key value | *Not specified* |
|
||||
| INVENTREE_OIDC_PRIVATE_KEY | oidc_private_key | Raw private key value | *Not specified* |
|
||||
| INVENTREE_OIDC_PRIVATE_KEY_FILE | oidc_private_key_file | File containing private key value in PEM format | *Not specified* |
|
||||
|
||||
## Database Options
|
||||
|
||||
|
Reference in New Issue
Block a user