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 +4 -4
- data/README.md +16 -1
- data/lib/x-signature.rb +19 -0
- data/lib/x-signature/rails_request_validator.rb +3 -3
- data/lib/x-signature/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02081a2dfd7d57f2d232b004f29170bcffe731b9
|
4
|
+
data.tar.gz: cbc18ecdf8d074aa9ee839d4aa7b868423dd8495
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
|
data/lib/x-signature.rb
CHANGED
@@ -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[
|
16
|
-
client: env[
|
17
|
-
nonce: env[
|
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,
|
data/lib/x-signature/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|