idsimple-rack 0.1.0 → 0.1.1
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 +3 -1
- data/idsimple-rack.gemspec +2 -2
- data/lib/idsimple/rack/access_token_validator.rb +0 -21
- data/lib/idsimple/rack/api.rb +5 -4
- data/lib/idsimple/rack/configuration.rb +4 -3
- data/lib/idsimple/rack/helper.rb +5 -1
- data/lib/idsimple/rack/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c35d904d4db39a9f711b889af448027ebf9a8f84ef04b282a1d7e1e420c64027
|
4
|
+
data.tar.gz: 540ff108660918e36c6d37a874506ed18ea02ccd58f3c82a9ab0ab3b7f266067
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ad0f90bb5c0c73ace4e550f21b864f78ea08b6e2189e27c676f9d3fd75b39ab85a64be43a6cc64b2902b24b77f918ca5b53a01e3847771d6328e11543b3cf8d
|
7
|
+
data.tar.gz: ed9bc934cf8288f5027b32cf6b167b5fb4b4418162d290712664b2b09c42d174e67acc54df87eca37f467e2510086e6b9a3ce516d64b4889c08fec8f70319001
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# Idsimple::Rack
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/idsimple-rack)
|
4
|
+
|
3
5
|
## Overview
|
4
|
-
Idsimple works with all [Rack](https://github.com/rack/rack)-based applications.
|
6
|
+
[Idsimple](https://idsimple.io) works with all [Rack](https://github.com/rack/rack)-based applications.
|
5
7
|
This includes:
|
6
8
|
- [Ruby on Rails](https://rubyonrails.org/)
|
7
9
|
- [Sinatra](http://sinatrarb.com/)
|
data/idsimple-rack.gemspec
CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.authors = ["Ari Summer"]
|
7
7
|
spec.email = ["support@idsimple.io"]
|
8
8
|
|
9
|
-
spec.summary = "
|
10
|
-
spec.homepage = "https://
|
9
|
+
spec.summary = "Ruby middleware for idsimple integration."
|
10
|
+
spec.homepage = "https://idsimple.io"
|
11
11
|
spec.license = "MIT"
|
12
12
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
13
|
|
@@ -5,20 +5,9 @@ module Idsimple
|
|
5
5
|
class AccessTokenValidator
|
6
6
|
def self.validate_used_token_custom_claims(decoded_token, req)
|
7
7
|
token_payload = decoded_token[0]
|
8
|
-
ip = token_payload["idsimple.ip"]
|
9
|
-
user_agent = token_payload["idsimple.user_agent"]
|
10
8
|
used_at = token_payload["idsimple.used_at"]
|
11
9
|
|
12
10
|
result = AccessTokenValidationResult.new
|
13
|
-
|
14
|
-
if ip && req.ip != ip
|
15
|
-
result.add_error("IP mismatch")
|
16
|
-
end
|
17
|
-
|
18
|
-
if user_agent && req.user_agent != user_agent
|
19
|
-
result.add_error("User agent mismatch")
|
20
|
-
end
|
21
|
-
|
22
11
|
result.add_error("Missing used_at timestamp") if !used_at
|
23
12
|
result.add_error("Invalid used_at timestamp") if used_at && used_at > Time.now.to_i
|
24
13
|
|
@@ -29,19 +18,9 @@ module Idsimple
|
|
29
18
|
token_payload = decoded_token[0]
|
30
19
|
use_by = token_payload["idsimple.use_by"]
|
31
20
|
used_at = token_payload["idsimple.used_at"]
|
32
|
-
ip = token_payload["idsimple.ip"]
|
33
|
-
user_agent = token_payload["idsimple.user_agent"]
|
34
21
|
|
35
22
|
result = AccessTokenValidationResult.new
|
36
23
|
|
37
|
-
if ip && req.ip != ip
|
38
|
-
result.add_error("IP mismatch")
|
39
|
-
end
|
40
|
-
|
41
|
-
if user_agent && req.user_agent != user_agent
|
42
|
-
result.add_error("User agent mismatch")
|
43
|
-
end
|
44
|
-
|
45
24
|
if use_by && Time.now.to_i > use_by
|
46
25
|
result.add_error("Token must be used prior to before claim")
|
47
26
|
end
|
data/lib/idsimple/rack/api.rb
CHANGED
@@ -4,10 +4,11 @@ require "json"
|
|
4
4
|
module Idsimple
|
5
5
|
module Rack
|
6
6
|
class Api
|
7
|
-
attr_reader :base_url
|
7
|
+
attr_reader :base_url, :base_path
|
8
8
|
|
9
|
-
def initialize(base_url, api_key)
|
9
|
+
def initialize(base_url, base_path, api_key)
|
10
10
|
@base_url = base_url
|
11
|
+
@base_path = base_path
|
11
12
|
@api_key = api_key
|
12
13
|
end
|
13
14
|
|
@@ -23,12 +24,12 @@ module Idsimple
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def use_token(token_id)
|
26
|
-
response = http_client.patch("/
|
27
|
+
response = http_client.patch("#{base_path}/access_tokens/#{token_id}/use", "", headers)
|
27
28
|
Result.new(response)
|
28
29
|
end
|
29
30
|
|
30
31
|
def refresh_token(token_id)
|
31
|
-
response = http_client.patch("/
|
32
|
+
response = http_client.patch("#{base_path}/access_tokens/#{token_id}/refresh", "", headers)
|
32
33
|
Result.new(response)
|
33
34
|
end
|
34
35
|
|
@@ -7,7 +7,7 @@ module Idsimple
|
|
7
7
|
DEFAULT_COOKIE_NAME = "idsimple.access_token"
|
8
8
|
|
9
9
|
attr_accessor :get_access_token, :set_access_token, :remove_access_token, :signing_secret,
|
10
|
-
:authenticate_path, :issuer, :api_base_url, :after_authenticated_path,
|
10
|
+
:authenticate_path, :issuer, :api_base_url, :api_base_path, :after_authenticated_path,
|
11
11
|
:app_id, :skip_on, :logger, :enabled, :unauthorized_response, :api_key,
|
12
12
|
:redirect_to_authenticate
|
13
13
|
|
@@ -25,8 +25,9 @@ module Idsimple
|
|
25
25
|
@enabled = true
|
26
26
|
@authenticate_path = "/idsimple/session"
|
27
27
|
@after_authenticated_path = "/"
|
28
|
-
@issuer = "https://app.idsimple.
|
29
|
-
@api_base_url = "https://api.idsimple.
|
28
|
+
@issuer = "https://app.idsimple.io"
|
29
|
+
@api_base_url = "https://api.idsimple.io"
|
30
|
+
@api_base_path = "/v1"
|
30
31
|
@app_id = nil
|
31
32
|
@skip_on = nil
|
32
33
|
@signing_secret = nil
|
data/lib/idsimple/rack/helper.rb
CHANGED
@@ -57,7 +57,11 @@ module Idsimple
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def api
|
60
|
-
@api ||= Idsimple::Rack::Api.new(
|
60
|
+
@api ||= Idsimple::Rack::Api.new(
|
61
|
+
configuration.api_base_url,
|
62
|
+
configuration.api_base_path,
|
63
|
+
configuration.api_key
|
64
|
+
)
|
61
65
|
end
|
62
66
|
end
|
63
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: idsimple-rack
|
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
|
- Ari Summer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -69,11 +69,11 @@ files:
|
|
69
69
|
- lib/idsimple/rack/railtie.rb
|
70
70
|
- lib/idsimple/rack/validator_middleware.rb
|
71
71
|
- lib/idsimple/rack/version.rb
|
72
|
-
homepage: https://
|
72
|
+
homepage: https://idsimple.io
|
73
73
|
licenses:
|
74
74
|
- MIT
|
75
75
|
metadata:
|
76
|
-
homepage_uri: https://
|
76
|
+
homepage_uri: https://idsimple.io
|
77
77
|
source_code_uri: https://github.com/idsimple/idsimple-rack
|
78
78
|
changelog_uri: https://github.com/idsimple/idsimple-rack/CHANGELOG.md
|
79
79
|
post_install_message:
|
@@ -94,5 +94,5 @@ requirements: []
|
|
94
94
|
rubygems_version: 3.1.6
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
|
-
summary:
|
97
|
+
summary: Ruby middleware for idsimple integration.
|
98
98
|
test_files: []
|