-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relax payload from_utf8 behind flag #98
Comments
Hej Kasper, Thanks for the suggestion! As you also mention, non-valid UTF-8 data is prohibited by the spec. As the spec also suggests, if non-UTF-8 data is needed, this ought to be encoded using the base64-url encoding, which is also used throughout the rest of PASETO. Is there anything preventing you from doing this? Encoding your binary data beforehand and then decoding it after having processed the token? |
Hej Johannes, Thank you for your fast response. There is nothing preventing me from using base64 encoding, except it introduces serialization/deserialization overhead and introduces space overhead, which is typical not an issue. But it would be nice to serialize it directly instead of introducing steps, since the function signature takes an &[u8] maybe it should be changed to a &str if it should stay complaint with PASETO? Since it introduces confusion? It is delightful to hear your thoughts, and thank you for the awesome library, huge thumbs up! //Kasper |
Yes, this sounds like a good idea. I see how it is confusing, I don't want people necessarily forced to read the spec before using the library. Should be noted that this API confusion is only present in the lower-level Doing this change would be SemVer breaking. Thank you for the kind words! Glad you like it. |
A minor suggestion
It would be nice if the payload could be relaxed to a non-valid utf-8 encoding, currently it restricts binary encodings. I know binary encoding, is not compliant with the PASETO RFC. As a suggestion, it could be hidden behind a feature flag to allow binary encodings and since the function signature for payload is &[u8], and a valid footer does not need a valid utf-8 encoding.
https://github.com/brycx/pasetors/blob/807d3ad3660158bac25be0f66768d84ee259323d/src/token.rs#L119C21-L119C21
The text was updated successfully, but these errors were encountered: