paragonie / paseto

Platform-Agnostic Security Tokens
https://paseto.io
Other
3.23k stars 108 forks source link

Payload processing specification #54

Closed aidantwoods closed 6 years ago

aidantwoods commented 6 years ago

Since there's no issue open specifically for this:

Currently the documentation only goes so far as to specify the Paseto message format, but does not specify how to process this payload after decrypting or verifying it.

From reading the reference implementation I can probably answer most of the following myself, the goal here is to highlight questions that the spec should answer if processing the payload is going to be part of the specification, it's not just a series of personal questions :p

Can probably ask at least the encoding question for processing the footer too, though that seems really intended just to be a string.

paragonie-scott commented 6 years ago

Let me attempt to answer this line-by-line, then document it:



Anything unanswered (bold) is something I'm not sure about yet.

aidantwoods commented 6 years ago

Are arbitrary keys allowed to be set?

  • By keys do you mean in the array<key, value> sense? If so, there are "registered claims" which are very similar to JOSE's, except we use ISO 8601 datetime strings rather than unix timestamps

Indeed, assuming the JSON structure is array<key, value>, this question is referring only to the key portion. This is to ask whether:

  1. Should conforming implementations allow users to pick their own keys, or is there some sort of whitelist (as fas as I know, answer is: user may pick keys)
  2. Are there restrictions on what a key can look like (e.g. character set, casing, whitespace, ...).

With regard to the values, e.g. date formats, this comes under:

do we fail if the user puts unexpected (e.g. unparseable) data in these reserved fields (i.e. should writes to reserved fields be validated)?

which you've already answered :)


It's more than okay for the answer to some of these to be: "undefined", or "application specific", ... (some of these questions are really just aimed at pulling spec details out of the reference implementation)

rlittlefield commented 6 years ago

Originally it was going to be optional so people could use Protobuf, etc. However, I've since decided to just use JSON.

I'll assume that means I should make the JSON-specific route the favored option in my examples, and provide the raw-payload binary data only through a secondary route. Currently pypaseto only handles the raw portion, but I intend to build support for JSON and validation of registered claims soon.

I'm interested in getting msgpack functional as well, although due to the mostly-compatible nature, the processing of claims could actually be identical just with the middle encoding layer swapped out.

paragonie-scott commented 6 years ago

I'll assume that means I should make the JSON-specific route the favored option in my examples, and provide the raw-payload binary data only through a secondary route.

👍

paragonie-scott commented 6 years ago

This should be unambiguous enough now that #59 is merged. I'll reread this tonight and make sure before I close it.

aidantwoods commented 6 years ago

This should be unambiguous enough now that #59 is merged. I'll reread this tonight and make sure before I close it.

Yeah, I think #59 pretty much answers everything. I've checked everything above that I think has been explicitly answered. For what remains I would assume the following answers by omission:


Are these reservations case sensitive? (e.g. should an expiry key with incorrect case be ignored?)

Yes, case-sensitive.

If users can set these, do we fail if the user puts unexpected (e.g. unparseable) data in these reserved fields (i.e. should writes to reserved fields be validated)?

Up to implementation to come up with a means of discouraging invalid writes.

Do we fail open or closed if a rule is of an unexpected format?

Closed. (i.e. rule fails)

Will payload processing receive spec updates (e.g. potential changes to rules, addition of rules), how should this be versioned?

Unknown. (no mention of versioning for payload processing, leaning towards: No, this is a static requirement).

If payload processing is versioned, where do we put this version?

Unknown / n/a

paragonie-scott commented 6 years ago

https://github.com/paragonie/paseto/commit/060491a43e7c1364468c65ab206b45fa369539c2