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

Unclear documentation for "Normalized data for HTTP requests" #54

Closed
hvge opened this issue Feb 22, 2016 · 1 comment
Closed

Unclear documentation for "Normalized data for HTTP requests" #54

hvge opened this issue Feb 22, 2016 · 1 comment

Comments

@hvge
Copy link
Member

hvge commented Feb 22, 2016

For this time, I found out just a small issue in the signature.md documentation. There are two errors actually:

  1. Your documentation doesn't reflect actual reference implementation for data normalization
  2. The usage of "REQUEST_DATA" variable doesn't make sense

1. Implementation vs documentation

Your current implementation does something like this:

return (httpMethod != null ? httpMethod.toUpperCase() : "GET")
                + "&" + requestUriHash
                + "&" + applicationSecret
                + "&" + (nonce != null ? nonce : "")
                + "&" + dataBase64;

but the documentation says:

REQUEST_DATA = ${REQUEST_METHOD}&${REQUEST_URI_IDENTIFIER_HASH}&${NONCE}&${REQUEST_BODY}
DATA = ${REQUEST_DATA}&${APPLICATION_SECRET}

You can clearly see, that the APPLICATION_SECRET should be appended at the end of the normalized string, but the reference implementation has secret somewhere in the middle of the normalized string.

2. The usage of "REQUEST_DATA"

There's unclear usage of REQUEST_DATA term. It is used as a part of calculation (see that concatenation above) and also as a part of GET/POST data normalization. For GET, for example documentation says:

REQUEST_DATA = BASE64.encode(CONCAT_ALL(CONCAT(KEY[j], VALUE[j], "="), "&", j = 0 .. N))

...and that would revert all that concatenation explained before.

Solution

I would recommend to simplify the documentation to something like this (if the order of concatenation is correct):

SIGNED_DATA = ${REQUEST_METHOD}&${REQUEST_URI_IDENTIFIER_HASH}&${NONCE}&${REQUEST_DATA}&${APPLICATION_SECRET}

Where the REQUEST_DATA is that B64 encoding for POSTs or that key-value normalization for GETs.

@petrdvorak
Copy link
Member

The documentation is correct and issue will be fixed with fixing #25.

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

2 participants