biscuit-java icon indicating copy to clipboard operation
biscuit-java copied to clipboard

codecs: add base64 URL encoding without paddin

Open KannarFr opened this issue 2 months ago • 3 comments

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.

KannarFr avatar Oct 15 '25 15:10 KannarFr