Skip to content

Fix handling of base64url#20

Merged
divarvel merged 5 commits into
eclipse-biscuit:mainfrom
saoirse-a:fix-base64url
Apr 23, 2026
Merged

Fix handling of base64url#20
divarvel merged 5 commits into
eclipse-biscuit:mainfrom
saoirse-a:fix-base64url

Conversation

@saoirse-a
Copy link
Copy Markdown
Contributor

@saoirse-a saoirse-a commented Apr 22, 2026

This fixes the handling of base64url by accepting base64url without padding (though also accepting with padding) and producing without padding - the standard for base64url. Previously, the library always produced base64url with padding bytes and would not accept base64url without padding bytes.

Additionally, in Swift 6.3 there is now built-in support in Foundation for base64url encoding (though not decoding), so we opportunistically use that implementation (which should be faster) when building for Swift 6.3 and running on a platform with the correct Foundation.

Because of the compatibility complexity of base64url in Swift, we've moved the code to its own module and added tests.

This fixes the handling of base64url by accepting base64url without
padding (though also accepting *with* padding) and producing without
padding - the standard for base64url. Previously, the library always
produced base64url with padding bytes and would not accept base64url
without padding byes.

Additionally, in Swift 6.3 there is now built-in support in Foundation
for base64url encoding (though not decoding), so we opportunistically
use that implementation (which should be faster) when building for Swift
6.3 and running on a platform with the correct Foundation.

Because of the compatibility complexity of base64url in Swift, we've
moved the code to its own module and added tests.
Copy link
Copy Markdown
Contributor

@divarvel divarvel left a comment

Choose a reason for hiding this comment

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

biscuit-rust accepts both padded and unpadded base64 url, and still emits padded base64, because of (as far as i remember) biscuit-go only accepting padded b64.

do you know where swift’s b64 support stands wrt malleability?

@saoirse-a
Copy link
Copy Markdown
Contributor Author

Changed to emit padding bytes

@divarvel divarvel merged commit f7ef0ac into eclipse-biscuit:main Apr 23, 2026
4 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.

2 participants