session-validator-client 3.0.1 → 3.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 +14 -0
- data/lib/session_validator/cached_client.rb +11 -0
- data/lib/session_validator/client.rb +12 -0
- data/session-validator-client.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a5fbffce84601019f81c281d10264ca718ea083ac84a12aa9ea079f6af56d1c
|
4
|
+
data.tar.gz: d73b28d840deed00914f2d5316e222967d0c17b791a52c1fccc44ce54964c8cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 962e8d27ef646e4a5201a657937fa468639e1b75dacf5a36a2226a5abb6891799ef2eabd8209daa0a552369bbd470bf95822c0a3f0f9fecd0e8d6c5009ce7b14
|
7
|
+
data.tar.gz: 85de14cee3adf4f7b07b122023159116d43d91c2e59897273ef47f1ecd6eec3f58d9d33dd31ef4ccc921ed5e9ebee8da9f9c574f7014cc790b8700438b68ff34
|
data/README.md
CHANGED
@@ -10,12 +10,16 @@ gem install session-validator-client
|
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
13
|
+
|
13
14
|
setup up the following environment variables:
|
14
15
|
|
15
16
|
* `KEY_POOL`
|
16
17
|
* `SESSION_VALIDATOR_KEYID`
|
17
18
|
* `SESSION_VALIDATOR_URL`
|
18
19
|
|
20
|
+
###Validating a single Msid
|
21
|
+
`valid?(msid)` returns `true` if `msid` is valid
|
22
|
+
|
19
23
|
```ruby
|
20
24
|
require "session_validator"
|
21
25
|
|
@@ -23,6 +27,16 @@ client = SessionValidator::Client.new
|
|
23
27
|
client.valid?("staging_int_5ad5f96f307cf9.61063404")
|
24
28
|
```
|
25
29
|
|
30
|
+
###Batch validating multiple MSIDS
|
31
|
+
`filter_invalid(msids)` returns an array of the invalid MSIDS.
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require "session_validator"
|
35
|
+
|
36
|
+
client = SessionValidator::Client.new
|
37
|
+
client.filter_invalid(["staging_int_5ad5f96f307cf9.61063404", "staging_int_5ad5f96f307cf9.61063405"])
|
38
|
+
```
|
39
|
+
|
26
40
|
## Running tests
|
27
41
|
|
28
42
|
```bash
|
@@ -15,5 +15,16 @@ module SessionValidator
|
|
15
15
|
@cache.set msid, result if result
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
19
|
+
def filter_invalid(msids)
|
20
|
+
@cache.cleanup
|
21
|
+
|
22
|
+
@client.filter_invalid(msids).tap do |result|
|
23
|
+
msids.each do |msid|
|
24
|
+
@cache.set msid, true unless result.include?(msid)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
18
29
|
end
|
19
30
|
end
|
@@ -21,6 +21,18 @@ class SessionValidator::Client
|
|
21
21
|
true
|
22
22
|
end
|
23
23
|
|
24
|
+
def filter_invalid(msids)
|
25
|
+
response = client.post("/sessions/filter", JSON.generate({msids:msids}), headers)
|
26
|
+
if response.status == 200
|
27
|
+
JSON.parse(response.body)
|
28
|
+
else
|
29
|
+
[]
|
30
|
+
end
|
31
|
+
rescue Faraday::TimeoutError
|
32
|
+
[]
|
33
|
+
end
|
34
|
+
|
35
|
+
|
24
36
|
private
|
25
37
|
|
26
38
|
def client
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: session-validator-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emarsys Technologies Ltd.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: escher-keypool
|