Skip to content

Increase max payload length to 128000 bytes#93

Merged
lepture merged 2 commits intoauthlib:mainfrom
steverweber:main
Apr 30, 2026
Merged

Increase max payload length to 128000 bytes#93
lepture merged 2 commits intoauthlib:mainfrom
steverweber:main

Conversation

@steverweber
Copy link
Copy Markdown
Contributor

solve #92

some organizations have large jwt claims that have been in the 32k range.

I feel 128k is safe and unlikely to be hit unless something is very wrong on the auth provider end.

some organizations have large jwt claims that have been in the 32k range.
Copilot AI review requested due to automatic review settings April 20, 2026 14:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR increases the default maximum allowed JWS payload segment length in the RFC7515 registry to support larger JWT/JWS claims (per issue #92) without triggering ExceededSizeError during deserialization.

Changes:

  • Bump JWSRegistry.max_payload_length from 8000 bytes to 128000 bytes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 51 to +52
#: max payload content's size in bytes
max_payload_length: int = 8000
max_payload_length: int = 128000
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raising the default max_payload_length to 128000 changes JWS size-validation behavior and breaks existing unit tests that currently expect an ExceededSizeError for ~13KB base64url payload segments (e.g. tests/jws/test_compact.py::test_payload_exceeded_size_error uses a 10,000-byte payload before encoding). Please update the test vectors to exceed the new limit (ideally derived from registry.max_payload_length to avoid future drift).

Copilot uses AI. Check for mistakes.
max_header_length: int = 512
#: max payload content's size in bytes
max_payload_length: int = 8000
max_payload_length: int = 128000
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

128000 is a bit ambiguous (decimal KB vs KiB). Elsewhere the codebase uses * 1024 or powers of two for byte-size limits (e.g. JWE ciphertext limit is 65536 # 64KB). Consider expressing this as 128 * 1024 (131072) or adding an inline comment clarifying that the intent is exactly 128000 bytes.

Suggested change
max_payload_length: int = 128000
max_payload_length: int = 128000 # exactly 128000 bytes

Copilot uses AI. Check for mistakes.
@lepture
Copy link
Copy Markdown
Member

lepture commented Apr 27, 2026

@steverweber hi, can you fix the test errors?

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (6ae237e) to head (bb7c86c).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #93   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           47        47           
  Lines         2929      2929           
  Branches       339       339           
=========================================
  Hits          2929      2929           
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lepture lepture merged commit fd87015 into authlib:main Apr 30, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants