mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-14 11:05:41 +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:
@ -37,6 +37,7 @@ ENV INVENTREE_BACKEND_DIR="${INVENTREE_HOME}/src/backend"
|
||||
# InvenTree configuration files
|
||||
ENV INVENTREE_CONFIG_FILE="${INVENTREE_DATA_DIR}/config.yaml"
|
||||
ENV INVENTREE_SECRET_KEY_FILE="${INVENTREE_DATA_DIR}/secret_key.txt"
|
||||
ENV INVENTREE_OIDC_PRIVATE_KEY_FILE="${INVENTREE_DATA_DIR}/oidc.pem"
|
||||
ENV INVENTREE_PLUGIN_FILE="${INVENTREE_DATA_DIR}/plugins.txt"
|
||||
|
||||
# Worker configuration (can be altered by user)
|
||||
|
@ -181,6 +181,7 @@ function detect_envs() {
|
||||
export INVENTREE_PLUGINS_ENABLED=true
|
||||
export INVENTREE_PLUGIN_FILE=${CONF_DIR}/plugins.txt
|
||||
export INVENTREE_SECRET_KEY_FILE=${CONF_DIR}/secret_key.txt
|
||||
export INVENTREE_OIDC_PRIVATE_KEY_FILE=${CONF_DIR}/oidc.pem
|
||||
|
||||
export INVENTREE_DB_ENGINE=${INVENTREE_DB_ENGINE:-sqlite3}
|
||||
export INVENTREE_DB_NAME=${INVENTREE_DB_NAME:-${DATA_DIR}/database.sqlite3}
|
||||
@ -339,6 +340,8 @@ function set_env() {
|
||||
sed -i s=#plugin_file:\ \'/path/to/plugins.txt\'=plugin_file:\ \'${INVENTREE_PLUGIN_FILE}\'=g ${INVENTREE_CONFIG_FILE}
|
||||
# Secret key file
|
||||
sed -i s=#secret_key_file:\ \'/etc/inventree/secret_key.txt\'=secret_key_file:\ \'${INVENTREE_SECRET_KEY_FILE}\'=g ${INVENTREE_CONFIG_FILE}
|
||||
# OIDC private key file
|
||||
sed -i s=#oidc_private_key_file:\ \'/etc/inventree/oidc.pem\'=oidc_private_key_file:\ \'${INVENTREE_OIDC_PRIVATE_KEY_FILE}\'=g ${INVENTREE_CONFIG_FILE}
|
||||
# Debug mode
|
||||
sed -i s=debug:\ True=debug:\ False=g ${INVENTREE_CONFIG_FILE}
|
||||
|
||||
|
Reference in New Issue
Block a user