x-signature 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f1d3f9f8bffd4aee0038f5151d573e1c7ba7e81
4
- data.tar.gz: a4d0d93ddf55eb587a9f3bbc6ed93ddd8ed32a6a
3
+ metadata.gz: 02081a2dfd7d57f2d232b004f29170bcffe731b9
4
+ data.tar.gz: cbc18ecdf8d074aa9ee839d4aa7b868423dd8495
5
5
  SHA512:
6
- metadata.gz: cffca84f57a29654d303046bbd17bc380a236a1b6e7373d7e40be49a95d42abd43c17c214bddf0dbb32ded47a4c4a5ba76b7d0b557e47f18b6d64f7f4a52fb57
7
- data.tar.gz: 113f54fee2427a91cb33ed554d2512d2ce1314a7b95717bab18a41ca9405c8e9adb3435ec1dd4c1a9cd3b403d3e4b9898e246d32fe857e8569bb77ba8945b01a
6
+ metadata.gz: 1fa1ec83f927a3c9af48e06cbce24da98c37520949c199ec41be97e2bd998a078b87e89c1d1f98d328d31cbc79c8d7c0a373ee8c951a2201461fee0ef0ef7ba9
7
+ data.tar.gz: 865f2b7b8f6fc12179ab3e2410cf4cfc828a1bed05bfd8d30c1755bfdf193cd5ef037e2ef032b4a6a7761051cb55876ca51431a7020e1fbc57c9d7f965c45cc6
data/README.md CHANGED
@@ -22,7 +22,22 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- ### Rails
25
+ For details check out [API reference](http://www.rubydoc.info/gems/x-signature).
26
+
27
+ ### Signing request
28
+
29
+ ```ruby
30
+ nonce = (Time.now.to_f * 1e3).to_i
31
+ headers['X-Nonce'] = nonce
32
+ headers['X-Signature'] = XSignature::HexSignatureValidator.signature(
33
+ secret: '42', nonce: nonce, body: 'test', method: 'GET', request_uri: '/path'
34
+ )
35
+ headers['X-Client'] = user.id
36
+ ```
37
+
38
+ ### Verifying signature
39
+
40
+ #### Rails
26
41
 
27
42
  In the controller:
28
43
 
@@ -19,4 +19,23 @@ module XSignature
19
19
  autoload :Base64SignatureValidator, File.expand_path('../x-signature/base64_signature_validator', __FILE__)
20
20
  autoload :HexSignatureValidator, File.expand_path('../x-signature/hex_signature_validator', __FILE__)
21
21
 
22
+ class << self
23
+ attr_writer :signature_header, :client_header, :nonce_header
24
+
25
+ def signature_header
26
+ @signature_header ||= 'HTTP_X_SIGNATURE'
27
+ end
28
+
29
+ def client_header
30
+ @client_header ||= 'HTTP_X_CLIENT'
31
+ end
32
+
33
+ def nonce_header
34
+ @nonce_header ||= 'HTTP_X_NONCE'
35
+ end
36
+
37
+ def configure
38
+ yield self
39
+ end
40
+ end
22
41
  end
@@ -12,9 +12,9 @@ module XSignature
12
12
  request_uri = (URI(env['REQUEST_URI']).request_uri rescue env['REQUEST_URI'])
13
13
  params = {
14
14
  secret: secret,
15
- signature: env['HTTP_X_SIGNATURE'],
16
- client: env['HTTP_X_CLIENT'],
17
- nonce: env['HTTP_X_NONCE'],
15
+ signature: env[XSignature.signature_header],
16
+ client: env[XSignature.client_header],
17
+ nonce: env[XSignature.nonce_header],
18
18
  method: request.method,
19
19
  request_uri: request_uri,
20
20
  body: body,
@@ -1,3 +1,3 @@
1
1
  module XSignature
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: x-signature
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AlexanderPavlenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-26 00:00:00.000000000 Z
11
+ date: 2015-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler