workos 5.12.0 → 5.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/workos/session.rb +1 -0
- data/lib/workos/version.rb +1 -1
- data/spec/lib/workos/session_spec.rb +46 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a70c9c63f286f0ec63436cc9d4d04d20f0cab14cffc5946bfb3e9725db014f7a
|
4
|
+
data.tar.gz: b3ed8ecca83aad20d9a91674c27066ecb2a8019b4cd43173cfad01c10195653a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55692378591903208dd90c471d38eca8a0597adecac109329a277688ad92275e573e9d7110f3a8e58e06c0d78c3134e52e0924ca42e036bef01d337ef00bdde3
|
7
|
+
data.tar.gz: edc0f7070cb311f43d7d77e6ae29e1afeb6695a04a85b9c6ac50cdd733fb0ae4dbc317ca88d2f468ef0f434e8551904a558ad70fad1857ab3bbb7c0362ea9fe3
|
data/Gemfile.lock
CHANGED
data/lib/workos/session.rb
CHANGED
data/lib/workos/version.rb
CHANGED
@@ -103,24 +103,23 @@ describe WorkOS::Session do
|
|
103
103
|
|
104
104
|
describe '.authenticate' do
|
105
105
|
let(:user_management) { instance_double('UserManagement') }
|
106
|
-
let(:
|
107
|
-
|
106
|
+
let(:payload) do
|
107
|
+
{
|
108
108
|
sid: 'session_id',
|
109
109
|
org_id: 'org_id',
|
110
110
|
role: 'role',
|
111
111
|
permissions: ['read'],
|
112
112
|
exp: Time.now.to_i + 3600,
|
113
113
|
}
|
114
|
-
headers = { kid: jwk[:kid] }
|
115
|
-
JWT.encode(payload, jwk.signing_key, jwk[:alg], headers)
|
116
114
|
end
|
115
|
+
let(:valid_access_token) { JWT.encode(payload, jwk.signing_key, jwk[:alg], { kid: jwk[:kid] }) }
|
117
116
|
let(:session_data) do
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
end
|
117
|
+
WorkOS::Session.seal_data({
|
118
|
+
access_token: valid_access_token,
|
119
|
+
user: 'user',
|
120
|
+
impersonator: 'impersonator',
|
121
|
+
}, cookie_password,)
|
122
|
+
end
|
124
123
|
|
125
124
|
before do
|
126
125
|
allow(user_management).to receive(:get_jwks_url).with(client_id).and_return(jwks_url)
|
@@ -167,14 +166,7 @@ end
|
|
167
166
|
session_data: session_data,
|
168
167
|
cookie_password: cookie_password,
|
169
168
|
)
|
170
|
-
|
171
|
-
allow(JWT).to receive(:decode).and_return([{
|
172
|
-
'sid' => 'session_id',
|
173
|
-
'org_id' => 'org_id',
|
174
|
-
'role' => 'role',
|
175
|
-
'permissions' => ['read'],
|
176
|
-
}])
|
177
|
-
|
169
|
+
allow_any_instance_of(JWT::Decode).to receive(:verify_signature).and_return(true)
|
178
170
|
result = session.authenticate
|
179
171
|
expect(result).to eq({
|
180
172
|
authenticated: true,
|
@@ -182,11 +174,47 @@ end
|
|
182
174
|
organization_id: 'org_id',
|
183
175
|
role: 'role',
|
184
176
|
permissions: ['read'],
|
177
|
+
entitlements: nil,
|
185
178
|
user: 'user',
|
186
179
|
impersonator: 'impersonator',
|
187
180
|
reason: nil,
|
188
181
|
})
|
189
182
|
end
|
183
|
+
|
184
|
+
describe 'with entitlements' do
|
185
|
+
let(:payload) do
|
186
|
+
{
|
187
|
+
sid: 'session_id',
|
188
|
+
org_id: 'org_id',
|
189
|
+
role: 'role',
|
190
|
+
permissions: ['read'],
|
191
|
+
entitlements: ['billing'],
|
192
|
+
exp: Time.now.to_i + 3600,
|
193
|
+
}
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'includes entitlements in the result' do
|
197
|
+
session = WorkOS::Session.new(
|
198
|
+
user_management: user_management,
|
199
|
+
client_id: client_id,
|
200
|
+
session_data: session_data,
|
201
|
+
cookie_password: cookie_password,
|
202
|
+
)
|
203
|
+
allow_any_instance_of(JWT::Decode).to receive(:verify_signature).and_return(true)
|
204
|
+
result = session.authenticate
|
205
|
+
expect(result).to eq({
|
206
|
+
authenticated: true,
|
207
|
+
session_id: 'session_id',
|
208
|
+
organization_id: 'org_id',
|
209
|
+
role: 'role',
|
210
|
+
permissions: ['read'],
|
211
|
+
entitlements: ['billing'],
|
212
|
+
user: 'user',
|
213
|
+
impersonator: 'impersonator',
|
214
|
+
reason: nil,
|
215
|
+
})
|
216
|
+
end
|
217
|
+
end
|
190
218
|
end
|
191
219
|
|
192
220
|
describe '.refresh' do
|
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: 5.
|
4
|
+
version: 5.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WorkOS
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: encryptor
|