-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
from typing import List, Literal, NamedTuple | ||
from enum import Enum | ||
from workos.utils.types import JsonDict | ||
|
||
|
||
class AuthenticationType(Enum): | ||
EMAIL_VERIFICATION = "email_verification" | ||
MAGIC_AUTH = "magic_auth" | ||
MFA = "mfa" | ||
OAUTH = "oauth" | ||
PASSWORD = "password" | ||
SSO = "sso" | ||
|
||
|
||
class Error(NamedTuple): | ||
code: str | ||
message: str | ||
|
||
|
||
class AuthenticationFailedFields: | ||
def __init__(self, attributes: JsonDict) -> None: | ||
self.type: AuthenticationType = AuthenticationType(attributes["type"]) | ||
self.status: str = attributes["status"] | ||
self.user_id: str = attributes["user_id"] | ||
self.email: str = attributes["email"] | ||
self.ip_address: str = attributes["ip_address"] | ||
self.user_agent: str = attributes["user_agent"] | ||
self.error: Error = Error(code=attributes["error"]["code"], message=attributes["error"]["message"]) | ||
|
||
class AuthenticationSucceededFields: | ||
def __init__(self, attributes: JsonDict) -> None: | ||
self.type: AuthenticationType = AuthenticationType(attributes["type"]) | ||
self.status: str = attributes["status"] | ||
self.user_id: str = attributes["user_id"] | ||
self.email: str = attributes["email"] | ||
self.ip_address: str = attributes["ip_address"] | ||
self.user_agent: str = attributes["user_agent"] | ||
|
||
class AuthenticationEmailVerificationFailedEvent: | ||
event_name: str = "authentication.email_verification_failed" | ||
|
||
def __init__(self, attributes: JsonDict) -> None: | ||
self.event: Literal["authentication.email_verification_failed"] = attributes['event'] | ||
self.id: str = attributes["id"] | ||
self.created_at = attributes["created_at"] | ||
self.data: AuthenticationFailedFields = AuthenticationFailedFields( | ||
attributes["data"] | ||
) | ||
|
||
class AuthenticationEmailVerificationSucceededEvent: | ||
event_name: str = "authentication.email_verification_succeeded" | ||
|
||
def __init__(self, attributes: JsonDict) -> None: | ||
self.event: Literal["authentication.email_verification_succeeded"] = attributes['event'] | ||
self.id: str = attributes["id"] | ||
self.created_at = attributes["created_at"] | ||
self.data: AuthenticationSucceededFields = AuthenticationSucceededFields( | ||
attributes["data"] | ||
) | ||
|
||
class AuthenticationMagicAuthFailedEvent: | ||
event_name: str = "authentication.magic_auth_failed" | ||
|
||
def __init__(self, attributes: JsonDict) -> None: | ||
self.event: Literal["authentication.magic_auth_failed"] = attributes['event'] | ||
self.id: str = attributes["id"] | ||
self.created_at = attributes["created_at"] | ||
self.data: AuthenticationFailedFields = AuthenticationFailedFields( | ||
attributes["data"] | ||
) | ||
|
||
class AuthenticationMagicAuthSucceededEvent: | ||
event_name: str = "authentication.magic_auth_succeeded" | ||
|
||
def __init__(self, attributes: JsonDict) -> None: | ||
self.event: Literal["authentication.magic_auth_succeeded"] = attributes['event'] | ||
self.id: str = attributes["id"] | ||
self.created_at = attributes["created_at"] | ||
self.data: AuthenticationSucceededFields = AuthenticationSucceededFields( | ||
attributes["data"] | ||
) | ||
|
||
class AuthenticationMFAFailedEvent: | ||
event_name: str = "authentication.mfa_failed" | ||
|
||
def __init__(self, attributes: JsonDict) -> None: | ||
self.event: Literal["authentication.mfa_failed"] = attributes['event'] | ||
self.id: str = attributes["id"] | ||
self.created_at = attributes["created_at"] | ||
self.data: AuthenticationFailedFields = AuthenticationFailedFields( | ||
attributes["data"] | ||
) | ||
|
||
class AuthenticationMFASucceededEvent: | ||
event_name: str = "authentication.mfa_succeeded" | ||
|
||
def __init__(self, attributes: JsonDict) -> None: | ||
self.event: Literal["authentication.mfa_succeeded"] = attributes['event'] | ||
self.id: str = attributes["id"] | ||
self.created_at = attributes["created_at"] | ||
self.data: AuthenticationSucceededFields = AuthenticationSucceededFields( | ||
attributes["data"] | ||
) | ||
|
||
class AuthenticationOAuthFailedEvent: | ||
event_name: str = "authentication.oauth_failed" | ||
|
||
def __init__(self, attributes: JsonDict) -> None: | ||
self.event: Literal["authentication.oauth_failed"] = attributes['event'] | ||
self.id: str = attributes["id"] | ||
self.created_at = attributes["created_at"] | ||
self.data: AuthenticationFailedFields = AuthenticationFailedFields( | ||
attributes["data"] | ||
) | ||
|
||
class AuthenticationOAuthSucceededEvent: | ||
event_name: str = "authentication.oauth_succeeded" | ||
|
||
def __init__(self, attributes: JsonDict) -> None: | ||
self.event: Literal["authentication.oauth_succeeded"] = attributes['event'] | ||
self.id: str = attributes["id"] | ||
self.created_at = attributes["created_at"] | ||
self.data: AuthenticationSucceededFields = AuthenticationSucceededFields( | ||
attributes["data"] | ||
) | ||
|
||
class AuthenticationPasswordFailedEvent: | ||
event_name: str = "authentication.password_failed" | ||
|
||
def __init__(self, attributes: JsonDict) -> None: | ||
self.event: Literal["authentication.password_failed"] = attributes['event'] | ||
self.id: str = attributes["id"] | ||
self.created_at = attributes["created_at"] | ||
self.data: AuthenticationFailedFields = AuthenticationFailedFields( | ||
attributes["data"] | ||
) | ||
|
||
class AuthenticationPasswordSucceededEvent: | ||
event_name: str = "authentication.password_succeeded" | ||
|
||
def __init__(self, attributes: JsonDict) -> None: | ||
self.event: Literal["authentication.password_succeeded"] = attributes['event'] | ||
self.id: str = attributes["id"] | ||
self.created_at = attributes["created_at"] | ||
self.data: AuthenticationSucceededFields = AuthenticationSucceededFields( | ||
attributes["data"] | ||
) | ||
|
||
|
||
class AuthenticationSSOFailedEvent: | ||
event_name: str = "authentication.sso_failed" | ||
|
||
def __init__(self, attributes: JsonDict) -> None: | ||
self.event: Literal["authentication.sso_failed"] = attributes['event'] | ||
self.id: str = attributes["id"] | ||
self.created_at = attributes["created_at"] | ||
self.data: AuthenticationFailedFields = AuthenticationFailedFields( | ||
attributes["data"] | ||
) | ||
|
||
class AuthenticationSSOSucceededEvent: | ||
event_name: str = "authentication.sso_succeeded" | ||
|
||
def __init__(self, attributes: JsonDict) -> None: | ||
self.event: Literal["authentication.sso_succeeded"] = attributes['event'] | ||
self.id: str = attributes["id"] | ||
self.created_at = attributes["created_at"] | ||
self.data: AuthenticationSucceededFields = AuthenticationSucceededFields( | ||
attributes["data"] | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
from typing import List, Literal, NamedTuple | ||
from enum import Enum | ||
from workos.utils.types import JsonDict | ||
|
||
class ConnectionState(Enum): | ||
INACTIVE = "inactive" | ||
ACTIVE = "active" | ||
|
||
class ConnectionType(Enum): | ||
ADFS_SAML = 'ADFSSAML' | ||
ADP_OIDC = 'AdpOidc' | ||
AUTH0_SAML = 'Auth0SAML' | ||
AZURE_SAML = 'AzureSAML' | ||
CAS_SAML = 'CasSAML' | ||
CLASS_LINK_SAML = 'ClassLinkSAML' | ||
CLOUDFLARE_SAML = 'CloudflareSAML' | ||
CYBER_ARK_SAML = 'CyberArkSAML' | ||
DUO_SAML = 'DuoSAML' | ||
GENERIC_OIDC = 'GenericOIDC' | ||
GENERIC_SAML = 'GenericSAML' | ||
GOOGLE_OAUTH = 'GoogleOAuth' | ||
GOOGLE_SAML = 'GoogleSAML' | ||
JUMP_CLOUD_SAML = 'JumpCloudSAML' | ||
KEYCLOAK_SAML = 'KeycloakSAML' | ||
LAST_PASS_SAML = 'LastPassSAML' | ||
LOGIN_GOV_OIDC = 'LoginGovOidc' | ||
MAGIC_LINK = 'MagicLink' | ||
MICROSOFT_OAUTH = 'MicrosoftOAuth' | ||
MINI_ORANGE_SAML = 'MiniOrangeSAML' | ||
NET_IQ_SAML = 'NetIqSAML' | ||
OKTA_SAML = 'OktaSAML' | ||
ONE_LOGIN_SAML ='OneLoginSAML' | ||
ORACLE_SAML = 'OracleSAML' | ||
PING_FEDERATE_SAML = 'PingFederateSAML' | ||
PING_ONE_SAML = 'PingOneSAML' | ||
RIPPLING_SAML = 'RipplingSAML' | ||
SALESFORCE_SAML = 'SalesforceSAML' | ||
SHIBBOLETH_GENERIC_SAML = 'ShibbolethGenericSAML' | ||
SHIBBOLETH_SAML = 'ShibbolethSAML' | ||
SIMPLE_SAML_PHP_SAML = 'SimpleSamlPhpSAML' | ||
VM_WARE_SAML = 'VMwareSAML' | ||
|
||
class Domain: | ||
def __init__(self, attributes: JsonDict) -> None: | ||
self.id: str = attributes["id"] | ||
self.object: Literal["connection_domain"] = attributes["object"] | ||
self.domain: str = attributes["domain"] | ||
|
||
|
||
class ConnectionEvent: | ||
def __init__(self, attributes: JsonDict) -> None: | ||
self.object: Literal["connection"] = attributes["object"] | ||
self.id: str = attributes["id"] | ||
self.organization_id: str = attributes["organization_id"] | ||
self.state: str = ConnectionState(attributes["state"]) | ||
self.connection_type: str = ConnectionType(attributes["connection_type"]) | ||
self.name: str = attributes["name"] | ||
self.created_at: str = attributes["created_at"] | ||
self.updated_at: str = attributes["updated_at"] | ||
self.domains = [] | ||
for domain in attributes["domains"]: | ||
self.domains.push(Domain(attributes=domain)) | ||
|
||
class ConnectionActivatedEvent: | ||
event_name = "connection.activated" | ||
|
||
def __init__(self, attributes: JsonDict) -> None: | ||
self.event: Literal['connection.activated'] = attributes["event"] | ||
self.id: str = attributes["id"] | ||
self.created_at = attributes["created_at"] | ||
self.data: ConnectionEvent = ConnectionEvent( | ||
attributes["data"] | ||
) | ||
|
||
class ConnectionDeactivatedEvent: | ||
event_name = "connection.deactivated" | ||
|
||
def __init__(self, attributes: JsonDict) -> None: | ||
self.event: Literal['connection.deactivated'] = attributes["event"] | ||
self.id: str = attributes["id"] | ||
self.created_at = attributes["created_at"] | ||
self.data: ConnectionEvent = ConnectionEvent( | ||
attributes["data"] | ||
) | ||
|
||
class ConnectionDeactivatedEvent: | ||
event_name = "connection.deleted" | ||
|
||
def __init__(self, attributes: JsonDict) -> None: | ||
self.event: Literal['connection.deleted'] = attributes["event"] | ||
self.id: str = attributes["id"] | ||
self.created_at = attributes["created_at"] | ||
self.data: ConnectionEvent = ConnectionEvent( | ||
attributes["data"] | ||
) |