Skip to content
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

serialization produces invalid base64 #26

Open
rogpeppe opened this issue Jan 8, 2015 · 4 comments
Open

serialization produces invalid base64 #26

rogpeppe opened this issue Jan 8, 2015 · 4 comments

Comments

@rogpeppe
Copy link
Contributor

rogpeppe commented Jan 8, 2015

The base64 does not have the required padding characters to
allow it to be parsed by standard base64 decoders.

Verify by taking some serialization from the example README.md:

echo 'MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudGlmaWVyIHdlIHVzZWQgb3VyIHNlY3JldCBrZXkKMDAyZnNpZ25hdHVyZSDj2eApCFJsTAA5rhURQRXZf91ovyujebNCqvD2F9BVLwo' | base64 -d

produces an error.

@rescrv
Copy link
Owner

rescrv commented Jan 8, 2015

We switched to the URL Base64 format so tokens can be put into URLs. See here for more discussion: #20.

This library will handle both, but produces the URL format.

@rogpeppe
Copy link
Contributor Author

rogpeppe commented Jan 9, 2015

Thanks. I hadn't appreciated that the URL encoding conventionally omits padding.

I think there might be a benefit to exposing functions that don't do any
base64 encoding or decoding at all. If you're sending binary data, the
base64 encoding adds unnecessary overhead, and JSON is already ASCII,
so likewise does not necessarily need armoring.

@rescrv
Copy link
Owner

rescrv commented Jan 9, 2015

I'm up for adding a (possibly hidden) function that can directly output non-base64 tokens so binary data can be sent in the clear. Ditto for the JSON format once it settles.

I went for base64 by default because it's the easiest to use safely under the widest variety of scenarios I can imagine. The lack of whitespace or non-ascii characters means its easy to parse a complete token, and use it in every place I could imagine a token being used. Developers who want to do things more cleverly than that are certainly welcome to do so, but we shouldn't make it the default.

@nitram509
Copy link
Contributor

Interesting discussion. I also want to add my 2 cts.

I prefer Base64, because its plain ASCII and can be easily transported (nearly) everywhere on the web.
AFAIK, JSON isn't ASCII but Unicode (according to http://json.org/). So every developer has to think about post serialization processing (at least), to make a safe transport possible. Think about HTTP headers etc.

When we're talking about character encoding, I prefer JSON, because it's solved there. The current macaroon binary format doesn't specify this.Besides this, I don't see any values in using JSON. But I'm interested to hear yours. (context: macaroon serialization)

In the future I would like to see only one preferred transport format, which eases the cross platform or cross language implementation adoption of macaroons.

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

No branches or pull requests

3 participants