workos 1.5.1__py3-none-any.whl → 5.38.0__py3-none-any.whl
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/__about__.py +1 -1
- workos/__init__.py +3 -7
- workos/_base_client.py +138 -0
- workos/_client_configuration.py +10 -0
- workos/api_keys.py +53 -0
- workos/async_client.py +144 -0
- workos/audit_logs.py +125 -0
- workos/client.py +110 -18
- workos/directory_sync.py +379 -99
- workos/events.py +111 -0
- workos/exceptions.py +53 -26
- workos/fga.py +649 -0
- workos/mfa.py +205 -0
- workos/organization_domains.py +179 -0
- workos/organizations.py +403 -73
- workos/passwordless.py +67 -43
- workos/pipes.py +93 -0
- workos/portal.py +51 -28
- workos/session.py +337 -0
- workos/sso.py +311 -101
- workos/types/__init__.py +4 -0
- workos/types/api_keys/__init__.py +1 -0
- workos/types/api_keys/api_keys.py +20 -0
- workos/types/audit_logs/__init__.py +6 -0
- workos/types/audit_logs/audit_log_event.py +16 -0
- workos/types/audit_logs/audit_log_event_actor.py +12 -0
- workos/types/audit_logs/audit_log_event_context.py +8 -0
- workos/types/audit_logs/audit_log_event_target.py +12 -0
- workos/types/audit_logs/audit_log_export.py +18 -0
- workos/types/audit_logs/audit_log_metadata.py +4 -0
- workos/types/directory_sync/__init__.py +5 -0
- workos/types/directory_sync/directory.py +31 -0
- workos/types/directory_sync/directory_group.py +16 -0
- workos/types/directory_sync/directory_state.py +28 -0
- workos/types/directory_sync/directory_type.py +24 -0
- workos/types/directory_sync/directory_user.py +50 -0
- workos/types/directory_sync/list_filters.py +21 -0
- workos/types/events/__init__.py +13 -0
- workos/types/events/authentication_payload.py +70 -0
- workos/types/events/connection_payload_with_legacy_fields.py +5 -0
- workos/types/events/directory_group_membership_payload.py +9 -0
- workos/types/events/directory_group_with_previous_attributes.py +6 -0
- workos/types/events/directory_payload.py +16 -0
- workos/types/events/directory_payload_with_legacy_fields.py +29 -0
- workos/types/events/directory_user_with_previous_attributes.py +6 -0
- workos/types/events/event.py +324 -0
- workos/types/events/event_model.py +103 -0
- workos/types/events/event_type.py +59 -0
- workos/types/events/list_filters.py +10 -0
- workos/types/events/organization_domain_verification_failed_payload.py +14 -0
- workos/types/events/previous_attributes.py +3 -0
- workos/types/events/session_payload.py +27 -0
- workos/types/feature_flags/__init__.py +3 -0
- workos/types/feature_flags/feature_flag.py +12 -0
- workos/types/feature_flags/list_filters.py +5 -0
- workos/types/fga/__init__.py +5 -0
- workos/types/fga/authorization_resource_types.py +9 -0
- workos/types/fga/authorization_resources.py +10 -0
- workos/types/fga/check.py +51 -0
- workos/types/fga/list_filters.py +24 -0
- workos/types/fga/warnings.py +33 -0
- workos/types/fga/warrant.py +49 -0
- workos/types/list_resource.py +198 -0
- workos/types/metadata.py +4 -0
- workos/types/mfa/__init__.py +5 -0
- workos/types/mfa/authentication_challenge.py +14 -0
- workos/types/mfa/authentication_challenge_verification_response.py +9 -0
- workos/types/mfa/authentication_factor.py +70 -0
- workos/types/mfa/authentication_factor_totp_and_challenge_response.py +10 -0
- workos/types/mfa/enroll_authentication_factor_type.py +8 -0
- workos/types/organization_domains/__init__.py +1 -0
- workos/types/organization_domains/organization_domain.py +18 -0
- workos/types/organizations/__init__.py +6 -0
- workos/types/organizations/domain_data_input.py +7 -0
- workos/types/organizations/list_filters.py +6 -0
- workos/types/organizations/organization.py +13 -0
- workos/types/organizations/organization_common.py +12 -0
- workos/types/passwordless/__init__.py +2 -0
- workos/types/passwordless/passwordless_session.py +12 -0
- workos/types/passwordless/passwordless_session_type.py +3 -0
- workos/types/pipes/__init__.py +6 -0
- workos/types/pipes/pipes.py +34 -0
- workos/types/portal/__init__.py +2 -0
- workos/types/portal/portal_link.py +7 -0
- workos/types/portal/portal_link_intent.py +11 -0
- workos/types/portal/portal_link_intent_options.py +9 -0
- workos/types/roles/__init__.py +0 -0
- workos/types/roles/role.py +27 -0
- workos/types/sso/__init__.py +4 -0
- workos/types/sso/connection.py +70 -0
- workos/types/sso/connection_domain.py +8 -0
- workos/types/sso/profile.py +35 -0
- workos/types/sso/sso_provider_type.py +10 -0
- workos/types/user_management/__init__.py +12 -0
- workos/types/user_management/authenticate_with_common.py +66 -0
- workos/types/user_management/authentication_response.py +53 -0
- workos/types/user_management/email_verification.py +18 -0
- workos/types/user_management/impersonator.py +8 -0
- workos/types/user_management/invitation.py +26 -0
- workos/types/user_management/list_filters.py +29 -0
- workos/types/user_management/magic_auth.py +18 -0
- workos/types/user_management/oauth_tokens.py +21 -0
- workos/types/user_management/organization_membership.py +25 -0
- workos/types/user_management/password_hash_type.py +4 -0
- workos/types/user_management/password_reset.py +18 -0
- workos/types/user_management/screen_hint.py +3 -0
- workos/types/user_management/session.py +79 -0
- workos/types/user_management/user.py +22 -0
- workos/types/user_management/user_management_provider_type.py +11 -0
- workos/types/vault/__init__.py +2 -0
- workos/types/vault/key.py +25 -0
- workos/types/vault/object.py +38 -0
- workos/types/webhooks/__init__.py +0 -0
- workos/types/webhooks/webhook.py +330 -0
- workos/types/webhooks/webhook_model.py +14 -0
- workos/types/webhooks/webhook_payload.py +4 -0
- workos/types/widgets/__init__.py +2 -0
- workos/types/widgets/widget_scope.py +4 -0
- workos/types/widgets/widget_token_response.py +7 -0
- workos/types/workos_model.py +26 -0
- workos/typing/__init__.py +1 -0
- workos/typing/literals.py +32 -0
- workos/typing/sync_or_async.py +5 -0
- workos/typing/untyped_literal.py +37 -0
- workos/typing/webhooks.py +18 -0
- workos/user_management.py +2400 -0
- workos/utils/_base_http_client.py +252 -0
- workos/utils/crypto_provider.py +39 -0
- workos/utils/http_client.py +214 -0
- workos/utils/pagination_order.py +4 -0
- workos/utils/request_helper.py +27 -0
- workos/vault.py +544 -0
- workos/webhooks.py +96 -39
- workos/widgets.py +55 -0
- {workos-1.5.1.dist-info → workos-5.38.0.dist-info}/LICENSE +1 -1
- workos-5.38.0.dist-info/METADATA +107 -0
- workos-5.38.0.dist-info/RECORD +141 -0
- {workos-1.5.1.dist-info → workos-5.38.0.dist-info}/WHEEL +1 -1
- workos/audit_trail.py +0 -172
- workos/resources/base.py +0 -36
- workos/resources/event.py +0 -42
- workos/resources/event_action.py +0 -11
- workos/resources/sso.py +0 -53
- workos/utils/connection_types.py +0 -17
- workos/utils/request.py +0 -95
- workos/utils/validation.py +0 -45
- workos-1.5.1.dist-info/METADATA +0 -77
- workos-1.5.1.dist-info/RECORD +0 -25
- /workos/{resources/__init__.py → py.typed} +0 -0
- {workos-1.5.1.dist-info → workos-5.38.0.dist-info}/top_level.txt +0 -0
workos/audit_trail.py
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import workos
|
|
2
|
-
from workos.exceptions import ConfigurationException
|
|
3
|
-
from workos.resources.event import WorkOSEvent
|
|
4
|
-
from workos.utils.request import RequestHelper, REQUEST_METHOD_GET, REQUEST_METHOD_POST
|
|
5
|
-
from workos.utils.validation import AUDIT_TRAIL_MODULE, validate_settings
|
|
6
|
-
|
|
7
|
-
EVENTS_PATH = "events"
|
|
8
|
-
METADATA_LIMIT = 50
|
|
9
|
-
DEFAULT_EVENT_LIMIT = 10
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class AuditTrail(object):
|
|
13
|
-
"""Offers methods through the WorkOS Audit Trail service."""
|
|
14
|
-
|
|
15
|
-
@validate_settings(AUDIT_TRAIL_MODULE)
|
|
16
|
-
def __init__(self):
|
|
17
|
-
pass
|
|
18
|
-
|
|
19
|
-
@property
|
|
20
|
-
def request_helper(self):
|
|
21
|
-
if not getattr(self, "_request_helper", None):
|
|
22
|
-
self._request_helper = RequestHelper()
|
|
23
|
-
return self._request_helper
|
|
24
|
-
|
|
25
|
-
def create_event(self, event, idempotency_key=None):
|
|
26
|
-
"""Create an Audit Trail event.
|
|
27
|
-
|
|
28
|
-
Args:
|
|
29
|
-
event (dict) - An event object
|
|
30
|
-
event[action] (str) - Specific activity performed by the actor.
|
|
31
|
-
event[action_type] (str) - Corresponding CRUD category of the
|
|
32
|
-
event. Can be one of C, R, U, or D.
|
|
33
|
-
event[actor_name] (str) - Display name of the entity performing the action
|
|
34
|
-
event[actor_id] (str) - Unique identifier of the entity performing the action
|
|
35
|
-
event[group] (str) - A single organization containing related .
|
|
36
|
-
members. This will normally be the customer of a vendor's application
|
|
37
|
-
event[location] (str) - Identifier for where the event
|
|
38
|
-
originated. This will be an IP address (IPv4 or IPv6),
|
|
39
|
-
hostname, or device ID.
|
|
40
|
-
event[occurred_at] (str) - ISO-8601 datetime at which the event
|
|
41
|
-
happened, with millisecond precision.
|
|
42
|
-
event[metadata] (str) - Arbitrary key-value data containing
|
|
43
|
-
information associated with the event. Note: There is a limit of 50
|
|
44
|
-
keys. Key names can be up to 40 characters long, and values can be up
|
|
45
|
-
to 500 characters long.
|
|
46
|
-
event[target_id] (str) - Unique identifier of the object or
|
|
47
|
-
resource being acted upon.
|
|
48
|
-
event[target_name] (str) - Display name of the object or
|
|
49
|
-
resource that is being acted upon.
|
|
50
|
-
idempotency_key (str) - An idempotency key
|
|
51
|
-
|
|
52
|
-
Returns:
|
|
53
|
-
boolean: Returns True
|
|
54
|
-
"""
|
|
55
|
-
if len(event.get("metadata", {})) > METADATA_LIMIT:
|
|
56
|
-
raise ValueError(
|
|
57
|
-
"Number of metadata keys exceeds {}.".format(METADATA_LIMIT)
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
headers = {
|
|
61
|
-
"idempotency-key": idempotency_key,
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
response = self.request_helper.request(
|
|
65
|
-
EVENTS_PATH,
|
|
66
|
-
method=REQUEST_METHOD_POST,
|
|
67
|
-
params=event,
|
|
68
|
-
headers=headers,
|
|
69
|
-
token=workos.api_key,
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
return response["success"]
|
|
73
|
-
|
|
74
|
-
def get_events(
|
|
75
|
-
self,
|
|
76
|
-
before=None,
|
|
77
|
-
after=None,
|
|
78
|
-
limit=DEFAULT_EVENT_LIMIT,
|
|
79
|
-
group=None,
|
|
80
|
-
action=None,
|
|
81
|
-
action_type=None,
|
|
82
|
-
actor_name=None,
|
|
83
|
-
actor_id=None,
|
|
84
|
-
target_name=None,
|
|
85
|
-
target_id=None,
|
|
86
|
-
occurred_at=None,
|
|
87
|
-
occurred_at_gt=None,
|
|
88
|
-
occurred_at_gte=None,
|
|
89
|
-
occurred_at_lt=None,
|
|
90
|
-
occurred_at_lte=None,
|
|
91
|
-
search=None,
|
|
92
|
-
):
|
|
93
|
-
"""Filter for Audit Trail Events.
|
|
94
|
-
|
|
95
|
-
Kwargs:
|
|
96
|
-
before (str) - Event ID to look before
|
|
97
|
-
after (str) - Event ID to look after
|
|
98
|
-
limit (int) - Number of Events to return
|
|
99
|
-
group (str|list) - Group or groups to filter for
|
|
100
|
-
action (str|list) - Action or actions to filter for
|
|
101
|
-
action_type (str|list) - Action type or types to filter for
|
|
102
|
-
actor_name (str|list) - Actor name or name to filter for
|
|
103
|
-
actor_id (str|list) - Actor ID or IDs to filter for
|
|
104
|
-
target_name (str|list) - Target name or names to filter for
|
|
105
|
-
target_id (str|list) - Target ID or IDs to filter for
|
|
106
|
-
occurred_at (str) - ISO-8601 datetime of when an event occurred
|
|
107
|
-
occurred_at_gt (str) - ISO-8601 datetime of when an event occurred after
|
|
108
|
-
occurred_at_gte (str) - ISO-8601 datetime of when an event occurred at or after
|
|
109
|
-
occurred_at_lt (str) - ISO-8601 datetime of when an event occurred before
|
|
110
|
-
occurred_at_lte (str) - ISO-8601 datetime of when an event occured at or before
|
|
111
|
-
search (str) - Keyword search
|
|
112
|
-
|
|
113
|
-
Returns:
|
|
114
|
-
tuple
|
|
115
|
-
list - List of WorkOSEvent objects
|
|
116
|
-
string - Event ID to use as before cursor
|
|
117
|
-
string - Event ID to use as after cursor
|
|
118
|
-
"""
|
|
119
|
-
params = {
|
|
120
|
-
"before": before,
|
|
121
|
-
"after": after,
|
|
122
|
-
"limit": limit,
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if group is not None:
|
|
126
|
-
params["group[]"] = group
|
|
127
|
-
|
|
128
|
-
if action is not None:
|
|
129
|
-
params["action[]"] = action
|
|
130
|
-
|
|
131
|
-
if action_type is not None:
|
|
132
|
-
params["action_type[]"] = action_type
|
|
133
|
-
|
|
134
|
-
if actor_name is not None:
|
|
135
|
-
params["actor_name[]"] = actor_name
|
|
136
|
-
|
|
137
|
-
if actor_id is not None:
|
|
138
|
-
params["actor_id[]"] = actor_id
|
|
139
|
-
|
|
140
|
-
if target_name is not None:
|
|
141
|
-
params["target_name[]"] = target_name
|
|
142
|
-
|
|
143
|
-
if target_id is not None:
|
|
144
|
-
params["target_id[]"] = target_id
|
|
145
|
-
|
|
146
|
-
if occurred_at is not None:
|
|
147
|
-
params["occurred_at"] = occurred_at
|
|
148
|
-
else:
|
|
149
|
-
if occurred_at_gte is not None:
|
|
150
|
-
params["occurred_at_gte"] = occurred_at_gte
|
|
151
|
-
elif occurred_at_gt is not None:
|
|
152
|
-
params["occurred_at_gt"] = occurred_at_gt
|
|
153
|
-
|
|
154
|
-
if occurred_at_lte is not None:
|
|
155
|
-
params["occurred_at_lte"] = occurred_at_lte
|
|
156
|
-
elif occurred_at_lt is not None:
|
|
157
|
-
params["occurred_at_lt"] = occurred_at_lt
|
|
158
|
-
|
|
159
|
-
if search is not None:
|
|
160
|
-
params["search"] = search
|
|
161
|
-
|
|
162
|
-
response = self.request_helper.request(
|
|
163
|
-
EVENTS_PATH, method=REQUEST_METHOD_GET, params=params, token=workos.api_key,
|
|
164
|
-
)
|
|
165
|
-
|
|
166
|
-
events = [
|
|
167
|
-
WorkOSEvent.construct_from_response(data) for data in response["data"]
|
|
168
|
-
]
|
|
169
|
-
before = response["listMetadata"]["before"]
|
|
170
|
-
after = response["listMetadata"]["after"]
|
|
171
|
-
|
|
172
|
-
return (events, before, after)
|
workos/resources/base.py
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
class WorkOSBaseResource(object):
|
|
2
|
-
"""Representation of a WorkOS Resource as returned through the API.
|
|
3
|
-
|
|
4
|
-
Attributes:
|
|
5
|
-
OBJECT_FIELDS (list): List of fields a Resource is comprised of.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
OBJECT_FIELDS = []
|
|
9
|
-
|
|
10
|
-
@classmethod
|
|
11
|
-
def construct_from_response(cls, response):
|
|
12
|
-
"""Returns an instance of WorkOSBaseResource.
|
|
13
|
-
|
|
14
|
-
Args:
|
|
15
|
-
response (dict): Resource data from a WorkOS API response
|
|
16
|
-
|
|
17
|
-
Returns:
|
|
18
|
-
WorkOSBaseResource: Instance of a WorkOSBaseResource with OBJECT_FIELDS fields set
|
|
19
|
-
"""
|
|
20
|
-
obj = cls()
|
|
21
|
-
for field in cls.OBJECT_FIELDS:
|
|
22
|
-
setattr(obj, field, response[field])
|
|
23
|
-
|
|
24
|
-
return obj
|
|
25
|
-
|
|
26
|
-
def to_dict(self):
|
|
27
|
-
"""Returns a dict representation of the WorkOSBaseResource.
|
|
28
|
-
|
|
29
|
-
Returns:
|
|
30
|
-
dict: A dict representation of the WorkOSBaseResource
|
|
31
|
-
"""
|
|
32
|
-
obj_dict = {}
|
|
33
|
-
for field in self.OBJECT_FIELDS:
|
|
34
|
-
obj_dict[field] = getattr(self, field, None)
|
|
35
|
-
|
|
36
|
-
return obj_dict
|
workos/resources/event.py
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
from workos.resources.base import WorkOSBaseResource
|
|
2
|
-
from workos.resources.event_action import WorkOSEventAction
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class WorkOSEvent(WorkOSBaseResource):
|
|
6
|
-
"""Representation of an Event as returned by WorkOS through the Audit Trail feature.
|
|
7
|
-
|
|
8
|
-
Attributes:
|
|
9
|
-
OBJECT_FIELDS (list): List of fields a WorkOSEvent is comprised of.
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
OBJECT_FIELDS = [
|
|
13
|
-
"id",
|
|
14
|
-
"group",
|
|
15
|
-
"location",
|
|
16
|
-
"latitude",
|
|
17
|
-
"longitude",
|
|
18
|
-
"type",
|
|
19
|
-
"actor_name",
|
|
20
|
-
"actor_id",
|
|
21
|
-
"target_name",
|
|
22
|
-
"target_id",
|
|
23
|
-
"metadata",
|
|
24
|
-
"occurred_at",
|
|
25
|
-
]
|
|
26
|
-
|
|
27
|
-
@classmethod
|
|
28
|
-
def construct_from_response(cls, response):
|
|
29
|
-
event = super(WorkOSEvent, cls).construct_from_response(response)
|
|
30
|
-
|
|
31
|
-
event_action = WorkOSEventAction.construct_from_response(response["action"])
|
|
32
|
-
event.action = event_action
|
|
33
|
-
|
|
34
|
-
return event
|
|
35
|
-
|
|
36
|
-
def to_dict(self):
|
|
37
|
-
event_dict = super(WorkOSEvent, self).to_dict()
|
|
38
|
-
|
|
39
|
-
event_action_dict = self.action.to_dict()
|
|
40
|
-
event_dict["action"] = event_action_dict
|
|
41
|
-
|
|
42
|
-
return event_dict
|
workos/resources/event_action.py
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
from workos.resources.base import WorkOSBaseResource
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class WorkOSEventAction(WorkOSBaseResource):
|
|
5
|
-
"""Representation of an Event Action as returned by WorkOS through the Audit Trail feature.
|
|
6
|
-
|
|
7
|
-
Attributes:
|
|
8
|
-
OBJECT_FIELDS (list): List of fields a WorkOSEventAction is comprised of.
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
OBJECT_FIELDS = ["id", "name", "environment_id"]
|
workos/resources/sso.py
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
from workos.resources.base import WorkOSBaseResource
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class WorkOSProfile(WorkOSBaseResource):
|
|
5
|
-
"""Representation of a User Profile as returned by WorkOS through the SSO feature.
|
|
6
|
-
|
|
7
|
-
Attributes:
|
|
8
|
-
OBJECT_FIELDS (list): List of fields a WorkOSProfile is comprised of.
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
OBJECT_FIELDS = [
|
|
12
|
-
"id",
|
|
13
|
-
"email",
|
|
14
|
-
"first_name",
|
|
15
|
-
"last_name",
|
|
16
|
-
"organization_id",
|
|
17
|
-
"connection_id",
|
|
18
|
-
"connection_type",
|
|
19
|
-
"idp_id",
|
|
20
|
-
"raw_attributes",
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class WorkOSProfileAndToken(WorkOSBaseResource):
|
|
25
|
-
"""Representation of a User Profile and Access Token as returned by WorkOS through the SSO feature.
|
|
26
|
-
|
|
27
|
-
Attributes:
|
|
28
|
-
OBJECT_FIELDS (list): List of fields a WorkOSProfileAndToken is comprised of.
|
|
29
|
-
"""
|
|
30
|
-
|
|
31
|
-
OBJECT_FIELDS = [
|
|
32
|
-
"access_token",
|
|
33
|
-
]
|
|
34
|
-
|
|
35
|
-
@classmethod
|
|
36
|
-
def construct_from_response(cls, response):
|
|
37
|
-
profile_and_token = super(WorkOSProfileAndToken, cls).construct_from_response(
|
|
38
|
-
response
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
profile_and_token.profile = WorkOSProfile.construct_from_response(
|
|
42
|
-
response["profile"]
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
return profile_and_token
|
|
46
|
-
|
|
47
|
-
def to_dict(self):
|
|
48
|
-
profile_and_token_dict = super(WorkOSProfileAndToken, self).to_dict()
|
|
49
|
-
|
|
50
|
-
profile_dict = self.profile.to_dict()
|
|
51
|
-
profile_and_token_dict["profile"] = profile_dict
|
|
52
|
-
|
|
53
|
-
return profile_and_token_dict
|
workos/utils/connection_types.py
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
from enum import Enum
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class ConnectionType(Enum):
|
|
5
|
-
ADFSSAML = "ADFSSAML"
|
|
6
|
-
AzureSAML = "AzureSAML"
|
|
7
|
-
GenericOIDC = "GenericOIDC"
|
|
8
|
-
GenericSAML = "GenericSAML"
|
|
9
|
-
GoogleOAuth = "GoogleOAuth"
|
|
10
|
-
GoogleSAML = "GoogleSAML"
|
|
11
|
-
MagicLink = "MagicLink"
|
|
12
|
-
MicrosoftOAuth = "MicrosoftOAuth"
|
|
13
|
-
OktaSAML = "OktaSAML"
|
|
14
|
-
OneLoginSAML = "OneLoginSAML"
|
|
15
|
-
PingFederateSAML = "PingFederateSAML"
|
|
16
|
-
PingOneSAML = "PingOneSAML"
|
|
17
|
-
VMwareSAML = "VMwareSAML"
|
workos/utils/request.py
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
|
|
3
|
-
import workos
|
|
4
|
-
from workos.exceptions import (
|
|
5
|
-
AuthorizationException,
|
|
6
|
-
AuthenticationException,
|
|
7
|
-
BadRequestException,
|
|
8
|
-
ServerException,
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
BASE_HEADERS = {
|
|
12
|
-
"User-Agent": "WorkOS Python/{}".format(workos.__version__),
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
RESPONSE_TYPE_CODE = "code"
|
|
16
|
-
|
|
17
|
-
REQUEST_METHOD_DELETE = "delete"
|
|
18
|
-
REQUEST_METHOD_GET = "get"
|
|
19
|
-
REQUEST_METHOD_POST = "post"
|
|
20
|
-
REQUEST_METHOD_PUT = "put"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class RequestHelper(object):
|
|
24
|
-
def __init__(self):
|
|
25
|
-
self.set_base_api_url(workos.base_api_url)
|
|
26
|
-
|
|
27
|
-
def set_base_api_url(self, base_api_url):
|
|
28
|
-
"""Creates an accessible template for constructing the URL for an API request.
|
|
29
|
-
|
|
30
|
-
Args:
|
|
31
|
-
base_api_url (str): Base URL for api requests (Should end with a /)
|
|
32
|
-
"""
|
|
33
|
-
self.base_api_url = "{}{{}}".format(base_api_url)
|
|
34
|
-
|
|
35
|
-
def generate_api_url(self, path):
|
|
36
|
-
return self.base_api_url.format(path)
|
|
37
|
-
|
|
38
|
-
def request(
|
|
39
|
-
self, path, method=REQUEST_METHOD_GET, params=None, headers=None, token=None,
|
|
40
|
-
):
|
|
41
|
-
"""Executes a request against the WorkOS API.
|
|
42
|
-
|
|
43
|
-
Args:
|
|
44
|
-
path (str): Path for the api request that'd be appended to the base API URL
|
|
45
|
-
|
|
46
|
-
Kwargs:
|
|
47
|
-
method (str): One of the supported methods as defined by the REQUEST_METHOD_X constants
|
|
48
|
-
params (dict): Query params to be added to the request
|
|
49
|
-
token (str): Bearer token
|
|
50
|
-
|
|
51
|
-
Returns:
|
|
52
|
-
dict: Response from WorkOS
|
|
53
|
-
"""
|
|
54
|
-
if headers is None:
|
|
55
|
-
headers = {}
|
|
56
|
-
|
|
57
|
-
if token:
|
|
58
|
-
headers["Authorization"] = "Bearer {}".format(token)
|
|
59
|
-
|
|
60
|
-
headers.update(BASE_HEADERS)
|
|
61
|
-
url = self.generate_api_url(path)
|
|
62
|
-
|
|
63
|
-
request_fn = getattr(requests, method)
|
|
64
|
-
if method == REQUEST_METHOD_GET:
|
|
65
|
-
response = request_fn(url, headers=headers, params=params)
|
|
66
|
-
else:
|
|
67
|
-
response = request_fn(url, headers=headers, json=params)
|
|
68
|
-
|
|
69
|
-
response_json = None
|
|
70
|
-
content_type = (
|
|
71
|
-
response.headers.get("content-type")
|
|
72
|
-
if response.headers is not None
|
|
73
|
-
else None
|
|
74
|
-
)
|
|
75
|
-
if content_type is not None and "application/json" in content_type:
|
|
76
|
-
try:
|
|
77
|
-
response_json = response.json()
|
|
78
|
-
except ValueError:
|
|
79
|
-
raise ServerException(response)
|
|
80
|
-
|
|
81
|
-
status_code = response.status_code
|
|
82
|
-
if status_code >= 400 and status_code < 500:
|
|
83
|
-
if status_code == 401:
|
|
84
|
-
raise AuthenticationException(response)
|
|
85
|
-
elif status_code == 403:
|
|
86
|
-
raise AuthorizationException(response)
|
|
87
|
-
error = response_json.get("error")
|
|
88
|
-
error_description = response_json.get("error_description")
|
|
89
|
-
raise BadRequestException(
|
|
90
|
-
response, error=error, error_description=error_description
|
|
91
|
-
)
|
|
92
|
-
elif status_code >= 500 and status_code < 600:
|
|
93
|
-
raise ServerException(response)
|
|
94
|
-
|
|
95
|
-
return response_json
|
workos/utils/validation.py
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
from functools import wraps
|
|
2
|
-
|
|
3
|
-
import workos
|
|
4
|
-
from workos.exceptions import ConfigurationException
|
|
5
|
-
|
|
6
|
-
AUDIT_TRAIL_MODULE = "AuditTrail"
|
|
7
|
-
DIRECTORY_SYNC_MODULE = "DirectorySync"
|
|
8
|
-
ORGANIZATIONS_MODULE = "Organizations"
|
|
9
|
-
PASSWORDLESS_MODULE = "Passwordless"
|
|
10
|
-
PORTAL_MODULE = "Portal"
|
|
11
|
-
SSO_MODULE = "SSO"
|
|
12
|
-
WEBHOOKS_MODULE = "Webhooks"
|
|
13
|
-
|
|
14
|
-
REQUIRED_SETTINGS_FOR_MODULE = {
|
|
15
|
-
AUDIT_TRAIL_MODULE: ["api_key",],
|
|
16
|
-
DIRECTORY_SYNC_MODULE: ["api_key",],
|
|
17
|
-
ORGANIZATIONS_MODULE: ["api_key",],
|
|
18
|
-
PASSWORDLESS_MODULE: ["api_key",],
|
|
19
|
-
PORTAL_MODULE: ["api_key",],
|
|
20
|
-
SSO_MODULE: ["api_key", "client_id",],
|
|
21
|
-
WEBHOOKS_MODULE: ["api_key"],
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def validate_settings(module_name):
|
|
26
|
-
def decorator(fn):
|
|
27
|
-
@wraps(fn)
|
|
28
|
-
def wrapper(*args, **kwargs):
|
|
29
|
-
missing_settings = []
|
|
30
|
-
|
|
31
|
-
for setting in REQUIRED_SETTINGS_FOR_MODULE[module_name]:
|
|
32
|
-
if not getattr(workos, setting, None):
|
|
33
|
-
missing_settings.append(setting)
|
|
34
|
-
|
|
35
|
-
if missing_settings:
|
|
36
|
-
raise ConfigurationException(
|
|
37
|
-
"The following settings are missing for {}: {}".format(
|
|
38
|
-
module_name, ", ".join(missing_settings)
|
|
39
|
-
)
|
|
40
|
-
)
|
|
41
|
-
return fn(*args, **kwargs)
|
|
42
|
-
|
|
43
|
-
return wrapper
|
|
44
|
-
|
|
45
|
-
return decorator
|
workos-1.5.1.dist-info/METADATA
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: workos
|
|
3
|
-
Version: 1.5.1
|
|
4
|
-
Summary: WorkOS Python Client
|
|
5
|
-
Home-page: https://github.com/workos-inc/workos-python
|
|
6
|
-
Author: WorkOS
|
|
7
|
-
Author-email: team@workos.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Platform: UNKNOWN
|
|
10
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
-
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
14
|
-
Classifier: Programming Language :: Python
|
|
15
|
-
Classifier: Programming Language :: Python :: 2
|
|
16
|
-
Classifier: Programming Language :: Python :: 2.7
|
|
17
|
-
Classifier: Programming Language :: Python :: 3
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.4
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.5
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
23
|
-
Description-Content-Type: text/markdown
|
|
24
|
-
Requires-Dist: requests (>=2.22.0)
|
|
25
|
-
Requires-Dist: enum34 ; python_version<'3.4'
|
|
26
|
-
Provides-Extra: dev
|
|
27
|
-
Requires-Dist: flake8 ; extra == 'dev'
|
|
28
|
-
Requires-Dist: pytest (==4.6.9) ; extra == 'dev'
|
|
29
|
-
Requires-Dist: pytest-cov (==2.8.1) ; extra == 'dev'
|
|
30
|
-
Requires-Dist: six (==1.13.0) ; extra == 'dev'
|
|
31
|
-
Requires-Dist: black (==19.10b0) ; extra == 'dev'
|
|
32
|
-
Requires-Dist: twine (==3.1.1) ; extra == 'dev'
|
|
33
|
-
|
|
34
|
-
# WorkOS Python Library
|
|
35
|
-
|
|
36
|
-

|
|
37
|
-
[](https://workos.semaphoreci.com/projects/workos-python)
|
|
38
|
-
|
|
39
|
-
The WorkOS library for Python provides convenient access to the WorkOS API from applications written in Python, [hosted on PyPi](https://pypi.org/project/workos/)
|
|
40
|
-
|
|
41
|
-
## Documentation
|
|
42
|
-
|
|
43
|
-
See the [API Reference](https://workos.com/docs/reference/client-libraries) for Python usage examples.
|
|
44
|
-
|
|
45
|
-
## Installation
|
|
46
|
-
|
|
47
|
-
To install from PyPi, run the following:
|
|
48
|
-
|
|
49
|
-
```
|
|
50
|
-
pip install workos
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
To install from source, clone the repo and run the following:
|
|
54
|
-
|
|
55
|
-
```
|
|
56
|
-
python setup.py install
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Configuration
|
|
60
|
-
|
|
61
|
-
The package will need to be configured with your [api key](https://dashboard.workos.com/api-keys) at a minimum and [client id](https://dashboard.workos.com/sso/configuration) if you plan on using SSO:
|
|
62
|
-
|
|
63
|
-
```python
|
|
64
|
-
import workos
|
|
65
|
-
|
|
66
|
-
workos.api_key = "sk_1234"
|
|
67
|
-
workos.client_id = "client_1234"
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## More Information
|
|
71
|
-
|
|
72
|
-
- [Single Sign-On Guide](https://workos.com/docs/sso/guide)
|
|
73
|
-
- [Directory Sync Guide](https://workos.com/docs/directory-sync/guide)
|
|
74
|
-
- [Admin Portal Guide](https://workos.com/docs/admin-portal/guide)
|
|
75
|
-
- [Magic Link Guide](https://workos.com/docs/magic-link/guide)
|
|
76
|
-
|
|
77
|
-
|
workos-1.5.1.dist-info/RECORD
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
workos/__about__.py,sha256=kdj91jXlr4DPgTmhpcYtVjlx7BD3dLNZl0ORatUKuJk,405
|
|
2
|
-
workos/__init__.py,sha256=EBYXvVZCRbkoUs8IMgjd5mwWIiVsrglUWueOYxd9IZY,207
|
|
3
|
-
workos/audit_trail.py,sha256=rSVweO8PCLN4npLekBPgDYy55uiUKZ_Llz6935-Ootc,6411
|
|
4
|
-
workos/client.py,sha256=FrOPeSvtM_gszanBD336i6QDRIqBidM3H3mEzvIkwFk,1554
|
|
5
|
-
workos/directory_sync.py,sha256=FFwSQsw5lOv9Fbqnx5zryFN7lOr8a1ROGah8Il-GZy4,5178
|
|
6
|
-
workos/exceptions.py,sha256=iSLDPtUat7xsaKmkGxlwB4W0SFEZZ_Yl-1JxmYDtTPY,1497
|
|
7
|
-
workos/organizations.py,sha256=H7E-R3OFw8r9GRjsJUQpPanN7DKohxXGlRVUVg2FU2o,4419
|
|
8
|
-
workos/passwordless.py,sha256=bRGZ0OJA3gv9Gge7Nas19jtoUYU92sopzUOFguOs230,2620
|
|
9
|
-
workos/portal.py,sha256=iy1LsD9dHUEAv7pQ1XnWTnAfiymWN1T1Z1lTh_WiSks,1540
|
|
10
|
-
workos/sso.py,sha256=z-xrKzp5saNaDmxwCpK0pcO57BTFJSUPO1DtKBQiYpE,6313
|
|
11
|
-
workos/webhooks.py,sha256=eqzDwHw4tQF7pcb_8Po4VlmxENzviFRcL8tuS8uKhOM,3093
|
|
12
|
-
workos/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
workos/resources/base.py,sha256=V5jaKeAKtjgyVLDJcd9XIs5mj4R06dcYIxbtx2xVGVw,1020
|
|
14
|
-
workos/resources/event.py,sha256=8K-vJdSAt92r7hetmzwJtBVggnUaoiJO_d7pMPGpyJ8,1101
|
|
15
|
-
workos/resources/event_action.py,sha256=oBALu0VjWISfxq6LlVVd8NGXE_lGrXAvxm5piqPwM-4,357
|
|
16
|
-
workos/resources/sso.py,sha256=PQxsO8GoPxjfHRsT7w_naUnfaA0xFOj28WJ7A2IKWm8,1412
|
|
17
|
-
workos/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
-
workos/utils/connection_types.py,sha256=gCCSunkI-g6zPw1k8miPAyiST8SmZXCIfmdd38NExXA,462
|
|
19
|
-
workos/utils/request.py,sha256=i6m5-hYrjYeVHg5WcrYz0QJRXqEgTdKvSZTQWOWxDNw,2963
|
|
20
|
-
workos/utils/validation.py,sha256=mN_qA7FmRJloiGuRRuz4h3JoeBoeLAkszZo2FDxA43c,1301
|
|
21
|
-
workos-1.5.1.dist-info/LICENSE,sha256=RAEmkw4BYTzgAxZbzzw_DDUlpPgg02u-_9qtEfcAOOw,1063
|
|
22
|
-
workos-1.5.1.dist-info/METADATA,sha256=fD669IKXn5NTE--OKsfi-ZhRw2KerJ4kbAV0OQ56_Ns,2611
|
|
23
|
-
workos-1.5.1.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
|
|
24
|
-
workos-1.5.1.dist-info/top_level.txt,sha256=ZFskIfue1Tw-JwjyIXRvdsAl9i0DX9VbqmgICXV84Sk,7
|
|
25
|
-
workos-1.5.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|