Sha256: 251399e1cde47f601f8ad60a68712a9cd9556d582d001d273a5c18e699ecae8b

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href="/app.css">

<title>HMAC Generator</title>
<h1>Okay, here's what I've got</h1>

<p>These are the values we used to generate the hash:</p>
<code><%= JSON.pretty_generate @params %></code>
<p class="info">Removed blank params here, we won't send them to the provider, if we had, they should have been in the string_to_sign e.g. "1|2||4".</p>

<p>Then we add the timestamp and other parameter we want:</p>
<code>params = <%= JSON.pretty_generate @params_to_sign %></code>
<p class="info">timestamp is the only key that is required. <br />
  version, nonce and consumer_key are app-specific and can be anything you want, just make sure you calculate the hmac over all the params you send.
 </p>

<p>To calculate the HMAC, we sort the params by key alfabetically and join the values with a '|' in between:</p>
<code>string_to_sign = <%= @checker.send(:message_string, @params_to_sign) %></code>

<p>And use the configured secret for the HMAC generation:</p>
<code>hmac_secret = '<%= @secret %>'</code>

<p>Then we add the HMAC to the params:</p>
<code># Authmac::HmacChecker.new(hmac_secret, '|', 'sha256').sign(params)
<%= JSON.pretty_generate @params_with_hmac %></code>

<p>Then, this is a nice URL to use. We URL-escape each value, and keep in mind that the order of HTTP-methods does not matter:</p>

<a href="/auth?<%= @link %>">Link</a>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
authmac-2.0.2 example/views/sign.erb
authmac-2.0.1 example/views/sign.erb
authmac-2.0.0 example/views/sign.erb