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

Hash of Concatenated Header Information Required for API Lookup #66

Open
cicakdinding01 opened this issue Mar 14, 2018 · 2 comments
Open

Comments

@cicakdinding01
Copy link

Hi,

Am currently looking at a new integration - this integration requires several items, including a header information, which is a hash check of all the other header information concatenated together.

Also, one of the header ("date") is a dynamic value, generated from the time stamp of the client.

Question: Is this worth embarking on / technically achievable within the browser only, without a thick client. Note that example codes are provided in Python, Java, PHP, C++ and C#.


X-Auth-Hash header calculation:

  1. Take the request path and query string for the request. The request path is the part of the URL after the https://api.cti_provider.com. For example, for the following basic search request:
    http://api.cti_provider.com/search/basic?domain=abc.com, the part of the URL to be taken is: /search/basic?domain=abc.com

  2. Concatenate with the value specified in the "Accept-Version" header (defined earlier, fixed value).

  3. Concatenate with the value specified in the "Accept header" (defined earlier, fixed value)

  4. Concatenate with the current time stamp value of the client specified in the "Date" header (defined earlier, the time stamp needs to be dynamically calculated).

  5. Calculate the HMAC-SHA256 digest for the string obtained after following Step 1 to Step 4 above.

  6. Populate the "X-Auth-Hash" header with this value.

@cicakdinding01 cicakdinding01 changed the title Hash of Concatenated Header Information Required for API integration Hash of Concatenated Header Information Required for API Lookup Mar 14, 2018
@cloudtracer
Copy link
Owner

The API sounds like a pain in the butt :).

I can probably expand the jexl expressions to allow most of this (getting the date, concatenating the values then hashing them, etc), but I'd also have to expand the jexl expressions to work at request time. Which is cool, it shouldn't be a problem.

I just want to make sure I'm not missing anything. Could you throw together some javascript or pseudo code that can perform the steps and show what variables we need to collect from any responses and then use in any requests and how its all thrown together to make the API request? It sounds like other than the date the rest of the values are mostly hard coded except the hash which would be calculated based on the other values which seems straight forward.

Working on some other items right now for a bigger-ish release in the next week or two but I can try and squeeze this in. I can make sure I don't mess it up if you can get some javascript code together that makes the requests (doesn't need to be working example with the domain or anything just demonstrate what needs to be manipulated for the XHR request). Any JS is fine, jquery, pure whatever.

Also throw together an example of the variables with static values, what they concatenate to, and what the hash value ends up being. This will just give me a working example that I can use to make sure the hash is being produced properly and something wonky isn't going on with white space or with the expressions themselves.

Any chance you can share what API this is for?

@cicakdinding01
Copy link
Author

cicakdinding01 commented Mar 14, 2018

Hi cloudtracer, can we link up in private to discuss further on this? I have the details required to share.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants