Skip to content

feat(backend): extend token model - #13139

Open
matmair wants to merge 19 commits into
inventree:masterfrom
matmair:backend-extend-token-model
Open

matmair wants to merge 19 commits into
inventree:masterfrom
matmair:backend-extend-token-model

Conversation

@matmair

@matmair matmair commented Oct 31, 2026

Copy link
Copy Markdown
Member

Enables better tracing where tokens come from and allows for setting (and rotating) peppers

@matmair matmair added this to the 1.7.0 milestone Oct 31, 2026
@matmair matmair self-assigned this Oct 31, 2026
@matmair matmair added the api Relates to the API label Oct 31, 2026
@netlify

netlify Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 703727c
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6afa40b28be1f00375deab2a
😎 Deploy Preview https://deploy-preview-13139--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 94 (🔴 down 1 from production)
Accessibility: 82 (no change from production)
Best Practices: 92 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.07143% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.28%. Comparing base (a87489c) to head (703727c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #13139      +/-   ##
==========================================
- Coverage   90.34%   90.28%   -0.07%     
==========================================
  Files         901      897       -4     
  Lines       83191    83220      +29     
  Branches     4272     4260      -12     
==========================================
- Hits        75160    75133      -27     
- Misses       7017     7078      +61     
+ Partials     1014     1009       -5     
Flag Coverage Δ
backend 93.77% <91.07%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend Apps 94.24% <86.30%> (-0.13%) ⬇️
Backend General 95.47% <100.00%> (+<0.01%) ⬆️
Frontend 77.40% <ø> (-0.05%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SchrodingersGat SchrodingersGat added enhancement This is an suggested enhancement or new feature security Relates to a security issue setup Relates to the InvenTree setup / installation process labels Nov 1, 2026
@matmair

matmair commented Nov 1, 2026

Copy link
Copy Markdown
Member Author

@SchrodingersGat ready for review and merge

@matmair matmair changed the title backend: extend token model feat(backend): extend token model Nov 1, 2026
@SchrodingersGat

Copy link
Copy Markdown
Member

Some thoughts below on how this could be a bit more "user friendly"

Pepper Generation

Currently there is no way for the sysadmin to actually generate a new pepper. As far as I can tell the docs doesn't cover this either.

Suggestion: An invoke task to generate a new random pepper value, with an option to either drop or keep the existing pepper value as legacy. This new command should also be covered in the docs. Any error or warning messages should reference it too (if needed)

This task would also serve as the method for rotating out peppers if needed

Default Pepper

By default, no pepper is available - and thus for any new (or migrating) instances there will be a lot of warning messages. Can we create a default pepper file, which is created on load (only if env var or pepper file does not exist). This mirrors the way that the secret key file is generated if it does not already exist.

This will mean that any new installs, or old installs migrating to the new code, will automatically have a "default" randomly generated pepper value.

Empty Pepper Values

It appears that empty pepper values can sneak in to get_api_token_peppers - update this to ignore empty or null values.

@matmair

matmair commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

I can add such a command but these values need to be backed up for a correct restore so not really a fan of a silent mechanism

@SchrodingersGat SchrodingersGat removed this from the 1.7.0 milestone Nov 2, 2026
@SchrodingersGat SchrodingersGat added this to the 1.8.0 milestone Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Relates to the API enhancement This is an suggested enhancement or new feature security Relates to a security issue setup Relates to the InvenTree setup / installation process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants