idsimple-rack 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
  SHA256:
3
- metadata.gz: 8e96f0e33a7a9ae276cceadb129736372de30090009e65627abb8b265c970441
4
- data.tar.gz: '0892d4f0de694a19808e0d86b3cf160e2cb76568abf21c54870f44269f6eb325'
3
+ metadata.gz: c35d904d4db39a9f711b889af448027ebf9a8f84ef04b282a1d7e1e420c64027
4
+ data.tar.gz: 540ff108660918e36c6d37a874506ed18ea02ccd58f3c82a9ab0ab3b7f266067
5
5
  SHA512:
6
- metadata.gz: 179c195156ea7eb3762ae4df5ad1b60dad5894156d78a4b53a65aec1311c67cade941d87c9108df63b3d1e89d7961b34cb23668149afcbe1c0fb0f4cb7c40688
7
- data.tar.gz: 1fabbc0f43b36e97a60442aaf5bf055ce570666906df603d0bc5d9bdb9775124aabf837dda661b82ef0041853cd30e1168112ff5491982cee472561501832540
6
+ metadata.gz: 3ad0f90bb5c0c73ace4e550f21b864f78ea08b6e2189e27c676f9d3fd75b39ab85a64be43a6cc64b2902b24b77f918ca5b53a01e3847771d6328e11543b3cf8d
7
+ data.tar.gz: ed9bc934cf8288f5027b32cf6b167b5fb4b4418162d290712664b2b09c42d174e67acc54df87eca37f467e2510086e6b9a3ce516d64b4889c08fec8f70319001
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # Idsimple::Rack
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/idsimple-rack.svg)](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/)
@@ -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 = "Rack middleware for idsimple integration."
10
- spec.homepage = "https://github.com/idsimple/idsimple-rack"
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
@@ -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("/api/v1/access_tokens/#{token_id}/use", "", headers)
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("/api/v1/access_tokens/#{token_id}/refresh", "", headers)
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.com"
29
- @api_base_url = "https://api.idsimple.com"
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
@@ -57,7 +57,11 @@ module Idsimple
57
57
  end
58
58
 
59
59
  def api
60
- @api ||= Idsimple::Rack::Api.new(configuration.api_base_url, configuration.api_key)
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
@@ -1,5 +1,5 @@
1
1
  module Idsimple
2
2
  module Rack
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  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.0
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 00:00:00.000000000 Z
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://github.com/idsimple/idsimple-rack
72
+ homepage: https://idsimple.io
73
73
  licenses:
74
74
  - MIT
75
75
  metadata:
76
- homepage_uri: https://github.com/idsimple/idsimple-rack
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: Rack middleware for idsimple integration.
97
+ summary: Ruby middleware for idsimple integration.
98
98
  test_files: []