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/.rubocop.yml +2 -0
- data/.semaphore/semaphore.yml +2 -2
- data/Gemfile.lock +2 -2
- data/lib/workos/client.rb +3 -2
- data/lib/workos/profile.rb +8 -10
- data/lib/workos/profile_and_token.rb +1 -1
- data/lib/workos/sso.rb +17 -0
- data/lib/workos/version.rb +1 -1
- data/spec/lib/workos/sso_spec.rb +31 -0
- data/spec/support/fixtures/vcr_cassettes/sso/profile.yml +74 -0
- data/workos.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d48c12ff6a0a470ca2a35fb76cabf17fe9d4f2444b11811891a9ea0c81f9cda
|
4
|
+
data.tar.gz: ec43b59ca57135efd145346ce14ebab1ed30341f210b3a47f8525afb907d3856
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2068f4bd90b52d90b802eea6f1e8ebeb2a5e1b166d5256d952df40af30821bd858999813532f18e9ab44eff36f4cde40a27f423126028509fe9c12f15ef07d58
|
7
|
+
data.tar.gz: 526f33fd44a2371696dc19f400461af7e170e362d7057bf04529767eae8692d12b8e56635f6b61d5b0e8c585f2275e65e62422f064bbe056645c2c0cc1cfe14f
|
data/.rubocop.yml
CHANGED
data/.semaphore/semaphore.yml
CHANGED
@@ -33,13 +33,13 @@ blocks:
|
|
33
33
|
- name: Ruby 1.9.3
|
34
34
|
commands:
|
35
35
|
- checkout
|
36
|
-
- sem-version ruby 1.9.3
|
36
|
+
- sem-version ruby 1.9.3-p551
|
37
37
|
- bundle install
|
38
38
|
- bundle exec rspec
|
39
39
|
- name: Ruby 2.0.0
|
40
40
|
commands:
|
41
41
|
- checkout
|
42
|
-
- sem-version ruby 2.0.0
|
42
|
+
- sem-version ruby 2.0.0-p648
|
43
43
|
- bundle install
|
44
44
|
- bundle exec rspec
|
45
45
|
- name: Ruby 2.3.4
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
workos (1.
|
4
|
+
workos (1.1.0)
|
5
5
|
sorbet-runtime (~> 0.5)
|
6
6
|
|
7
7
|
GEM
|
@@ -60,7 +60,7 @@ GEM
|
|
60
60
|
simplecov_json_formatter (0.1.2)
|
61
61
|
sorbet (0.5.6388)
|
62
62
|
sorbet-static (= 0.5.6388)
|
63
|
-
sorbet-runtime (0.5.
|
63
|
+
sorbet-runtime (0.5.6424)
|
64
64
|
sorbet-static (0.5.6388-universal-darwin-14)
|
65
65
|
sorbet-static (0.5.6388-universal-darwin-15)
|
66
66
|
sorbet-static (0.5.6388-universal-darwin-16)
|
data/lib/workos/client.rb
CHANGED
@@ -36,9 +36,10 @@ module WorkOS
|
|
36
36
|
path: String,
|
37
37
|
auth: T.nilable(T::Boolean),
|
38
38
|
params: T.nilable(Hash),
|
39
|
+
access_token: T.nilable(String),
|
39
40
|
).returns(Net::HTTP::Get)
|
40
41
|
end
|
41
|
-
def get_request(path:, auth: false, params: {})
|
42
|
+
def get_request(path:, auth: false, params: {}, access_token: nil)
|
42
43
|
uri = URI(path)
|
43
44
|
uri.query = URI.encode_www_form(params) if params
|
44
45
|
|
@@ -47,7 +48,7 @@ module WorkOS
|
|
47
48
|
'Content-Type' => 'application/json',
|
48
49
|
)
|
49
50
|
|
50
|
-
request['Authorization'] = "Bearer #{WorkOS.key!}" if auth
|
51
|
+
request['Authorization'] = "Bearer #{access_token || WorkOS.key!}}" if auth
|
51
52
|
request['User-Agent'] = user_agent
|
52
53
|
request
|
53
54
|
end
|
data/lib/workos/profile.rb
CHANGED
@@ -48,22 +48,20 @@ module WorkOS
|
|
48
48
|
|
49
49
|
private
|
50
50
|
|
51
|
-
# rubocop:disable Metrics/AbcSize
|
52
51
|
sig { params(json_string: String).returns(WorkOS::Types::ProfileStruct) }
|
53
52
|
def parse_json(json_string)
|
54
53
|
hash = JSON.parse(json_string, symbolize_names: true)
|
55
54
|
|
56
55
|
WorkOS::Types::ProfileStruct.new(
|
57
|
-
id: hash[:
|
58
|
-
email: hash[:
|
59
|
-
first_name: hash[:
|
60
|
-
last_name: hash[:
|
61
|
-
connection_id: hash[:
|
62
|
-
connection_type: hash[:
|
63
|
-
idp_id: hash[:
|
64
|
-
raw_attributes: hash[:
|
56
|
+
id: hash[:id],
|
57
|
+
email: hash[:email],
|
58
|
+
first_name: hash[:first_name],
|
59
|
+
last_name: hash[:last_name],
|
60
|
+
connection_id: hash[:connection_id],
|
61
|
+
connection_type: hash[:connection_type],
|
62
|
+
idp_id: hash[:idp_id],
|
63
|
+
raw_attributes: hash[:raw_attributes],
|
65
64
|
)
|
66
65
|
end
|
67
|
-
# rubocop:enable Metrics/AbcSize
|
68
66
|
end
|
69
67
|
end
|
@@ -15,7 +15,7 @@ module WorkOS
|
|
15
15
|
json = JSON.parse(profile_and_token_json, symbolize_names: true)
|
16
16
|
|
17
17
|
@access_token = T.let(json[:access_token], String)
|
18
|
-
@profile = WorkOS::Profile.new(
|
18
|
+
@profile = WorkOS::Profile.new(json[:profile].to_json)
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_json(*)
|
data/lib/workos/sso.rb
CHANGED
@@ -88,6 +88,23 @@ module WorkOS
|
|
88
88
|
"https://#{WorkOS::API_HOSTNAME}/sso/authorize?#{query}"
|
89
89
|
end
|
90
90
|
|
91
|
+
sig do
|
92
|
+
params(
|
93
|
+
access_token: String,
|
94
|
+
).returns(WorkOS::Profile)
|
95
|
+
end
|
96
|
+
def get_profile(access_token:)
|
97
|
+
response = execute_request(
|
98
|
+
request: get_request(
|
99
|
+
path: '/sso/profile',
|
100
|
+
auth: true,
|
101
|
+
access_token: access_token,
|
102
|
+
),
|
103
|
+
)
|
104
|
+
|
105
|
+
WorkOS::Profile.new(response.body)
|
106
|
+
end
|
107
|
+
|
91
108
|
# Fetch the profile details for the authenticated SSO user.
|
92
109
|
#
|
93
110
|
# @param [String] code The authorization code provided in the callback URL
|
data/lib/workos/version.rb
CHANGED
data/spec/lib/workos/sso_spec.rb
CHANGED
@@ -149,6 +149,37 @@ describe WorkOS::SSO do
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
+
describe '.get_profile' do
|
153
|
+
it 'returns a profile' do
|
154
|
+
VCR.use_cassette 'sso/profile' do
|
155
|
+
profile = described_class.get_profile(access_token: 'access_token')
|
156
|
+
|
157
|
+
expectation = {
|
158
|
+
connection_id: 'conn_01E83FVYZHY7DM4S9503JHV0R5',
|
159
|
+
connection_type: 'GoogleOAuth',
|
160
|
+
email: 'bob.loblaw@workos.com',
|
161
|
+
first_name: 'Bob',
|
162
|
+
id: 'prof_01EEJTY9SZ1R350RB7B73SNBKF',
|
163
|
+
idp_id: '116485463307139932699',
|
164
|
+
last_name: 'Loblaw',
|
165
|
+
raw_attributes: {
|
166
|
+
email: 'bob.loblaw@workos.com',
|
167
|
+
family_name: 'Loblaw',
|
168
|
+
given_name: 'Bob',
|
169
|
+
hd: 'workos.com',
|
170
|
+
id: '116485463307139932699',
|
171
|
+
locale: 'en',
|
172
|
+
name: 'Bob Loblaw',
|
173
|
+
picture: 'https://lh3.googleusercontent.com/a-/AOh14GyO2hLlgZvteDQ3Ldi3_-RteZLya0hWH7247Cam=s96-c',
|
174
|
+
verified_email: true,
|
175
|
+
},
|
176
|
+
}
|
177
|
+
|
178
|
+
expect(profile.to_json).to eq(expectation)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
152
183
|
describe '.profile_and_token' do
|
153
184
|
let(:args) do
|
154
185
|
{
|
@@ -0,0 +1,74 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.workos.com/sso/profile
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ""
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
User-Agent:
|
17
|
+
- WorkOS; ruby/3.0.1; arm64-darwin20; v1.0.0
|
18
|
+
Authorization:
|
19
|
+
- Bearer access_token
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- Cowboy
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Vary:
|
30
|
+
- Origin, Accept-Encoding
|
31
|
+
Access-Control-Allow-Credentials:
|
32
|
+
- "true"
|
33
|
+
Content-Security-Policy:
|
34
|
+
- "default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self'
|
35
|
+
https: data:;frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src
|
36
|
+
'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests"
|
37
|
+
X-Dns-Prefetch-Control:
|
38
|
+
- "off"
|
39
|
+
Expect-Ct:
|
40
|
+
- max-age=0
|
41
|
+
X-Frame-Options:
|
42
|
+
- SAMEORIGIN
|
43
|
+
Strict-Transport-Security:
|
44
|
+
- max-age=15552000; includeSubDomains
|
45
|
+
X-Download-Options:
|
46
|
+
- noopen
|
47
|
+
X-Content-Type-Options:
|
48
|
+
- nosniff
|
49
|
+
X-Permitted-Cross-Domain-Policies:
|
50
|
+
- none
|
51
|
+
Referrer-Policy:
|
52
|
+
- no-referrer
|
53
|
+
X-Xss-Protection:
|
54
|
+
- "0"
|
55
|
+
X-Request-Id:
|
56
|
+
- 45f253d6-51bb-4171-879a-d532f0275044
|
57
|
+
Content-Type:
|
58
|
+
- application/json; charset=utf-8
|
59
|
+
Content-Length:
|
60
|
+
- "545"
|
61
|
+
Etag:
|
62
|
+
- W/"221-LoXMZbv3vrn7lnJvNn6G/pqr7+c"
|
63
|
+
Date:
|
64
|
+
- Tue, 18 May 2021 22:55:21 GMT
|
65
|
+
Via:
|
66
|
+
- 1.1 vegur
|
67
|
+
body:
|
68
|
+
encoding: UTF-8
|
69
|
+
string:
|
70
|
+
'{"object":"profile","id":"prof_01EEJTY9SZ1R350RB7B73SNBKF","connection_id":"conn_01E83FVYZHY7DM4S9503JHV0R5","connection_type":"GoogleOAuth","idp_id":"116485463307139932699","email":"bob.loblaw@workos.com","first_name":"Bob","last_name":"Loblaw","raw_attributes":{"hd":"workos.com","id":"116485463307139932699","name":"Bob
|
71
|
+
Loblaw","email":"bob.loblaw@workos.com","locale":"en","picture":"https://lh3.googleusercontent.com/a-/AOh14GyO2hLlgZvteDQ3Ldi3_-RteZLya0hWH7247Cam=s96-c","given_name":"Bob","family_name":"Loblaw","verified_email":true}}'
|
72
|
+
http_version:
|
73
|
+
recorded_at: Tue, 18 May 2021 22:55:21 GMT
|
74
|
+
recorded_with: VCR 5.0.0
|
data/workos.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: 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
|
- WorkOS
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorbet-runtime
|
@@ -332,6 +332,7 @@ files:
|
|
332
332
|
- spec/support/fixtures/vcr_cassettes/sso/list_connections/with_limit.yml
|
333
333
|
- spec/support/fixtures/vcr_cassettes/sso/list_connections/with_no_options.yml
|
334
334
|
- spec/support/fixtures/vcr_cassettes/sso/list_connections/with_organization_id.yml
|
335
|
+
- spec/support/fixtures/vcr_cassettes/sso/profile.yml
|
335
336
|
- spec/support/profile.txt
|
336
337
|
- workos.gemspec
|
337
338
|
homepage: https://github.com/workos-inc/workos-ruby
|
@@ -345,9 +346,9 @@ require_paths:
|
|
345
346
|
- lib
|
346
347
|
required_ruby_version: !ruby/object:Gem::Requirement
|
347
348
|
requirements:
|
348
|
-
- - "
|
349
|
+
- - ">="
|
349
350
|
- !ruby/object:Gem::Version
|
350
|
-
version: '
|
351
|
+
version: '2.5'
|
351
352
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
352
353
|
requirements:
|
353
354
|
- - ">="
|
@@ -422,4 +423,5 @@ test_files:
|
|
422
423
|
- spec/support/fixtures/vcr_cassettes/sso/list_connections/with_limit.yml
|
423
424
|
- spec/support/fixtures/vcr_cassettes/sso/list_connections/with_no_options.yml
|
424
425
|
- spec/support/fixtures/vcr_cassettes/sso/list_connections/with_organization_id.yml
|
426
|
+
- spec/support/fixtures/vcr_cassettes/sso/profile.yml
|
425
427
|
- spec/support/profile.txt
|