omniauth-workos 1.0.0 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca6792ae900fd8ff62ec50165bf0dad3925b4a8bf399d45bdd000b42154ee779
4
- data.tar.gz: 8f59e1223bd81407fcd02980a16879d769b69d911ee7ca52d54131906528f10f
3
+ metadata.gz: 3a71a4a9a8e65554eb0715f2a2277a7be0ef87bd898c88f2ff8bf9516c1ec63a
4
+ data.tar.gz: 064fac097752e9ae6ba5c5f09fac574bcb2ed075ed2d08612600a159fb0aada0
5
5
  SHA512:
6
- metadata.gz: 39ac12ad8a083de04e6eb3765484fee4f5504e542de39bf97f2058aad0e95c1e89f5200f6526a3ef6d01e18c0705c8ac8dbc6581d06c8629a3c198171edad9e9
7
- data.tar.gz: 4db30484b097f977fa668d04b21463d294541ab509c068750365261368c4ea845f971908f2bffeb75bb6d60cdf2b4adf72980bed5e222e86c37bb2f63e505bf1
6
+ metadata.gz: e56755b2811419ff88af17ea1f33132cfd46ac798e094b5969c8999f7cef82d084aef020f6061a43092bc4097437f3e004d598fbb8d726600b479e900f39a4a4
7
+ data.tar.gz: ecd090729df0ce497cf50470489cfaaf4937ebe57446a1b66c337b9e5b12dcda56557863b28578080658494e27c4f2ac55186ad548ae7bb91c64ce956cebc1bb
data/.standard.yml ADDED
@@ -0,0 +1 @@
1
+ ruby_version: 2.5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.1.0] - 2022-02-23
4
+
5
+ - Return clearer errors
6
+
3
7
  ## [1.0.0] - 2022-02-21
4
8
 
5
9
  - Initial release
data/Gemfile CHANGED
@@ -18,3 +18,7 @@ group :test do
18
18
  gem "timecop", "~> 0.9"
19
19
  gem "webmock", "~> 3.14"
20
20
  end
21
+
22
+ group :test, :development do
23
+ gem "standard", "~> 1.7"
24
+ end
@@ -4,16 +4,23 @@ require "omniauth-oauth2"
4
4
 
5
5
  module OmniAuth::Strategies
6
6
  class WorkOS < OmniAuth::Strategies::OAuth2
7
- class Error < StandardError; end
7
+ class Error < StandardError
8
+ attr_reader :code
9
+
10
+ def initialize(code:, message:)
11
+ @code = code
12
+ super(message)
13
+ end
14
+ end
8
15
 
9
16
  AUTHORIZE_PARAMS_SESSION_KEY = "omniauth_workos_authorize_params"
10
17
  private_constant :AUTHORIZE_PARAMS_SESSION_KEY
11
18
 
12
19
  option :name, "workos"
13
20
  option :client_options,
14
- site: "https://api.workos.com",
15
- authorize_url: "/sso/authorize",
16
- token_url: "/sso/token"
21
+ site: "https://api.workos.com",
22
+ authorize_url: "/sso/authorize",
23
+ token_url: "/sso/token"
17
24
  option :authorize_options, %w[organization connection provider login_hint]
18
25
  # info_fields:
19
26
  # Either an **array** with the names of the fields as **strings**, or the
@@ -49,15 +56,18 @@ module OmniAuth::Strategies
49
56
  # Confirm that the user comes from the connection/organization requested
50
57
  # during the authorize phase.
51
58
  unless authorize_params.key?("connection") || authorize_params.key?("organization")
52
- raise Error.new("invalid session; no connection nor organization")
59
+ raise Error.new(code: :invalid_session,
60
+ message: "invalid session; no connection nor organization")
53
61
  end
54
62
 
55
63
  if authorize_params.key?("connection") && authorize_params["connection"] != raw_info["connection_id"]
56
- raise Error.new("the user's connection_id `#{raw_info["connection_id"]}` doesn't match what was requested `#{authorize_params["connection"]}`")
64
+ raise Error.new(code: :connection_mismatch,
65
+ message: "the user's connection_id `#{raw_info["connection_id"]}` doesn't match what was requested `#{authorize_params["connection"]}`")
57
66
  end
58
67
 
59
68
  if authorize_params.key?("organization") && authorize_params["organization"] != raw_info["organization_id"]
60
- raise Error.new("the user's organization_id `#{raw_info["organization_id"]}` doesn't match what was requested `#{authorize_params["organization"]}`")
69
+ raise Error.new(code: :organization_mismatch,
70
+ message: "the user's organization_id `#{raw_info["organization_id"]}` doesn't match what was requested `#{authorize_params["organization"]}`")
61
71
  end
62
72
  end
63
73
  end
@@ -91,7 +101,7 @@ module OmniAuth::Strategies
91
101
  def callback_phase
92
102
  super
93
103
  rescue Error => e
94
- fail!(:connection_or_organization_mismatch, e)
104
+ fail!(e.code, e)
95
105
  end
96
106
 
97
107
  private
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module WorkOS
5
- VERSION = "1.0.0"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
@@ -21,6 +21,6 @@ Gem::Specification.new do |spec|
21
21
  end
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_dependency 'omniauth', '~> 2.0'
25
- spec.add_dependency 'omniauth-oauth2', '~> 1.7'
24
+ spec.add_dependency "omniauth", "~> 2.0"
25
+ spec.add_dependency "omniauth-oauth2", "~> 1.7"
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-workos
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Fernandes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-21 00:00:00.000000000 Z
11
+ date: 2022-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -46,6 +46,7 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".rspec"
49
+ - ".standard.yml"
49
50
  - CHANGELOG.md
50
51
  - Gemfile
51
52
  - LICENSE.txt