omniauth-workos 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.standard.yml +1 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +4 -0
- data/lib/omniauth/strategies/workos.rb +18 -8
- data/lib/omniauth-workos/version.rb +1 -1
- data/omniauth-workos.gemspec +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a71a4a9a8e65554eb0715f2a2277a7be0ef87bd898c88f2ff8bf9516c1ec63a
|
4
|
+
data.tar.gz: 064fac097752e9ae6ba5c5f09fac574bcb2ed075ed2d08612600a159fb0aada0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/Gemfile
CHANGED
@@ -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
|
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
|
-
|
15
|
-
|
16
|
-
|
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(
|
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(
|
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(
|
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!(
|
104
|
+
fail!(e.code, e)
|
95
105
|
end
|
96
106
|
|
97
107
|
private
|
data/omniauth-workos.gemspec
CHANGED
@@ -21,6 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
end
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency
|
25
|
-
spec.add_dependency
|
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.
|
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-
|
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
|