workos 5.30.1 → 5.31.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 +4 -4
- data/.github/CODEOWNERS +1 -1
- data/.github/workflows/ci.yml +2 -2
- data/.github/workflows/release.yml +1 -1
- data/Gemfile.lock +3 -3
- data/context7.json +4 -0
- data/lib/workos/directory_sync.rb +1 -1
- data/lib/workos/user_management/session.rb +57 -0
- data/lib/workos/user_management.rb +36 -0
- data/lib/workos/version.rb +1 -1
- data/spec/lib/workos/user_management_spec.rb +39 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/list_sessions/valid.yml +38 -0
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 72ac2923fd0b63753144e3395e07af49589481edabf18df1c4d959ea92b56400
|
|
4
|
+
data.tar.gz: f9950ef319ff6001fd2ad1ce7d3f0ab2282e9fc8abc7f0c41fba69bc53bfb175
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b29d2a45d77c3242d2a970c14c30ed9b082cb8a2fb9447c32b8cb02d642deca29e7d044646deeba9a2de25ed971a801418b50e461ab6784fefa89353891eabb8
|
|
7
|
+
data.tar.gz: ef16608e192c0c8dffa249b8f37a83efa36897dfff75f87779c4cde3117fe2518f6535db63590465f8fcffe41cbf556397cc9b107c6f2cda2715dd324b651b00
|
data/.github/CODEOWNERS
CHANGED
data/.github/workflows/ci.yml
CHANGED
|
@@ -20,8 +20,8 @@ jobs:
|
|
|
20
20
|
- '3.1'
|
|
21
21
|
- '3.2'
|
|
22
22
|
steps:
|
|
23
|
-
- uses: actions/checkout@
|
|
24
|
-
- uses: ruby/setup-ruby@
|
|
23
|
+
- uses: actions/checkout@v6
|
|
24
|
+
- uses: ruby/setup-ruby@675dd7ba1b06c8786a1480d89c384f5620a42647 # v1.281.0
|
|
25
25
|
with:
|
|
26
26
|
ruby-version: ${{ matrix.ruby }}
|
|
27
27
|
bundler-cache: true
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
workos (5.
|
|
4
|
+
workos (5.31.0)
|
|
5
5
|
encryptor (~> 3.0)
|
|
6
6
|
jwt (~> 2.8)
|
|
7
7
|
|
|
@@ -20,7 +20,7 @@ GEM
|
|
|
20
20
|
encryptor (3.0.0)
|
|
21
21
|
hashdiff (1.1.0)
|
|
22
22
|
json (2.9.1)
|
|
23
|
-
jwt (2.10.
|
|
23
|
+
jwt (2.10.2)
|
|
24
24
|
base64
|
|
25
25
|
language_server-protocol (3.17.0.3)
|
|
26
26
|
parallel (1.26.3)
|
|
@@ -31,7 +31,7 @@ GEM
|
|
|
31
31
|
racc (1.8.1)
|
|
32
32
|
rainbow (3.1.1)
|
|
33
33
|
regexp_parser (2.10.0)
|
|
34
|
-
rexml (3.4.
|
|
34
|
+
rexml (3.4.2)
|
|
35
35
|
rspec (3.9.0)
|
|
36
36
|
rspec-core (~> 3.9.0)
|
|
37
37
|
rspec-expectations (~> 3.9.0)
|
data/context7.json
ADDED
|
@@ -115,7 +115,7 @@ module WorkOS
|
|
|
115
115
|
# @param [Hash] options An options hash
|
|
116
116
|
# @option options [String] directory The ID of the directory whose
|
|
117
117
|
# directory users will be retrieved.
|
|
118
|
-
# @option options [String]
|
|
118
|
+
# @option options [String] group The ID of the directory group whose
|
|
119
119
|
# directory users will be retrieved.
|
|
120
120
|
# @option options [String] limit Maximum number of records to return.
|
|
121
121
|
# @option options [String] order The order in which to paginate records
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module WorkOS
|
|
4
|
+
module UserManagement
|
|
5
|
+
# The Session class provides a lightweight wrapper around
|
|
6
|
+
# a WorkOS Session resource. This class is not meant to be instantiated
|
|
7
|
+
# in user space, and is instantiated internally but exposed.
|
|
8
|
+
class Session
|
|
9
|
+
include HashProvider
|
|
10
|
+
attr_accessor :id, :object, :user_id, :organization_id, :status, :auth_method,
|
|
11
|
+
:ip_address, :user_agent, :expires_at, :ended_at, :created_at, :updated_at
|
|
12
|
+
|
|
13
|
+
# rubocop:disable Metrics/AbcSize
|
|
14
|
+
def initialize(json)
|
|
15
|
+
hash = JSON.parse(json, symbolize_names: true)
|
|
16
|
+
|
|
17
|
+
@id = hash[:id]
|
|
18
|
+
@object = hash[:object]
|
|
19
|
+
@user_id = hash[:user_id]
|
|
20
|
+
@organization_id = hash[:organization_id]
|
|
21
|
+
@status = hash[:status]
|
|
22
|
+
@auth_method = hash[:auth_method]
|
|
23
|
+
@ip_address = hash[:ip_address]
|
|
24
|
+
@user_agent = hash[:user_agent]
|
|
25
|
+
@expires_at = hash[:expires_at]
|
|
26
|
+
@ended_at = hash[:ended_at]
|
|
27
|
+
@created_at = hash[:created_at]
|
|
28
|
+
@updated_at = hash[:updated_at]
|
|
29
|
+
end
|
|
30
|
+
# rubocop:enable Metrics/AbcSize
|
|
31
|
+
|
|
32
|
+
def to_json(*)
|
|
33
|
+
{
|
|
34
|
+
id: id,
|
|
35
|
+
object: object,
|
|
36
|
+
user_id: user_id,
|
|
37
|
+
organization_id: organization_id,
|
|
38
|
+
status: status,
|
|
39
|
+
auth_method: auth_method,
|
|
40
|
+
ip_address: ip_address,
|
|
41
|
+
user_agent: user_agent,
|
|
42
|
+
expires_at: expires_at,
|
|
43
|
+
ended_at: ended_at,
|
|
44
|
+
created_at: created_at,
|
|
45
|
+
updated_at: updated_at,
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Revoke this session
|
|
50
|
+
#
|
|
51
|
+
# @return [Bool] - returns `true` if successful
|
|
52
|
+
def revoke
|
|
53
|
+
WorkOS::UserManagement.revoke_session(session_id: id)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -7,6 +7,8 @@ module WorkOS
|
|
|
7
7
|
# The UserManagement module provides convenience methods for working with the
|
|
8
8
|
# WorkOS User platform. You'll need a valid API key.
|
|
9
9
|
module UserManagement
|
|
10
|
+
autoload :Session, 'workos/user_management/session'
|
|
11
|
+
|
|
10
12
|
module Types
|
|
11
13
|
# The ProviderEnum is a declaration of a
|
|
12
14
|
# fixed set of values for User Management Providers.
|
|
@@ -740,6 +742,40 @@ module WorkOS
|
|
|
740
742
|
)
|
|
741
743
|
end
|
|
742
744
|
|
|
745
|
+
# Get all sessions for a user
|
|
746
|
+
#
|
|
747
|
+
# @param [String] user_id The id for the user.
|
|
748
|
+
# @param [Hash] options
|
|
749
|
+
# @option options [String] limit Maximum number of records to return.
|
|
750
|
+
# @option options [String] order The order in which to paginate records
|
|
751
|
+
# @option options [String] before Pagination cursor to receive records
|
|
752
|
+
# before a provided Session ID.
|
|
753
|
+
# @option options [String] after Pagination cursor to receive records
|
|
754
|
+
# after a provided Session ID.
|
|
755
|
+
#
|
|
756
|
+
# @return [WorkOS::Types::ListStruct<WorkOS::UserManagement::Session>]
|
|
757
|
+
def list_sessions(user_id:, options: {})
|
|
758
|
+
options[:order] ||= 'desc'
|
|
759
|
+
response = execute_request(
|
|
760
|
+
request: get_request(
|
|
761
|
+
path: "/user_management/users/#{user_id}/sessions",
|
|
762
|
+
auth: true,
|
|
763
|
+
params: options,
|
|
764
|
+
),
|
|
765
|
+
)
|
|
766
|
+
|
|
767
|
+
parsed_response = JSON.parse(response.body)
|
|
768
|
+
|
|
769
|
+
sessions = parsed_response['data'].map do |session|
|
|
770
|
+
::WorkOS::UserManagement::Session.new(session.to_json)
|
|
771
|
+
end
|
|
772
|
+
|
|
773
|
+
WorkOS::Types::ListStruct.new(
|
|
774
|
+
data: sessions,
|
|
775
|
+
list_metadata: parsed_response['list_metadata'],
|
|
776
|
+
)
|
|
777
|
+
end
|
|
778
|
+
|
|
743
779
|
# Gets an email verification object
|
|
744
780
|
#
|
|
745
781
|
# @param [String] id The unique ID of the EmailVerification object.
|
data/lib/workos/version.rb
CHANGED
|
@@ -1797,6 +1797,45 @@ describe WorkOS::UserManagement do
|
|
|
1797
1797
|
end
|
|
1798
1798
|
end
|
|
1799
1799
|
|
|
1800
|
+
describe '.list_sessions' do
|
|
1801
|
+
context 'with a valid user_id' do
|
|
1802
|
+
it 'returns a list of sessions' do
|
|
1803
|
+
VCR.use_cassette('user_management/list_sessions/valid') do
|
|
1804
|
+
result = described_class.list_sessions(
|
|
1805
|
+
user_id: 'user_01H7TVSKS45SDHN5V9XPSM6H44',
|
|
1806
|
+
)
|
|
1807
|
+
|
|
1808
|
+
expect(result.data).to be_an(Array)
|
|
1809
|
+
expect(result.data.first).to be_a(WorkOS::UserManagement::Session)
|
|
1810
|
+
expect(result.data.first.id).to eq('session_01H96FETXGTW2S0V5V9XPSM6H44')
|
|
1811
|
+
expect(result.data.first.status).to eq('active')
|
|
1812
|
+
expect(result.data.first.auth_method).to eq('password')
|
|
1813
|
+
end
|
|
1814
|
+
end
|
|
1815
|
+
|
|
1816
|
+
it 'returns sessions that can be revoked' do
|
|
1817
|
+
VCR.use_cassette('user_management/list_sessions/valid') do
|
|
1818
|
+
result = described_class.list_sessions(
|
|
1819
|
+
user_id: 'user_01H7TVSKS45SDHN5V9XPSM6H44',
|
|
1820
|
+
)
|
|
1821
|
+
session = result.data.first
|
|
1822
|
+
|
|
1823
|
+
expect(described_class).to receive(:post_request) do |options|
|
|
1824
|
+
expect(options[:path]).to eq('/user_management/sessions/revoke')
|
|
1825
|
+
expect(options[:body]).to eq({ session_id: 'session_01H96FETXGTW2S0V5V9XPSM6H44' })
|
|
1826
|
+
expect(options[:auth]).to be true
|
|
1827
|
+
end.and_return(double('request'))
|
|
1828
|
+
|
|
1829
|
+
expect(described_class).to receive(:execute_request).and_return(
|
|
1830
|
+
double('response', is_a?: true),
|
|
1831
|
+
)
|
|
1832
|
+
|
|
1833
|
+
expect(session.revoke).to be true
|
|
1834
|
+
end
|
|
1835
|
+
end
|
|
1836
|
+
end
|
|
1837
|
+
end
|
|
1838
|
+
|
|
1800
1839
|
describe '.get_logout_url' do
|
|
1801
1840
|
it 'returns a logout url for the given session ID' do
|
|
1802
1841
|
result = described_class.get_logout_url(
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://api.workos.com/user_management/users/user_01H7TVSKS45SDHN5V9XPSM6H44/sessions?order=desc
|
|
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.2; arm64-darwin22; v2.16.0
|
|
18
|
+
Authorization:
|
|
19
|
+
- Bearer <API_KEY>
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 200
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Date:
|
|
26
|
+
- Mon, 05 Jan 2026 12:00:00 GMT
|
|
27
|
+
Content-Type:
|
|
28
|
+
- application/json; charset=utf-8
|
|
29
|
+
Transfer-Encoding:
|
|
30
|
+
- chunked
|
|
31
|
+
Connection:
|
|
32
|
+
- keep-alive
|
|
33
|
+
body:
|
|
34
|
+
encoding: ASCII-8BIT
|
|
35
|
+
string: '{"object":"list","data":[{"object":"session","id":"session_01H96FETXGTW2S0V5V9XPSM6H44","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:146.0) Gecko/20100101 Firefox/146.0","ip_address":"192.168.1.1","organization_id":"org_01H96FETXGTW2SXRA136PCMAQJ0","user_id":"user_01H7TVSKS45SDHN5V9XPSM6H44","auth_method":"password","status":"active","expires_at":"2027-01-02T03:47:13.027Z","ended_at":null,"created_at":"2026-01-02T03:47:13.024Z","updated_at":"2026-01-05T02:56:09.379Z"}],"list_metadata":{"before":null,"after":null}}'
|
|
36
|
+
http_version:
|
|
37
|
+
recorded_at: Mon, 05 Jan 2026 12:00:00 GMT
|
|
38
|
+
recorded_with: VCR 5.0.0
|
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.31.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- WorkOS
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: encryptor
|
|
@@ -132,6 +132,7 @@ files:
|
|
|
132
132
|
- bin/build
|
|
133
133
|
- bin/console
|
|
134
134
|
- bin/publish
|
|
135
|
+
- context7.json
|
|
135
136
|
- lib/workos.rb
|
|
136
137
|
- lib/workos/audit_log_export.rb
|
|
137
138
|
- lib/workos/audit_logs.rb
|
|
@@ -181,6 +182,7 @@ files:
|
|
|
181
182
|
- lib/workos/user.rb
|
|
182
183
|
- lib/workos/user_and_token.rb
|
|
183
184
|
- lib/workos/user_management.rb
|
|
185
|
+
- lib/workos/user_management/session.rb
|
|
184
186
|
- lib/workos/user_response.rb
|
|
185
187
|
- lib/workos/verify_challenge.rb
|
|
186
188
|
- lib/workos/version.rb
|
|
@@ -360,6 +362,7 @@ files:
|
|
|
360
362
|
- spec/support/fixtures/vcr_cassettes/user_management/list_organization_memberships/no_options.yml
|
|
361
363
|
- spec/support/fixtures/vcr_cassettes/user_management/list_organization_memberships/with_options.yml
|
|
362
364
|
- spec/support/fixtures/vcr_cassettes/user_management/list_organization_memberships/with_statuses_option.yml
|
|
365
|
+
- spec/support/fixtures/vcr_cassettes/user_management/list_sessions/valid.yml
|
|
363
366
|
- spec/support/fixtures/vcr_cassettes/user_management/list_users/no_options.yml
|
|
364
367
|
- spec/support/fixtures/vcr_cassettes/user_management/list_users/with_options.yml
|
|
365
368
|
- spec/support/fixtures/vcr_cassettes/user_management/reactivate_organization_membership.yml
|
|
@@ -599,6 +602,7 @@ test_files:
|
|
|
599
602
|
- spec/support/fixtures/vcr_cassettes/user_management/list_organization_memberships/no_options.yml
|
|
600
603
|
- spec/support/fixtures/vcr_cassettes/user_management/list_organization_memberships/with_options.yml
|
|
601
604
|
- spec/support/fixtures/vcr_cassettes/user_management/list_organization_memberships/with_statuses_option.yml
|
|
605
|
+
- spec/support/fixtures/vcr_cassettes/user_management/list_sessions/valid.yml
|
|
602
606
|
- spec/support/fixtures/vcr_cassettes/user_management/list_users/no_options.yml
|
|
603
607
|
- spec/support/fixtures/vcr_cassettes/user_management/list_users/with_options.yml
|
|
604
608
|
- spec/support/fixtures/vcr_cassettes/user_management/reactivate_organization_membership.yml
|