biscuit-java
biscuit-java copied to clipboard
codecs: add base64 URL encoding without paddin
What
Adds serializeBase64UrlNoPadding() methods to embed biscuit tokens in URL parameters without padding characters safely (=).
Why
Padding characters in base64-encoded tokens can cause issues when used in URLs. This was mentioned in code comments about needing custom encoders to prevent Java's default padding in URL contexts.
How
- Added serializeBase64UrlNoPadding() to Biscuit and UnverifiedBiscuit classes
- Uses Java's built-in Base64.getUrlEncoder().withoutPadding()
- Existing fromBase64Url() already handles both formats automatically
- Updated docs to clarify that padded/unpadded strings are both accepted
Example
String token = biscuit.serializeBase64UrlNoPadding();
String url = "https://api.example.com/auth?token=" + token;
// No special encoding needed - works directly in URLs
Fully backward compatible, no breaking changes.