Fix handling of base64url#20
Merged
Merged
Conversation
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.
divarvel
approved these changes
Apr 22, 2026
Contributor
divarvel
left a comment
There was a problem hiding this comment.
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?
Contributor
Author
|
Changed to emit padding bytes |
3a22dc3 to
11f5404
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.