authograph 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +17 -1
- data/lib/authograph/rspec.rb +27 -0
- data/lib/authograph/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a52a4a4e452cfbaa7157719b09cc0c4ec6c24cb9
|
4
|
+
data.tar.gz: aafe1c75a3b8c62a26e8ca3090541100f474b703
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1707868c3bbc1a64159c7950d16f417daa0448811409d325f1f863957afa4fe63a13b31739b164cad65ccedc1aeb5ab3028d848bd58c642cc7fa600af2734293
|
7
|
+
data.tar.gz: 56957e84964052c0268f801d024f5bcd1c4f9ae42db14482a8b58e6f35381a047b94ec61bbad0c694456ec81c5c0edcffde4c1334810889f5686889173c8b56d
|
data/README.md
CHANGED
@@ -44,7 +44,6 @@ Yo can later validate the request by using `authentic?`
|
|
44
44
|
signer.authentic?(my_request, my_secret) # this will check the signature and the date by default
|
45
45
|
```
|
46
46
|
|
47
|
-
|
48
47
|
### Signer options
|
49
48
|
|
50
49
|
**IMPORTANT** Remember to always configure both the signer-signer and the validator-signer using the same paremeters.
|
@@ -58,6 +57,23 @@ The following parameters are available when calling `Authograph.signer`:
|
|
58
57
|
* `date_header`: header key to store date in (`'X-Date'` by default).
|
59
58
|
* `date_max_skew`: maximum difference (in secs) between request time and validaton (`'600'` by default).
|
60
59
|
|
60
|
+
### Testing (only rspec)
|
61
|
+
|
62
|
+
Sometimes is useful to stub the signing process on tests.
|
63
|
+
|
64
|
+
Make sure to include the rspec extensions on your `spec_helper.rb`:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
require 'authograph/rspec'
|
68
|
+
```
|
69
|
+
|
70
|
+
Now you can call the `stub_authograph` inside your tests:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
before { stub_authograph(:any, 'mysignature') } }
|
74
|
+
before { stub_authograph({ secret: 'my_secret' }, 'mysignature') } # only stub signatures for a given secret (TODO)
|
75
|
+
before { stub_authograph({ path: '/my/path' }, 'mysignature') } # only stub signatures for a given path (TODO)
|
76
|
+
```
|
61
77
|
|
62
78
|
### Generated signature structure
|
63
79
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Authograph
|
2
|
+
module RSpecHelpers
|
3
|
+
def stub_authograph(_matcher, _signature = nil)
|
4
|
+
if _signature.nil?
|
5
|
+
_signature = _matcher
|
6
|
+
_matcher = :any
|
7
|
+
end
|
8
|
+
|
9
|
+
allow_any_instance_of(Authograph::Signer)
|
10
|
+
.to receive(:calc_signature)
|
11
|
+
.and_wrap_original do |original, request, secret|
|
12
|
+
case _matcher
|
13
|
+
when :any
|
14
|
+
next _signature
|
15
|
+
when Hash
|
16
|
+
# TODO
|
17
|
+
end
|
18
|
+
|
19
|
+
original.call(request, secret) # fallback to original
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
RSpec.configure do |config|
|
26
|
+
config.include Authograph::RSpecHelpers
|
27
|
+
end
|
data/lib/authograph/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authograph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ignacio Baixas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- lib/authograph/adapters/faraday.rb
|
107
107
|
- lib/authograph/adapters/http.rb
|
108
108
|
- lib/authograph/adapters/rack.rb
|
109
|
+
- lib/authograph/rspec.rb
|
109
110
|
- lib/authograph/signer.rb
|
110
111
|
- lib/authograph/version.rb
|
111
112
|
homepage: https://github.com/SurBTC/authograph
|