workos 5.30.0__tar.gz → 5.31.1__tar.gz
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.
- {workos-5.30.0 → workos-5.31.1}/PKG-INFO +1 -1
- {workos-5.30.0 → workos-5.31.1}/tests/test_session.py +7 -0
- workos-5.31.1/tests/test_user_management_list_sessions.py +73 -0
- workos-5.31.1/tests/test_user_management_revoke_session.py +26 -0
- {workos-5.30.0 → workos-5.31.1}/workos/__about__.py +1 -1
- {workos-5.30.0 → workos-5.31.1}/workos/session.py +4 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/list_resource.py +2 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/__init__.py +1 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/list_filters.py +4 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/session.py +32 -0
- {workos-5.30.0 → workos-5.31.1}/workos/user_management.py +113 -0
- {workos-5.30.0 → workos-5.31.1}/workos.egg-info/PKG-INFO +1 -1
- {workos-5.30.0 → workos-5.31.1}/workos.egg-info/SOURCES.txt +2 -0
- {workos-5.30.0 → workos-5.31.1}/LICENSE +0 -0
- {workos-5.30.0 → workos-5.31.1}/README.md +0 -0
- {workos-5.30.0 → workos-5.31.1}/setup.cfg +0 -0
- {workos-5.30.0 → workos-5.31.1}/setup.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_async_http_client.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_audit_logs.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_client.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_directory_sync.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_events.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_fga.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_mfa.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_organization_domains.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_organizations.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_passwordless.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_portal.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_sso.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_sync_http_client.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_user_management.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_vault.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_webhooks.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/tests/test_widgets.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/_base_client.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/_client_configuration.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/async_client.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/audit_logs.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/client.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/directory_sync.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/events.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/exceptions.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/fga.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/mfa.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/organization_domains.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/organizations.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/passwordless.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/portal.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/py.typed +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/sso.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/audit_logs/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/audit_logs/audit_log_event.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/audit_logs/audit_log_event_actor.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/audit_logs/audit_log_event_context.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/audit_logs/audit_log_event_target.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/audit_logs/audit_log_export.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/audit_logs/audit_log_metadata.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/directory_sync/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/directory_sync/directory.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/directory_sync/directory_group.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/directory_sync/directory_state.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/directory_sync/directory_type.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/directory_sync/directory_user.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/directory_sync/list_filters.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/events/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/events/authentication_payload.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/events/connection_payload_with_legacy_fields.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/events/directory_group_membership_payload.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/events/directory_group_with_previous_attributes.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/events/directory_payload.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/events/directory_payload_with_legacy_fields.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/events/directory_user_with_previous_attributes.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/events/event.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/events/event_model.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/events/event_type.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/events/list_filters.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/events/organization_domain_verification_failed_payload.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/events/previous_attributes.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/events/session_created_payload.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/feature_flags/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/feature_flags/feature_flag.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/feature_flags/list_filters.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/fga/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/fga/authorization_resource_types.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/fga/authorization_resources.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/fga/check.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/fga/list_filters.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/fga/warnings.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/fga/warrant.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/metadata.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/mfa/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/mfa/authentication_challenge.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/mfa/authentication_challenge_verification_response.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/mfa/authentication_factor.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/mfa/authentication_factor_totp_and_challenge_response.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/mfa/enroll_authentication_factor_type.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/organization_domains/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/organization_domains/organization_domain.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/organizations/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/organizations/domain_data_input.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/organizations/list_filters.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/organizations/organization.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/organizations/organization_common.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/passwordless/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/passwordless/passwordless_session.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/passwordless/passwordless_session_type.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/portal/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/portal/portal_link.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/portal/portal_link_intent.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/portal/portal_link_intent_options.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/roles/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/roles/role.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/sso/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/sso/connection.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/sso/connection_domain.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/sso/profile.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/sso/sso_provider_type.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/authenticate_with_common.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/authentication_response.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/email_verification.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/impersonator.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/invitation.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/magic_auth.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/oauth_tokens.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/organization_membership.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/password_hash_type.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/password_reset.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/screen_hint.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/user.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/user_management/user_management_provider_type.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/vault/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/vault/key.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/vault/object.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/webhooks/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/webhooks/webhook.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/webhooks/webhook_model.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/webhooks/webhook_payload.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/widgets/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/widgets/widget_scope.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/widgets/widget_token_response.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/types/workos_model.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/typing/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/typing/literals.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/typing/sync_or_async.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/typing/untyped_literal.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/typing/webhooks.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/utils/__init__.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/utils/_base_http_client.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/utils/crypto_provider.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/utils/http_client.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/utils/pagination_order.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/utils/request_helper.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/vault.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/webhooks.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos/widgets.py +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos.egg-info/dependency_links.txt +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos.egg-info/not-zip-safe +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos.egg-info/requires.txt +0 -0
- {workos-5.30.0 → workos-5.31.1}/workos.egg-info/top_level.txt +0 -0
|
@@ -51,6 +51,7 @@ class SessionFixtures:
|
|
|
51
51
|
"roles": ["admin"],
|
|
52
52
|
"permissions": ["read"],
|
|
53
53
|
"entitlements": ["feature_1"],
|
|
54
|
+
"feature_flags": ["flag1", "flag2"],
|
|
54
55
|
"exp": int(current_datetime.timestamp()) + 3600,
|
|
55
56
|
"iat": int(current_datetime.timestamp()),
|
|
56
57
|
}
|
|
@@ -244,6 +245,7 @@ class TestSessionBase(SessionFixtures):
|
|
|
244
245
|
"roles": ["admin"],
|
|
245
246
|
"permissions": ["read"],
|
|
246
247
|
"entitlements": ["feature_1"],
|
|
248
|
+
"feature_flags": ["flag1", "flag2"],
|
|
247
249
|
}
|
|
248
250
|
|
|
249
251
|
with patch.object(Session, "unseal_data", return_value=mock_session), patch(
|
|
@@ -263,6 +265,7 @@ class TestSessionBase(SessionFixtures):
|
|
|
263
265
|
assert response.roles == ["admin"]
|
|
264
266
|
assert response.permissions == ["read"]
|
|
265
267
|
assert response.entitlements == ["feature_1"]
|
|
268
|
+
assert response.feature_flags == ["flag1", "flag2"]
|
|
266
269
|
assert response.user.id == session_constants["USER_ID"]
|
|
267
270
|
assert response.impersonator is None
|
|
268
271
|
|
|
@@ -312,6 +315,7 @@ class TestSessionBase(SessionFixtures):
|
|
|
312
315
|
"roles": ["admin", "member"],
|
|
313
316
|
"permissions": ["read", "write"],
|
|
314
317
|
"entitlements": ["feature_1"],
|
|
318
|
+
"feature_flags": ["flag1", "flag2"],
|
|
315
319
|
}
|
|
316
320
|
|
|
317
321
|
with patch.object(Session, "unseal_data", return_value=mock_session), patch(
|
|
@@ -331,6 +335,7 @@ class TestSessionBase(SessionFixtures):
|
|
|
331
335
|
assert response.roles == ["admin", "member"]
|
|
332
336
|
assert response.permissions == ["read", "write"]
|
|
333
337
|
assert response.entitlements == ["feature_1"]
|
|
338
|
+
assert response.feature_flags == ["flag1", "flag2"]
|
|
334
339
|
assert response.user.id == session_constants["USER_ID"]
|
|
335
340
|
assert response.impersonator is None
|
|
336
341
|
|
|
@@ -410,6 +415,7 @@ class TestSession(SessionFixtures):
|
|
|
410
415
|
"roles": ["admin"],
|
|
411
416
|
"permissions": ["read"],
|
|
412
417
|
"entitlements": ["feature_1"],
|
|
418
|
+
"feature_flags": ["flag1", "flag2"],
|
|
413
419
|
},
|
|
414
420
|
):
|
|
415
421
|
response = session.refresh()
|
|
@@ -511,6 +517,7 @@ class TestAsyncSession(SessionFixtures):
|
|
|
511
517
|
"roles": ["admin"],
|
|
512
518
|
"permissions": ["read"],
|
|
513
519
|
"entitlements": ["feature_1"],
|
|
520
|
+
"feature_flags": ["flag1", "flag2"],
|
|
514
521
|
},
|
|
515
522
|
):
|
|
516
523
|
response = await session.refresh()
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from typing import Union
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from tests.utils.list_resource import list_response_of
|
|
6
|
+
from tests.utils.syncify import syncify
|
|
7
|
+
from tests.types.test_auto_pagination_function import TestAutoPaginationFunction
|
|
8
|
+
from workos.user_management import AsyncUserManagement, UserManagement
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _mock_session(id: str):
|
|
12
|
+
now = "2025-07-23T14:00:00.000Z"
|
|
13
|
+
return {
|
|
14
|
+
"object": "session",
|
|
15
|
+
"id": id,
|
|
16
|
+
"user_id": "user_123",
|
|
17
|
+
"organization_id": "org_123",
|
|
18
|
+
"status": "active",
|
|
19
|
+
"auth_method": "password",
|
|
20
|
+
"impersonator": None,
|
|
21
|
+
"ip_address": "192.168.1.1",
|
|
22
|
+
"user_agent": "Mozilla/5.0",
|
|
23
|
+
"expires_at": "2025-07-23T15:00:00.000Z",
|
|
24
|
+
"ended_at": None,
|
|
25
|
+
"created_at": now,
|
|
26
|
+
"updated_at": now,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@pytest.mark.sync_and_async(UserManagement, AsyncUserManagement)
|
|
31
|
+
class TestUserManagementListSessions:
|
|
32
|
+
@pytest.fixture(autouse=True)
|
|
33
|
+
def setup(self, module_instance: Union[UserManagement, AsyncUserManagement]):
|
|
34
|
+
self.http_client = module_instance._http_client
|
|
35
|
+
self.user_management = module_instance
|
|
36
|
+
|
|
37
|
+
def test_list_sessions_query_and_parsing(
|
|
38
|
+
self, capture_and_mock_http_client_request
|
|
39
|
+
):
|
|
40
|
+
sessions = [_mock_session("session_1"), _mock_session("session_2")]
|
|
41
|
+
response = list_response_of(data=sessions)
|
|
42
|
+
request_kwargs = capture_and_mock_http_client_request(
|
|
43
|
+
self.http_client, response, 200
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
result = syncify(
|
|
47
|
+
self.user_management.list_sessions(
|
|
48
|
+
user_id="user_123", limit=10, before="before_id", order="desc"
|
|
49
|
+
)
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
assert request_kwargs["url"].endswith("user_management/users/user_123/sessions")
|
|
53
|
+
assert request_kwargs["method"] == "get"
|
|
54
|
+
assert request_kwargs["params"]["limit"] == 10
|
|
55
|
+
assert request_kwargs["params"]["before"] == "before_id"
|
|
56
|
+
assert request_kwargs["params"]["order"] == "desc"
|
|
57
|
+
assert "after" not in request_kwargs["params"]
|
|
58
|
+
assert len(result.data) == 2
|
|
59
|
+
assert result.data[0].id == "session_1"
|
|
60
|
+
assert result.list_metadata.before is None
|
|
61
|
+
assert result.list_metadata.after is None
|
|
62
|
+
|
|
63
|
+
def test_list_sessions_auto_pagination(
|
|
64
|
+
self, test_auto_pagination: TestAutoPaginationFunction
|
|
65
|
+
):
|
|
66
|
+
data = [_mock_session(str(i)) for i in range(40)]
|
|
67
|
+
test_auto_pagination(
|
|
68
|
+
http_client=self.http_client,
|
|
69
|
+
list_function=self.user_management.list_sessions,
|
|
70
|
+
list_function_params={"user_id": "user_123"},
|
|
71
|
+
expected_all_page_data=data,
|
|
72
|
+
url_path_keys=["user_id"],
|
|
73
|
+
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from typing import Union
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from tests.utils.syncify import syncify
|
|
6
|
+
from workos.user_management import AsyncUserManagement, UserManagement
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@pytest.mark.sync_and_async(UserManagement, AsyncUserManagement)
|
|
10
|
+
class TestUserManagementRevokeSession:
|
|
11
|
+
@pytest.fixture(autouse=True)
|
|
12
|
+
def setup(self, module_instance: Union[UserManagement, AsyncUserManagement]):
|
|
13
|
+
self.http_client = module_instance._http_client
|
|
14
|
+
self.user_management = module_instance
|
|
15
|
+
|
|
16
|
+
def test_revoke_session(self, capture_and_mock_http_client_request):
|
|
17
|
+
request_kwargs = capture_and_mock_http_client_request(self.http_client, {}, 200)
|
|
18
|
+
|
|
19
|
+
response = syncify(
|
|
20
|
+
self.user_management.revoke_session(session_id="session_abc")
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
assert request_kwargs["url"].endswith("user_management/sessions/revoke")
|
|
24
|
+
assert request_kwargs["method"] == "post"
|
|
25
|
+
assert request_kwargs["json"] == {"session_id": "session_abc"}
|
|
26
|
+
assert response is None
|
|
@@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, List, Protocol
|
|
|
4
4
|
from functools import lru_cache
|
|
5
5
|
import json
|
|
6
6
|
from typing import Any, Dict, Optional, Union, cast
|
|
7
|
+
|
|
7
8
|
import jwt
|
|
8
9
|
from jwt import PyJWKClient
|
|
9
10
|
from cryptography.fernet import Fernet
|
|
@@ -107,6 +108,7 @@ class SessionModule(Protocol):
|
|
|
107
108
|
entitlements=decoded.get("entitlements", None),
|
|
108
109
|
user=session["user"],
|
|
109
110
|
impersonator=session.get("impersonator", None),
|
|
111
|
+
feature_flags=decoded.get("feature_flags", None),
|
|
110
112
|
)
|
|
111
113
|
|
|
112
114
|
def refresh(
|
|
@@ -235,6 +237,7 @@ class Session(SessionModule):
|
|
|
235
237
|
entitlements=decoded.get("entitlements", None),
|
|
236
238
|
user=auth_response.user,
|
|
237
239
|
impersonator=auth_response.impersonator,
|
|
240
|
+
feature_flags=decoded.get("feature_flags", None),
|
|
238
241
|
)
|
|
239
242
|
except Exception as e:
|
|
240
243
|
return RefreshWithSessionCookieErrorResponse(
|
|
@@ -326,6 +329,7 @@ class AsyncSession(SessionModule):
|
|
|
326
329
|
entitlements=decoded.get("entitlements", None),
|
|
327
330
|
user=auth_response.user,
|
|
328
331
|
impersonator=auth_response.impersonator,
|
|
332
|
+
feature_flags=decoded.get("feature_flags", None),
|
|
329
333
|
)
|
|
330
334
|
except Exception as e:
|
|
331
335
|
return RefreshWithSessionCookieErrorResponse(
|
|
@@ -34,6 +34,7 @@ from workos.types.mfa import AuthenticationFactor
|
|
|
34
34
|
from workos.types.organizations import Organization
|
|
35
35
|
from workos.types.sso import ConnectionWithDomains
|
|
36
36
|
from workos.types.user_management import Invitation, OrganizationMembership, User
|
|
37
|
+
from workos.types.user_management.session import Session as UserManagementSession
|
|
37
38
|
from workos.types.vault import ObjectDigest
|
|
38
39
|
from workos.types.workos_model import WorkOSModel
|
|
39
40
|
from workos.utils.request_helper import DEFAULT_LIST_RESPONSE_LIMIT
|
|
@@ -54,6 +55,7 @@ ListableResource = TypeVar(
|
|
|
54
55
|
AuthorizationResource,
|
|
55
56
|
AuthorizationResourceType,
|
|
56
57
|
User,
|
|
58
|
+
UserManagementSession,
|
|
57
59
|
ObjectDigest,
|
|
58
60
|
Warrant,
|
|
59
61
|
WarrantQueryResult,
|
|
@@ -24,6 +24,7 @@ class AuthenticateWithSessionCookieSuccessResponse(WorkOSModel):
|
|
|
24
24
|
user: User
|
|
25
25
|
impersonator: Optional[Impersonator] = None
|
|
26
26
|
entitlements: Optional[Sequence[str]] = None
|
|
27
|
+
feature_flags: Optional[Sequence[str]] = None
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
class AuthenticateWithSessionCookieErrorResponse(WorkOSModel):
|
|
@@ -45,3 +46,34 @@ class RefreshWithSessionCookieErrorResponse(WorkOSModel):
|
|
|
45
46
|
class SessionConfig(TypedDict, total=False):
|
|
46
47
|
seal_session: bool
|
|
47
48
|
cookie_password: str
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
AuthMethodType = Literal[
|
|
52
|
+
"external_auth",
|
|
53
|
+
"impersonation",
|
|
54
|
+
"magic_code",
|
|
55
|
+
"migrated_session",
|
|
56
|
+
"oauth",
|
|
57
|
+
"passkey",
|
|
58
|
+
"password",
|
|
59
|
+
"sso",
|
|
60
|
+
"unknown",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class Session(WorkOSModel):
|
|
65
|
+
"""Representation of a WorkOS User Management Session."""
|
|
66
|
+
|
|
67
|
+
object: Literal["session"]
|
|
68
|
+
id: str
|
|
69
|
+
user_id: str
|
|
70
|
+
organization_id: Optional[str] = None
|
|
71
|
+
status: str
|
|
72
|
+
auth_method: AuthMethodType
|
|
73
|
+
impersonator: Optional[Impersonator] = None
|
|
74
|
+
ip_address: Optional[str] = None
|
|
75
|
+
user_agent: Optional[str] = None
|
|
76
|
+
expires_at: str
|
|
77
|
+
ended_at: Optional[str] = None
|
|
78
|
+
created_at: str
|
|
79
|
+
updated_at: str
|
|
@@ -48,6 +48,7 @@ from workos.types.user_management.list_filters import (
|
|
|
48
48
|
from workos.types.user_management.password_hash_type import PasswordHashType
|
|
49
49
|
from workos.types.user_management.screen_hint import ScreenHintType
|
|
50
50
|
from workos.types.user_management.session import SessionConfig
|
|
51
|
+
from workos.types.user_management.session import Session as UserManagementSession
|
|
51
52
|
from workos.types.user_management.user_management_provider_type import (
|
|
52
53
|
UserManagementProviderType,
|
|
53
54
|
)
|
|
@@ -86,6 +87,8 @@ MAGIC_AUTH_DETAIL_PATH = "user_management/magic_auth/{0}"
|
|
|
86
87
|
MAGIC_AUTH_PATH = "user_management/magic_auth"
|
|
87
88
|
USER_SEND_MAGIC_AUTH_PATH = "user_management/magic_auth/send"
|
|
88
89
|
USER_AUTH_FACTORS_PATH = "user_management/users/{0}/auth_factors"
|
|
90
|
+
USER_SESSIONS_PATH = "user_management/users/{0}/sessions"
|
|
91
|
+
SESSIONS_REVOKE_PATH = "user_management/sessions/revoke"
|
|
89
92
|
EMAIL_VERIFICATION_DETAIL_PATH = "user_management/email_verification/{0}"
|
|
90
93
|
INVITATION_PATH = "user_management/invitations"
|
|
91
94
|
INVITATION_DETAIL_PATH = "user_management/invitations/{0}"
|
|
@@ -109,6 +112,12 @@ InvitationsListResource = WorkOSListResource[
|
|
|
109
112
|
Invitation, InvitationsListFilters, ListMetadata
|
|
110
113
|
]
|
|
111
114
|
|
|
115
|
+
from workos.types.user_management.list_filters import SessionsListFilters
|
|
116
|
+
|
|
117
|
+
SessionsListResource = WorkOSListResource[
|
|
118
|
+
UserManagementSession, SessionsListFilters, ListMetadata
|
|
119
|
+
]
|
|
120
|
+
|
|
112
121
|
|
|
113
122
|
class UserManagementModule(Protocol):
|
|
114
123
|
"""Offers methods for using the WorkOS User Management API."""
|
|
@@ -720,6 +729,18 @@ class UserManagementModule(Protocol):
|
|
|
720
729
|
"""
|
|
721
730
|
...
|
|
722
731
|
|
|
732
|
+
def list_sessions(
|
|
733
|
+
self,
|
|
734
|
+
*,
|
|
735
|
+
user_id: str,
|
|
736
|
+
limit: Optional[int] = None,
|
|
737
|
+
before: Optional[str] = None,
|
|
738
|
+
after: Optional[str] = None,
|
|
739
|
+
order: Optional[PaginationOrder] = "desc",
|
|
740
|
+
) -> SyncOrAsync["SessionsListResource"]: ...
|
|
741
|
+
|
|
742
|
+
def revoke_session(self, *, session_id: str) -> SyncOrAsync[None]: ...
|
|
743
|
+
|
|
723
744
|
def get_magic_auth(self, magic_auth_id: str) -> SyncOrAsync[MagicAuth]:
|
|
724
745
|
"""Get the details of a Magic Auth object.
|
|
725
746
|
|
|
@@ -1377,6 +1398,52 @@ class UserManagement(UserManagementModule):
|
|
|
1377
1398
|
|
|
1378
1399
|
return MagicAuth.model_validate(response)
|
|
1379
1400
|
|
|
1401
|
+
def list_sessions(
|
|
1402
|
+
self,
|
|
1403
|
+
*,
|
|
1404
|
+
user_id: str,
|
|
1405
|
+
limit: Optional[int] = DEFAULT_LIST_RESPONSE_LIMIT,
|
|
1406
|
+
before: Optional[str] = None,
|
|
1407
|
+
after: Optional[str] = None,
|
|
1408
|
+
order: Optional[PaginationOrder] = "desc",
|
|
1409
|
+
) -> "SessionsListResource":
|
|
1410
|
+
limit_value: int = limit if limit is not None else DEFAULT_LIST_RESPONSE_LIMIT
|
|
1411
|
+
|
|
1412
|
+
params: ListArgs = {
|
|
1413
|
+
"limit": limit_value,
|
|
1414
|
+
"before": before,
|
|
1415
|
+
"after": after,
|
|
1416
|
+
"order": order,
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
response = self._http_client.request(
|
|
1420
|
+
USER_SESSIONS_PATH.format(user_id),
|
|
1421
|
+
method=REQUEST_METHOD_GET,
|
|
1422
|
+
params=params,
|
|
1423
|
+
)
|
|
1424
|
+
|
|
1425
|
+
list_args: SessionsListFilters = {
|
|
1426
|
+
"limit": limit_value,
|
|
1427
|
+
"before": before,
|
|
1428
|
+
"after": after,
|
|
1429
|
+
"user_id": user_id,
|
|
1430
|
+
}
|
|
1431
|
+
if order is not None:
|
|
1432
|
+
list_args["order"] = order
|
|
1433
|
+
|
|
1434
|
+
return SessionsListResource(
|
|
1435
|
+
list_method=self.list_sessions,
|
|
1436
|
+
list_args=list_args,
|
|
1437
|
+
**ListPage[UserManagementSession](**response).model_dump(),
|
|
1438
|
+
)
|
|
1439
|
+
|
|
1440
|
+
def revoke_session(self, *, session_id: str) -> None:
|
|
1441
|
+
json = {"session_id": session_id}
|
|
1442
|
+
|
|
1443
|
+
self._http_client.request(
|
|
1444
|
+
SESSIONS_REVOKE_PATH, method=REQUEST_METHOD_POST, json=json
|
|
1445
|
+
)
|
|
1446
|
+
|
|
1380
1447
|
def enroll_auth_factor(
|
|
1381
1448
|
self,
|
|
1382
1449
|
*,
|
|
@@ -2033,6 +2100,52 @@ class AsyncUserManagement(UserManagementModule):
|
|
|
2033
2100
|
|
|
2034
2101
|
return MagicAuth.model_validate(response)
|
|
2035
2102
|
|
|
2103
|
+
async def list_sessions(
|
|
2104
|
+
self,
|
|
2105
|
+
*,
|
|
2106
|
+
user_id: str,
|
|
2107
|
+
limit: Optional[int] = DEFAULT_LIST_RESPONSE_LIMIT,
|
|
2108
|
+
before: Optional[str] = None,
|
|
2109
|
+
after: Optional[str] = None,
|
|
2110
|
+
order: Optional[PaginationOrder] = "desc",
|
|
2111
|
+
) -> "SessionsListResource":
|
|
2112
|
+
limit_value: int = limit if limit is not None else DEFAULT_LIST_RESPONSE_LIMIT
|
|
2113
|
+
|
|
2114
|
+
params: ListArgs = {
|
|
2115
|
+
"limit": limit_value,
|
|
2116
|
+
"before": before,
|
|
2117
|
+
"after": after,
|
|
2118
|
+
"order": order,
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
response = await self._http_client.request(
|
|
2122
|
+
USER_SESSIONS_PATH.format(user_id),
|
|
2123
|
+
method=REQUEST_METHOD_GET,
|
|
2124
|
+
params=params,
|
|
2125
|
+
)
|
|
2126
|
+
|
|
2127
|
+
list_args: SessionsListFilters = {
|
|
2128
|
+
"limit": limit_value,
|
|
2129
|
+
"before": before,
|
|
2130
|
+
"after": after,
|
|
2131
|
+
"user_id": user_id,
|
|
2132
|
+
}
|
|
2133
|
+
if order is not None:
|
|
2134
|
+
list_args["order"] = order
|
|
2135
|
+
|
|
2136
|
+
return SessionsListResource(
|
|
2137
|
+
list_method=self.list_sessions,
|
|
2138
|
+
list_args=list_args,
|
|
2139
|
+
**ListPage[UserManagementSession](**response).model_dump(),
|
|
2140
|
+
)
|
|
2141
|
+
|
|
2142
|
+
async def revoke_session(self, *, session_id: str) -> None:
|
|
2143
|
+
json = {"session_id": session_id}
|
|
2144
|
+
|
|
2145
|
+
await self._http_client.request(
|
|
2146
|
+
SESSIONS_REVOKE_PATH, method=REQUEST_METHOD_POST, json=json
|
|
2147
|
+
)
|
|
2148
|
+
|
|
2036
2149
|
async def enroll_auth_factor(
|
|
2037
2150
|
self,
|
|
2038
2151
|
*,
|
|
@@ -16,6 +16,8 @@ tests/test_session.py
|
|
|
16
16
|
tests/test_sso.py
|
|
17
17
|
tests/test_sync_http_client.py
|
|
18
18
|
tests/test_user_management.py
|
|
19
|
+
tests/test_user_management_list_sessions.py
|
|
20
|
+
tests/test_user_management_revoke_session.py
|
|
19
21
|
tests/test_vault.py
|
|
20
22
|
tests/test_webhooks.py
|
|
21
23
|
tests/test_widgets.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{workos-5.30.0 → workos-5.31.1}/workos/types/events/connection_payload_with_legacy_fields.py
RENAMED
|
File without changes
|
|
File without changes
|
{workos-5.30.0 → workos-5.31.1}/workos/types/events/directory_group_with_previous_attributes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{workos-5.30.0 → workos-5.31.1}/workos/types/events/directory_user_with_previous_attributes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{workos-5.30.0 → workos-5.31.1}/workos/types/mfa/authentication_challenge_verification_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{workos-5.30.0 → workos-5.31.1}/workos/types/user_management/user_management_provider_type.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|