tripaulx-sdk 0.1.0__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.
- tripaulx_sdk-0.1.0/.gitignore +20 -0
- tripaulx_sdk-0.1.0/LICENSE +21 -0
- tripaulx_sdk-0.1.0/PKG-INFO +80 -0
- tripaulx_sdk-0.1.0/README.md +35 -0
- tripaulx_sdk-0.1.0/pyproject.toml +70 -0
- tripaulx_sdk-0.1.0/src/tripaulx/__init__.py +3 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/admin/__init__.py +25 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/admin/security.py +92 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/admin/user.py +33 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/authentication.py +27 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/permissions.py +21 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/schema.py +22 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/serializers/__init__.py +55 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/serializers/auth.py +82 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/serializers/devices.py +64 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/serializers/user.py +63 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/serializers/workspace.py +58 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/urls.py +88 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/urls_public.py +17 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/urls_workspace.py +22 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/__init__.py +64 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/base.py +55 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/devices.py +42 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/email.py +44 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/invitations.py +83 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/login.py +74 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/members.py +48 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/mfa.py +120 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/passkeys.py +136 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/password.py +65 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/session.py +68 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/signup.py +62 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/apps.py +17 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/conf.py +41 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/locale/pt_BR/LC_MESSAGES/django.po +566 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/management/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/management/commands/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/management/commands/generate_recovery_codes.py +66 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/migrations/0001_initial.py +483 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/migrations/__init__.py +0 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/__init__.py +25 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/email_code.py +54 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/invitation.py +53 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/managers.py +44 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/passkey.py +39 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/recovery_code.py +44 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/roles.py +17 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/totp_device.py +50 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/trusted_device.py +53 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/user.py +55 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/__init__.py +4 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/email_codes.py +84 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/errors.py +79 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/invitations.py +103 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/login/__init__.py +26 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/login/flow.py +131 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/login/second_factor.py +66 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/login/tickets.py +39 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/members.py +85 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/notifications.py +57 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/passkeys/__init__.py +31 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/passkeys/ceremonies.py +140 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/passkeys/relying_party.py +62 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/passkeys/rules.py +71 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/passwords.py +87 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/recovery_codes.py +95 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/signup.py +76 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/tokens.py +75 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/totp/__init__.py +39 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/totp/algorithm.py +95 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/totp/devices.py +122 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/trusted_devices.py +99 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/verification.py +38 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/signals.py +12 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/code_base.html +9 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/code_base.txt +8 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/email_verify.html +5 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/email_verify.txt +3 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/greeting.txt +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/invite.html +13 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/invite.txt +8 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/login_2fa.html +5 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/login_2fa.txt +3 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/password_reset.html +5 -0
- tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/password_reset.txt +3 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/__init__.py +9 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/admin/__init__.py +6 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/admin/agents.py +125 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/admin/readonly.py +76 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/admin/settings.py +136 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/pagination.py +11 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/permissions.py +33 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/__init__.py +32 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/agent_links.py +115 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/agents.py +197 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/common.py +57 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/events.py +94 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/keys.py +66 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/runs.py +111 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/settings.py +158 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/skills.py +114 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/urls.py +40 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/__init__.py +20 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/agents.py +91 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/common.py +8 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/events.py +116 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/executions.py +74 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/keys.py +65 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/run_response.py +67 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/settings.py +121 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/skills.py +79 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/apps.py +13 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/admin/__init__.py +90 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/apps.py +13 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/management/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/management/commands/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/management/commands/ai_sync_catalog.py +44 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/migrations/0001_initial.py +186 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/migrations/0002_seed_models.py +246 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/migrations/__init__.py +0 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/models/__init__.py +5 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/models/ai_model.py +145 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/services/__init__.py +31 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/services/sync.py +125 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/conf.py +43 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/locale/pt_BR/LC_MESSAGES/django.po +1167 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/management/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/management/commands/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/management/commands/ai_purge_content.py +42 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/migrations/0001_initial.py +1009 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/migrations/__init__.py +0 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/models/__init__.py +34 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/models/agent.py +172 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/models/choices.py +58 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/models/event.py +140 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/models/key.py +108 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/models/settings.py +142 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/models/skill.py +143 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/models/slug.py +26 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/models/team.py +72 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/providers/__init__.py +94 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/providers/anthropic_messages.py +178 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/providers/base.py +193 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/providers/common.py +108 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/providers/errors.py +170 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/providers/openai_responses.py +153 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/agents.py +94 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/budget.py +55 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/dashboard.py +81 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/events.py +135 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/execution/__init__.py +149 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/execution/params.py +96 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/execution/results.py +97 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/execution/steps.py +153 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/keys.py +125 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/model_choice.py +50 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/origins.py +54 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/prices.py +90 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/probe.py +96 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/prompt.py +106 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/report.py +183 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/retention.py +68 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/services/skills.py +74 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/tasks/__init__.py +12 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/tasks/purge.py +13 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/tasks/run.py +132 -0
- tripaulx_sdk-0.1.0/src/tripaulx/ai/validators/__init__.py +60 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/apps.py +13 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/conf.py +42 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/crypto.py +79 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/locale/pt_BR/LC_MESSAGES/django.po +35 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/logs/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/logs/redaction.py +66 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/middleware/__init__.py +5 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/middleware/tenant.py +38 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/models/__init__.py +6 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/models/base.py +56 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/models/managers.py +18 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/testing/__init__.py +5 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/testing/cases.py +69 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/urls.py +12 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/views/__init__.py +5 -0
- tripaulx_sdk-0.1.0/src/tripaulx/core/views/health.py +31 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/__init__.py +7 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/api/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/api/permissions.py +21 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/api/serializers/__init__.py +13 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/api/serializers/documents.py +31 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/api/urls.py +19 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/api/urls_public.py +21 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/api/views/__init__.py +4 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/api/views/base.py +44 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/api/views/public.py +52 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/api/views/restricted.py +43 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/apps.py +13 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/conf.py +59 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/data-inventory.md +48 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/governance-backlog.md +38 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/incident-record-template.md +61 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/incident-register.md +41 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/incident-response-plan.md +59 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/privacy-policy.md +81 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/risk-matrix.md +49 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/terms-of-use.md +69 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/data-inventory.md +48 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/governance-backlog.md +38 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/incident-record-template.md +61 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/incident-register.md +41 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/incident-response-plan.md +59 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/privacy-policy.md +81 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/risk-matrix.md +49 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/terms-of-use.md +69 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/locale/pt_BR/LC_MESSAGES/django.po +119 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/management/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/management/commands/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/management/commands/legal_check.py +85 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/services/__init__.py +41 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/services/access.py +53 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/services/catalog.py +55 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/services/defaults.py +74 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/services/document.py +49 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/services/markdown/__init__.py +87 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/services/markdown/blocks.py +131 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/services/markdown/inline.py +71 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/services/markdown/tables.py +108 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/services/placeholders.py +45 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/services/render.py +41 -0
- tripaulx_sdk-0.1.0/src/tripaulx/legal/services/sources.py +90 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/admin/__init__.py +5 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/admin/mailgun_config.py +91 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/apps.py +13 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/backends/__init__.py +5 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/backends/mailgun.py +122 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/backends/multipart.py +24 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/conf.py +11 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/locale/pt_BR/LC_MESSAGES/django.po +91 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/migrations/0001_initial.py +78 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/migrations/__init__.py +0 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/models/__init__.py +5 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/models/mailgun_config.py +92 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/services/__init__.py +5 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/services/templated.py +51 -0
- tripaulx_sdk-0.1.0/src/tripaulx/mail/templates/tripaulx/mail/base.html +32 -0
- tripaulx_sdk-0.1.0/src/tripaulx/settings/__init__.py +6 -0
- tripaulx_sdk-0.1.0/src/tripaulx/settings/apps.py +81 -0
- tripaulx_sdk-0.1.0/src/tripaulx/settings/env.py +110 -0
- tripaulx_sdk-0.1.0/src/tripaulx/settings/middleware.py +30 -0
- tripaulx_sdk-0.1.0/src/tripaulx/settings/observability.py +38 -0
- tripaulx_sdk-0.1.0/src/tripaulx/settings/rest.py +120 -0
- tripaulx_sdk-0.1.0/src/tripaulx/settings/security.py +30 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/__init__.py +5 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/apps.py +13 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/client.py +73 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/conf.py +43 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/crypto/__init__.py +40 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/crypto/envelope.py +135 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/crypto/keys.py +56 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/exceptions.py +15 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/locale/pt_BR/LC_MESSAGES/django.po +125 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/management/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/management/commands/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/management/commands/check_bucket.py +148 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/management/commands/generate_file_key.py +35 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/services/__init__.py +34 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/services/access.py +95 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/services/keys.py +65 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/services/policy.py +126 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/services/streams.py +64 -0
- tripaulx_sdk-0.1.0/src/tripaulx/storage/services/upload.py +115 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/admin/__init__.py +5 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/admin/workspace.py +36 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/apps.py +13 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/conf.py +18 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/locale/pt_BR/LC_MESSAGES/django.po +70 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/management/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/management/commands/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/management/commands/bootstrap_workspace.py +75 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/migrations/0001_initial.py +86 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/migrations/__init__.py +0 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/models/__init__.py +6 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/models/domain.py +18 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/models/workspace.py +30 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/services/__init__.py +1 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/services/bootstrap.py +53 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/services/domains.py +18 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/services/provisioning.py +65 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/services/slugs.py +36 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/signals.py +11 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/validators/__init__.py +5 -0
- tripaulx_sdk-0.1.0/src/tripaulx/tenants/validators/slug.py +48 -0
- tripaulx_sdk-0.1.0/tests/__init__.py +0 -0
- tripaulx_sdk-0.1.0/tests/accounts/__init__.py +0 -0
- tripaulx_sdk-0.1.0/tests/accounts/helpers.py +56 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_command.py +43 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_email_verify.py +53 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_invitations.py +95 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_jwt_tenant.py +76 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_login_flow.py +117 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_members.py +102 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_passkey_rp.py +74 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_passkey_rules.py +113 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_password_change.py +44 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_password_reset.py +65 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_privileged_mfa.py +48 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_recovery_codes.py +101 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_refresh_throttle.py +36 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_signup.py +91 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_totp_algorithm.py +61 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_totp_api.py +83 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_totp_login.py +97 -0
- tripaulx_sdk-0.1.0/tests/accounts/test_trusted_devices.py +59 -0
- tripaulx_sdk-0.1.0/tests/ai/__init__.py +0 -0
- tripaulx_sdk-0.1.0/tests/ai/helpers.py +174 -0
- tripaulx_sdk-0.1.0/tests/ai/test_admin.py +64 -0
- tripaulx_sdk-0.1.0/tests/ai/test_agents_api.py +160 -0
- tripaulx_sdk-0.1.0/tests/ai/test_anthropic_client.py +155 -0
- tripaulx_sdk-0.1.0/tests/ai/test_catalog.py +133 -0
- tripaulx_sdk-0.1.0/tests/ai/test_events_api.py +86 -0
- tripaulx_sdk-0.1.0/tests/ai/test_events_budget.py +143 -0
- tripaulx_sdk-0.1.0/tests/ai/test_execution_prechecks.py +90 -0
- tripaulx_sdk-0.1.0/tests/ai/test_execution_runs.py +148 -0
- tripaulx_sdk-0.1.0/tests/ai/test_i18n.py +13 -0
- tripaulx_sdk-0.1.0/tests/ai/test_keys_api.py +82 -0
- tripaulx_sdk-0.1.0/tests/ai/test_keys_service.py +99 -0
- tripaulx_sdk-0.1.0/tests/ai/test_models.py +71 -0
- tripaulx_sdk-0.1.0/tests/ai/test_openai_call.py +136 -0
- tripaulx_sdk-0.1.0/tests/ai/test_openai_params.py +135 -0
- tripaulx_sdk-0.1.0/tests/ai/test_prices_prompt.py +98 -0
- tripaulx_sdk-0.1.0/tests/ai/test_probe.py +110 -0
- tripaulx_sdk-0.1.0/tests/ai/test_registry.py +86 -0
- tripaulx_sdk-0.1.0/tests/ai/test_report.py +86 -0
- tripaulx_sdk-0.1.0/tests/ai/test_retention.py +80 -0
- tripaulx_sdk-0.1.0/tests/ai/test_settings_api.py +107 -0
- tripaulx_sdk-0.1.0/tests/ai/test_skills_api.py +71 -0
- tripaulx_sdk-0.1.0/tests/ai/test_tasks.py +166 -0
- tripaulx_sdk-0.1.0/tests/conftest.py +27 -0
- tripaulx_sdk-0.1.0/tests/legal/__init__.py +0 -0
- tripaulx_sdk-0.1.0/tests/legal/test_access.py +29 -0
- tripaulx_sdk-0.1.0/tests/legal/test_api_public.py +51 -0
- tripaulx_sdk-0.1.0/tests/legal/test_api_restricted.py +97 -0
- tripaulx_sdk-0.1.0/tests/legal/test_catalog.py +65 -0
- tripaulx_sdk-0.1.0/tests/legal/test_markdown.py +67 -0
- tripaulx_sdk-0.1.0/tests/legal/test_placeholders.py +69 -0
- tripaulx_sdk-0.1.0/tests/legal/test_sources.py +90 -0
- tripaulx_sdk-0.1.0/tests/legal/test_tables.py +57 -0
- tripaulx_sdk-0.1.0/tests/mail/__init__.py +0 -0
- tripaulx_sdk-0.1.0/tests/mail/test_backend.py +104 -0
- tripaulx_sdk-0.1.0/tests/mail/test_config.py +46 -0
- tripaulx_sdk-0.1.0/tests/mail/test_mailers.py +47 -0
- tripaulx_sdk-0.1.0/tests/mail/test_templated.py +50 -0
- tripaulx_sdk-0.1.0/tests/project/__init__.py +0 -0
- tripaulx_sdk-0.1.0/tests/project/sample/__init__.py +1 -0
- tripaulx_sdk-0.1.0/tests/project/sample/apps.py +10 -0
- tripaulx_sdk-0.1.0/tests/project/sample/migrations/0001_initial.py +52 -0
- tripaulx_sdk-0.1.0/tests/project/sample/migrations/__init__.py +0 -0
- tripaulx_sdk-0.1.0/tests/project/sample/models.py +11 -0
- tripaulx_sdk-0.1.0/tests/project/settings.py +71 -0
- tripaulx_sdk-0.1.0/tests/project/urls.py +14 -0
- tripaulx_sdk-0.1.0/tests/project/urls_public.py +12 -0
- tripaulx_sdk-0.1.0/tests/project/users/__init__.py +1 -0
- tripaulx_sdk-0.1.0/tests/project/users/apps.py +11 -0
- tripaulx_sdk-0.1.0/tests/project/users/migrations/0001_initial.py +145 -0
- tripaulx_sdk-0.1.0/tests/project/users/migrations/__init__.py +0 -0
- tripaulx_sdk-0.1.0/tests/project/users/models.py +7 -0
- tripaulx_sdk-0.1.0/tests/storage/__init__.py +0 -0
- tripaulx_sdk-0.1.0/tests/storage/conftest.py +21 -0
- tripaulx_sdk-0.1.0/tests/storage/helpers.py +77 -0
- tripaulx_sdk-0.1.0/tests/storage/test_access.py +112 -0
- tripaulx_sdk-0.1.0/tests/storage/test_client.py +67 -0
- tripaulx_sdk-0.1.0/tests/storage/test_commands.py +109 -0
- tripaulx_sdk-0.1.0/tests/storage/test_crypto.py +139 -0
- tripaulx_sdk-0.1.0/tests/storage/test_keys.py +79 -0
- tripaulx_sdk-0.1.0/tests/storage/test_upload.py +140 -0
- tripaulx_sdk-0.1.0/tests/storage/test_upload_image.py +126 -0
- tripaulx_sdk-0.1.0/tests/test_bootstrap.py +43 -0
- tripaulx_sdk-0.1.0/tests/test_crypto.py +53 -0
- tripaulx_sdk-0.1.0/tests/test_domains.py +14 -0
- tripaulx_sdk-0.1.0/tests/test_env.py +57 -0
- tripaulx_sdk-0.1.0/tests/test_health.py +22 -0
- tripaulx_sdk-0.1.0/tests/test_i18n.py +10 -0
- tripaulx_sdk-0.1.0/tests/test_redaction.py +33 -0
- tripaulx_sdk-0.1.0/tests/test_rest_settings.py +54 -0
- tripaulx_sdk-0.1.0/tests/test_settings_helpers.py +33 -0
- tripaulx_sdk-0.1.0/tests/test_slugs.py +47 -0
- tripaulx_sdk-0.1.0/tests/test_tenant_models.py +37 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*.egg-info/
|
|
4
|
+
.venv/
|
|
5
|
+
.pytest_cache/
|
|
6
|
+
.ruff_cache/
|
|
7
|
+
.coverage
|
|
8
|
+
htmlcov/
|
|
9
|
+
dist/
|
|
10
|
+
build/
|
|
11
|
+
.env
|
|
12
|
+
.env.*
|
|
13
|
+
!.env.example
|
|
14
|
+
!.env.*.example
|
|
15
|
+
.DS_Store
|
|
16
|
+
.idea/
|
|
17
|
+
.vscode/
|
|
18
|
+
# Rendered from template/ by scripts/render_example.sh (never committed).
|
|
19
|
+
example/
|
|
20
|
+
.claude/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tripaulx
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: tripaulx-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Multi-tenant Django foundation: workspaces, accounts with mandatory 2FA and passkeys, AI providers, legal and storage.
|
|
5
|
+
Project-URL: Homepage, https://github.com/tripaulx/tripaulx-builder-init
|
|
6
|
+
Project-URL: Issues, https://github.com/tripaulx/tripaulx-builder-init/issues
|
|
7
|
+
Author-email: Flavio Almeida Paulino <f1@tripaulx.com>
|
|
8
|
+
Maintainer-email: Flavio Almeida Paulino <f1@tripaulx.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Framework :: Django
|
|
12
|
+
Classifier: Framework :: Django :: 6.0
|
|
13
|
+
Classifier: Framework :: Django :: 6.1
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Natural Language :: English
|
|
16
|
+
Classifier: Natural Language :: Portuguese (Brazilian)
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Requires-Python: >=3.12
|
|
21
|
+
Requires-Dist: cryptography>=44
|
|
22
|
+
Requires-Dist: django-cors-headers<5,>=4.9
|
|
23
|
+
Requires-Dist: django-tenants<4,>=3.14
|
|
24
|
+
Requires-Dist: django<6.2,>=6.0
|
|
25
|
+
Requires-Dist: djangorestframework-simplejwt<6,>=5.5
|
|
26
|
+
Requires-Dist: djangorestframework<4,>=3.16
|
|
27
|
+
Requires-Dist: drf-spectacular<1,>=0.28
|
|
28
|
+
Requires-Dist: nh3<1,>=0.2.17
|
|
29
|
+
Requires-Dist: psycopg[binary]<4,>=3.2
|
|
30
|
+
Requires-Dist: python-dotenv>=1.1
|
|
31
|
+
Requires-Dist: qrcode<9,>=8
|
|
32
|
+
Requires-Dist: webauthn<4,>=3
|
|
33
|
+
Provides-Extra: ai
|
|
34
|
+
Requires-Dist: anthropic>=1.0; extra == 'ai'
|
|
35
|
+
Requires-Dist: openai>=2; extra == 'ai'
|
|
36
|
+
Provides-Extra: anthropic
|
|
37
|
+
Requires-Dist: anthropic>=1.0; extra == 'anthropic'
|
|
38
|
+
Provides-Extra: openai
|
|
39
|
+
Requires-Dist: openai>=2; extra == 'openai'
|
|
40
|
+
Provides-Extra: storage
|
|
41
|
+
Requires-Dist: boto3<2,>=1.36; extra == 'storage'
|
|
42
|
+
Requires-Dist: cryptography>=44; extra == 'storage'
|
|
43
|
+
Requires-Dist: pillow>=11; extra == 'storage'
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
|
|
46
|
+
# tripaulx-sdk
|
|
47
|
+
|
|
48
|
+
The shared foundation of tripaulx-builders Django projects. It provides:
|
|
49
|
+
|
|
50
|
+
- multi-tenant Django 6 with **workspaces** (django-tenants, one PostgreSQL schema each);
|
|
51
|
+
- accounts with mandatory 2FA, an authenticator app (TOTP) and passkeys;
|
|
52
|
+
- AI providers, agents and skills with cost tracking;
|
|
53
|
+
- governance and legal documents;
|
|
54
|
+
- encrypted object storage.
|
|
55
|
+
|
|
56
|
+
It ships an API and the Django admin. There is no frontend.
|
|
57
|
+
|
|
58
|
+
> Version **0.1.0**. See the
|
|
59
|
+
> [project repository](https://github.com/tripaulx/tripaulx-builder-init) and its
|
|
60
|
+
> Copier template to start a new project.
|
|
61
|
+
|
|
62
|
+
## Install
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
uv add "tripaulx-sdk[storage,ai]" # extras: storage, openai, anthropic, ai
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Start new projects from the Copier template instead of wiring settings by hand:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
uvx copier copy --trust gh:tripaulx/tripaulx-builder-init my-project
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Maintainer
|
|
75
|
+
|
|
76
|
+
Flavio Almeida Paulino ([f1@tripaulx.com](mailto:f1@tripaulx.com?subject=%5Btripaulx-sdk%5D)).
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
MIT
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# tripaulx-sdk
|
|
2
|
+
|
|
3
|
+
The shared foundation of tripaulx-builders Django projects. It provides:
|
|
4
|
+
|
|
5
|
+
- multi-tenant Django 6 with **workspaces** (django-tenants, one PostgreSQL schema each);
|
|
6
|
+
- accounts with mandatory 2FA, an authenticator app (TOTP) and passkeys;
|
|
7
|
+
- AI providers, agents and skills with cost tracking;
|
|
8
|
+
- governance and legal documents;
|
|
9
|
+
- encrypted object storage.
|
|
10
|
+
|
|
11
|
+
It ships an API and the Django admin. There is no frontend.
|
|
12
|
+
|
|
13
|
+
> Version **0.1.0**. See the
|
|
14
|
+
> [project repository](https://github.com/tripaulx/tripaulx-builder-init) and its
|
|
15
|
+
> Copier template to start a new project.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
uv add "tripaulx-sdk[storage,ai]" # extras: storage, openai, anthropic, ai
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Start new projects from the Copier template instead of wiring settings by hand:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
uvx copier copy --trust gh:tripaulx/tripaulx-builder-init my-project
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Maintainer
|
|
30
|
+
|
|
31
|
+
Flavio Almeida Paulino ([f1@tripaulx.com](mailto:f1@tripaulx.com?subject=%5Btripaulx-sdk%5D)).
|
|
32
|
+
|
|
33
|
+
## License
|
|
34
|
+
|
|
35
|
+
MIT
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "tripaulx-sdk"
|
|
3
|
+
dynamic = ["version"]
|
|
4
|
+
description = "Multi-tenant Django foundation: workspaces, accounts with mandatory 2FA and passkeys, AI providers, legal and storage."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [{ name = "Flavio Almeida Paulino", email = "f1@tripaulx.com" }]
|
|
9
|
+
maintainers = [{ name = "Flavio Almeida Paulino", email = "f1@tripaulx.com" }]
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Framework :: Django",
|
|
13
|
+
"Framework :: Django :: 6.0",
|
|
14
|
+
"Framework :: Django :: 6.1",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.12",
|
|
17
|
+
"Programming Language :: Python :: 3.13",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Natural Language :: English",
|
|
20
|
+
"Natural Language :: Portuguese (Brazilian)",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"cryptography>=44",
|
|
24
|
+
"django>=6.0,<6.2",
|
|
25
|
+
"django-cors-headers>=4.9,<5",
|
|
26
|
+
"django-tenants>=3.14,<4",
|
|
27
|
+
"djangorestframework>=3.16,<4",
|
|
28
|
+
"djangorestframework-simplejwt>=5.5,<6",
|
|
29
|
+
"drf-spectacular>=0.28,<1",
|
|
30
|
+
"nh3>=0.2.17,<1",
|
|
31
|
+
"psycopg[binary]>=3.2,<4",
|
|
32
|
+
"python-dotenv>=1.1",
|
|
33
|
+
"qrcode>=8,<9",
|
|
34
|
+
"webauthn>=3,<4",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
# S3-compatible object storage with envelope encryption (tripaulx.storage).
|
|
39
|
+
# boto3 >= 1.36 needs request_checksum_calculation="when_required" for
|
|
40
|
+
# non-AWS providers; tripaulx.storage.client sets it.
|
|
41
|
+
storage = [
|
|
42
|
+
"boto3>=1.36,<2",
|
|
43
|
+
"cryptography>=44",
|
|
44
|
+
"pillow>=11",
|
|
45
|
+
]
|
|
46
|
+
# AI providers (tripaulx.ai). Each SDK is imported lazily, only when a call
|
|
47
|
+
# goes to that provider; "ai" installs both.
|
|
48
|
+
openai = ["openai>=2"]
|
|
49
|
+
anthropic = ["anthropic>=1.0"]
|
|
50
|
+
ai = ["openai>=2", "anthropic>=1.0"]
|
|
51
|
+
|
|
52
|
+
[project.urls]
|
|
53
|
+
Homepage = "https://github.com/tripaulx/tripaulx-builder-init"
|
|
54
|
+
Issues = "https://github.com/tripaulx/tripaulx-builder-init/issues"
|
|
55
|
+
|
|
56
|
+
[build-system]
|
|
57
|
+
requires = ["hatchling>=1.27"]
|
|
58
|
+
build-backend = "hatchling.build"
|
|
59
|
+
|
|
60
|
+
[tool.hatch.version]
|
|
61
|
+
path = "src/tripaulx/__init__.py"
|
|
62
|
+
|
|
63
|
+
[tool.hatch.build.targets.wheel]
|
|
64
|
+
packages = ["src/tripaulx"]
|
|
65
|
+
|
|
66
|
+
[tool.pytest.ini_options]
|
|
67
|
+
DJANGO_SETTINGS_MODULE = "tests.project.settings"
|
|
68
|
+
pythonpath = ["src", "."]
|
|
69
|
+
testpaths = ["tests"]
|
|
70
|
+
python_files = ["test_*.py"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Accounts: e-mail login, roles, mandatory 2FA, TOTP and passkeys."""
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Admin of the accounts app.
|
|
2
|
+
|
|
3
|
+
The security records are registered here; the user admin base class is
|
|
4
|
+
registered by each project for its concrete user model.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .security import (
|
|
8
|
+
EmailCodeAdmin,
|
|
9
|
+
InvitationAdmin,
|
|
10
|
+
RecoveryCodeAdmin,
|
|
11
|
+
TotpDeviceAdmin,
|
|
12
|
+
TrustedDeviceAdmin,
|
|
13
|
+
WebAuthnCredentialAdmin,
|
|
14
|
+
)
|
|
15
|
+
from .user import TripaulxUserAdmin
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"EmailCodeAdmin",
|
|
19
|
+
"InvitationAdmin",
|
|
20
|
+
"RecoveryCodeAdmin",
|
|
21
|
+
"TotpDeviceAdmin",
|
|
22
|
+
"TripaulxUserAdmin",
|
|
23
|
+
"TrustedDeviceAdmin",
|
|
24
|
+
"WebAuthnCredentialAdmin",
|
|
25
|
+
]
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""Read-only admin of the security records (codes, devices, passkeys).
|
|
2
|
+
|
|
3
|
+
Secrets never show: codes and tokens are hashes, the TOTP secret is
|
|
4
|
+
encrypted. Deleting a TOTP device is the way out for a user who lost both
|
|
5
|
+
the phone and the recovery codes: the login falls back to e-mail codes.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from django.contrib import admin
|
|
13
|
+
from django.http import HttpRequest
|
|
14
|
+
|
|
15
|
+
from ..models import (
|
|
16
|
+
EmailCode,
|
|
17
|
+
Invitation,
|
|
18
|
+
RecoveryCode,
|
|
19
|
+
TotpDevice,
|
|
20
|
+
TrustedDevice,
|
|
21
|
+
WebAuthnCredential,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ReadOnlyAdmin(admin.ModelAdmin):
|
|
26
|
+
"""No add and no change; deletion stays available."""
|
|
27
|
+
|
|
28
|
+
def has_add_permission(self, request: HttpRequest) -> bool:
|
|
29
|
+
"""Refuse: records are created by the account flows only."""
|
|
30
|
+
return False
|
|
31
|
+
|
|
32
|
+
def has_change_permission(self, request: HttpRequest, obj: Any = None) -> bool:
|
|
33
|
+
"""Refuse: records are never edited by hand."""
|
|
34
|
+
return False
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@admin.register(EmailCode)
|
|
38
|
+
class EmailCodeAdmin(ReadOnlyAdmin):
|
|
39
|
+
"""E-mail codes (hash only)."""
|
|
40
|
+
|
|
41
|
+
list_display = ("user", "purpose", "expires_at", "attempts", "consumed_at")
|
|
42
|
+
list_filter = ("purpose",)
|
|
43
|
+
search_fields = ("user__email",)
|
|
44
|
+
exclude = ("code_hash",)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@admin.register(RecoveryCode)
|
|
48
|
+
class RecoveryCodeAdmin(ReadOnlyAdmin):
|
|
49
|
+
"""Recovery codes; the plain text never exists after generation."""
|
|
50
|
+
|
|
51
|
+
list_display = ("prefix", "user", "label", "created_at", "used_at")
|
|
52
|
+
list_filter = ("used_at",)
|
|
53
|
+
search_fields = ("user__email", "prefix", "label")
|
|
54
|
+
exclude = ("code_hash",)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@admin.register(WebAuthnCredential)
|
|
58
|
+
class WebAuthnCredentialAdmin(ReadOnlyAdmin):
|
|
59
|
+
"""Passkeys."""
|
|
60
|
+
|
|
61
|
+
list_display = ("name", "user", "sign_count", "created_at", "last_used_at")
|
|
62
|
+
search_fields = ("user__email", "name", "credential_id")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@admin.register(TotpDevice)
|
|
66
|
+
class TotpDeviceAdmin(ReadOnlyAdmin):
|
|
67
|
+
"""Authenticator apps (the encrypted secret is hidden)."""
|
|
68
|
+
|
|
69
|
+
list_display = ("user", "confirmed_at", "created_at", "last_used_at")
|
|
70
|
+
list_filter = ("confirmed_at",)
|
|
71
|
+
search_fields = ("user__email",)
|
|
72
|
+
exclude = ("secret_encrypted",)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@admin.register(TrustedDevice)
|
|
76
|
+
class TrustedDeviceAdmin(ReadOnlyAdmin):
|
|
77
|
+
"""Trusted devices (the token hash is hidden)."""
|
|
78
|
+
|
|
79
|
+
list_display = ("user", "device_label", "ip_address", "expires_at", "is_active")
|
|
80
|
+
list_filter = ("is_active",)
|
|
81
|
+
search_fields = ("user__email", "device_label")
|
|
82
|
+
exclude = ("token_hash",)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@admin.register(Invitation)
|
|
86
|
+
class InvitationAdmin(ReadOnlyAdmin):
|
|
87
|
+
"""Invitations (the token hash is hidden)."""
|
|
88
|
+
|
|
89
|
+
list_display = ("email", "role", "invited_by", "expires_at", "accepted_at")
|
|
90
|
+
list_filter = ("role",)
|
|
91
|
+
search_fields = ("email",)
|
|
92
|
+
exclude = ("token_hash",)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Base ``ModelAdmin`` for projects to register their concrete user with."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from django.contrib.auth.admin import UserAdmin
|
|
6
|
+
from django.utils.translation import gettext_lazy as _
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TripaulxUserAdmin(UserAdmin):
|
|
10
|
+
"""User admin keyed by e-mail, with role and security flags.
|
|
11
|
+
|
|
12
|
+
Projects register it explicitly: ``admin.site.register(User,
|
|
13
|
+
TripaulxUserAdmin)``.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
ordering = ("email",)
|
|
17
|
+
list_display = ("email", "role", "is_active", "email_verified", "is_staff")
|
|
18
|
+
list_filter = ("role", "is_active", "email_verified", "is_staff")
|
|
19
|
+
search_fields = ("email", "first_name", "last_name")
|
|
20
|
+
fieldsets = (
|
|
21
|
+
(None, {"fields": ("email", "password")}),
|
|
22
|
+
(_("Personal info"), {"fields": ("first_name", "last_name")}),
|
|
23
|
+
(_("Workspace"), {"fields": ("role",)}),
|
|
24
|
+
(_("Security"), {"fields": ("email_verified", "password_login_disabled")}),
|
|
25
|
+
(
|
|
26
|
+
_("Permissions"),
|
|
27
|
+
{"fields": ("is_active", "is_staff", "is_superuser", "groups")},
|
|
28
|
+
),
|
|
29
|
+
(_("Important dates"), {"fields": ("last_login", "date_joined")}),
|
|
30
|
+
)
|
|
31
|
+
add_fieldsets = (
|
|
32
|
+
(None, {"classes": ("wide",), "fields": ("email", "password1", "password2")}),
|
|
33
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""REST API of the accounts app."""
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""DRF authentication: SimpleJWT plus the workspace (schema) check.
|
|
2
|
+
|
|
3
|
+
Use it instead of the plain ``JWTAuthentication`` in
|
|
4
|
+
``DEFAULT_AUTHENTICATION_CLASSES`` (``tripaulx.settings.rest`` does). Why:
|
|
5
|
+
see :mod:`tripaulx.accounts.services.tokens`.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from rest_framework_simplejwt.authentication import JWTAuthentication
|
|
11
|
+
from rest_framework_simplejwt.tokens import Token
|
|
12
|
+
|
|
13
|
+
from ..services.tokens import check_schema
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TenantJWTAuthentication(JWTAuthentication):
|
|
17
|
+
"""Accept only tokens issued in the current workspace schema.
|
|
18
|
+
|
|
19
|
+
The check runs in ``get_validated_token`` (not ``get_user``) so a foreign
|
|
20
|
+
token dies before any query hits this schema.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def get_validated_token(self, raw_token: bytes) -> Token:
|
|
24
|
+
"""Validate the signature, then the schema claim."""
|
|
25
|
+
token = super().get_validated_token(raw_token)
|
|
26
|
+
check_schema(token)
|
|
27
|
+
return token
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""DRF permissions based on the workspace role."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from rest_framework.permissions import BasePermission
|
|
8
|
+
from rest_framework.request import Request
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class IsWorkspaceAdmin(BasePermission):
|
|
12
|
+
"""Allow active owners and admins of the current workspace."""
|
|
13
|
+
|
|
14
|
+
def has_permission(self, request: Request, view: Any) -> bool:
|
|
15
|
+
"""Check ``user.is_workspace_admin``."""
|
|
16
|
+
user = request.user
|
|
17
|
+
return bool(
|
|
18
|
+
user
|
|
19
|
+
and user.is_authenticated
|
|
20
|
+
and getattr(user, "is_workspace_admin", False)
|
|
21
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""OpenAPI (drf-spectacular) glue for the accounts API.
|
|
2
|
+
|
|
3
|
+
Imported by ``AccountsConfig.ready`` so the authentication extension is
|
|
4
|
+
registered before any schema is generated.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from drf_spectacular.contrib.rest_framework_simplejwt import SimpleJWTScheme
|
|
10
|
+
from drf_spectacular.types import OpenApiTypes
|
|
11
|
+
from drf_spectacular.utils import extend_schema
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TenantJWTScheme(SimpleJWTScheme):
|
|
15
|
+
"""Describe ``TenantJWTAuthentication`` as a plain bearer JWT."""
|
|
16
|
+
|
|
17
|
+
target_class = "tripaulx.accounts.api.authentication.TenantJWTAuthentication"
|
|
18
|
+
name = "jwtAuth"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
#: For views without a request serializer that answer free-form JSON.
|
|
22
|
+
untyped = extend_schema(request=None, responses=OpenApiTypes.OBJECT)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Serializers of the accounts API."""
|
|
2
|
+
|
|
3
|
+
from .auth import (
|
|
4
|
+
CodeSerializer,
|
|
5
|
+
EmailCodeSerializer,
|
|
6
|
+
EmailSerializer,
|
|
7
|
+
LoginSerializer,
|
|
8
|
+
LoginVerifySerializer,
|
|
9
|
+
PasswordChangeSerializer,
|
|
10
|
+
PasswordResetConfirmSerializer,
|
|
11
|
+
RecoveryCodesSerializer,
|
|
12
|
+
RefreshSerializer,
|
|
13
|
+
TicketSerializer,
|
|
14
|
+
)
|
|
15
|
+
from .devices import (
|
|
16
|
+
PasskeyLoginBeginSerializer,
|
|
17
|
+
PasskeyLoginCompleteSerializer,
|
|
18
|
+
PasskeyRegisterSerializer,
|
|
19
|
+
PasskeySerializer,
|
|
20
|
+
PasswordLoginToggleSerializer,
|
|
21
|
+
TrustedDeviceSerializer,
|
|
22
|
+
)
|
|
23
|
+
from .user import MemberRoleSerializer, MemberSerializer, UserSerializer
|
|
24
|
+
from .workspace import (
|
|
25
|
+
InvitationAcceptSerializer,
|
|
26
|
+
InvitationCreateSerializer,
|
|
27
|
+
InvitationSerializer,
|
|
28
|
+
SignupSerializer,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
"CodeSerializer",
|
|
33
|
+
"EmailCodeSerializer",
|
|
34
|
+
"EmailSerializer",
|
|
35
|
+
"InvitationAcceptSerializer",
|
|
36
|
+
"InvitationCreateSerializer",
|
|
37
|
+
"InvitationSerializer",
|
|
38
|
+
"LoginSerializer",
|
|
39
|
+
"LoginVerifySerializer",
|
|
40
|
+
"MemberRoleSerializer",
|
|
41
|
+
"MemberSerializer",
|
|
42
|
+
"PasskeyLoginBeginSerializer",
|
|
43
|
+
"PasskeyLoginCompleteSerializer",
|
|
44
|
+
"PasskeyRegisterSerializer",
|
|
45
|
+
"PasskeySerializer",
|
|
46
|
+
"PasswordChangeSerializer",
|
|
47
|
+
"PasswordLoginToggleSerializer",
|
|
48
|
+
"PasswordResetConfirmSerializer",
|
|
49
|
+
"RecoveryCodesSerializer",
|
|
50
|
+
"RefreshSerializer",
|
|
51
|
+
"SignupSerializer",
|
|
52
|
+
"TicketSerializer",
|
|
53
|
+
"TrustedDeviceSerializer",
|
|
54
|
+
"UserSerializer",
|
|
55
|
+
]
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""Input serializers of login, codes and passwords.
|
|
2
|
+
|
|
3
|
+
Password strength is checked by the services (one rule, one place), so the
|
|
4
|
+
serializers only check shapes.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from rest_framework import serializers
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class EmailSerializer(serializers.Serializer):
|
|
13
|
+
"""Just an e-mail address."""
|
|
14
|
+
|
|
15
|
+
email = serializers.EmailField()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class EmailCodeSerializer(serializers.Serializer):
|
|
19
|
+
"""An e-mail address and the code sent to it."""
|
|
20
|
+
|
|
21
|
+
email = serializers.EmailField()
|
|
22
|
+
code = serializers.CharField(min_length=4, max_length=12)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class LoginSerializer(serializers.Serializer):
|
|
26
|
+
"""E-mail, password and an optional trusted-device token."""
|
|
27
|
+
|
|
28
|
+
email = serializers.EmailField()
|
|
29
|
+
password = serializers.CharField(write_only=True, trim_whitespace=False)
|
|
30
|
+
device_token = serializers.CharField(required=False, allow_blank=True, default="")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class LoginVerifySerializer(serializers.Serializer):
|
|
34
|
+
"""Second factor: app or e-mail code, or a recovery code (longer)."""
|
|
35
|
+
|
|
36
|
+
ticket = serializers.CharField()
|
|
37
|
+
code = serializers.CharField(min_length=4, max_length=24)
|
|
38
|
+
trust_device = serializers.BooleanField(required=False, default=False)
|
|
39
|
+
device_label = serializers.CharField(
|
|
40
|
+
required=False, allow_blank=True, default="", max_length=120
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class TicketSerializer(serializers.Serializer):
|
|
45
|
+
"""The login ticket alone (resend)."""
|
|
46
|
+
|
|
47
|
+
ticket = serializers.CharField(required=False, allow_blank=True, default="")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class CodeSerializer(serializers.Serializer):
|
|
51
|
+
"""An authenticator code or, where accepted, a recovery code."""
|
|
52
|
+
|
|
53
|
+
code = serializers.CharField(min_length=4, max_length=24)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class RecoveryCodesSerializer(serializers.Serializer):
|
|
57
|
+
"""How many recovery codes to generate."""
|
|
58
|
+
|
|
59
|
+
quantity = serializers.IntegerField(
|
|
60
|
+
required=False, default=None, min_value=1, max_value=20
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class PasswordResetConfirmSerializer(serializers.Serializer):
|
|
65
|
+
"""E-mail, reset code and the new password."""
|
|
66
|
+
|
|
67
|
+
email = serializers.EmailField()
|
|
68
|
+
code = serializers.CharField(min_length=4, max_length=12)
|
|
69
|
+
password = serializers.CharField(write_only=True, trim_whitespace=False)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class PasswordChangeSerializer(serializers.Serializer):
|
|
73
|
+
"""Current and new password of the logged-in user."""
|
|
74
|
+
|
|
75
|
+
current_password = serializers.CharField(write_only=True, trim_whitespace=False)
|
|
76
|
+
new_password = serializers.CharField(write_only=True, trim_whitespace=False)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class RefreshSerializer(serializers.Serializer):
|
|
80
|
+
"""A refresh token (logout)."""
|
|
81
|
+
|
|
82
|
+
refresh = serializers.CharField(required=False, allow_blank=True, default="")
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Serializers of passkeys and trusted devices."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from rest_framework import serializers
|
|
6
|
+
|
|
7
|
+
from ...models import TrustedDevice, WebAuthnCredential
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PasskeySerializer(serializers.ModelSerializer):
|
|
11
|
+
"""A passkey as listed to its owner; ``name`` is the only editable field."""
|
|
12
|
+
|
|
13
|
+
class Meta:
|
|
14
|
+
model = WebAuthnCredential
|
|
15
|
+
fields = ["id", "name", "created_at", "last_used_at"]
|
|
16
|
+
read_only_fields = ["id", "created_at", "last_used_at"]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
DEFAULT_PASSKEY_NAME = "Passkey"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class PasskeyRegisterSerializer(serializers.Serializer):
|
|
23
|
+
"""The browser's registration response and a name for the passkey."""
|
|
24
|
+
|
|
25
|
+
credential = serializers.JSONField()
|
|
26
|
+
name = serializers.CharField(
|
|
27
|
+
required=False, allow_blank=True, default=DEFAULT_PASSKEY_NAME, max_length=120
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class PasswordLoginToggleSerializer(serializers.Serializer):
|
|
32
|
+
"""``disabled=True`` closes e-mail and password login."""
|
|
33
|
+
|
|
34
|
+
disabled = serializers.BooleanField()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class PasskeyLoginBeginSerializer(serializers.Serializer):
|
|
38
|
+
"""Optional e-mail; without it any passkey of the workspace may answer."""
|
|
39
|
+
|
|
40
|
+
email = serializers.EmailField(required=False, allow_blank=True, default="")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class PasskeyLoginCompleteSerializer(serializers.Serializer):
|
|
44
|
+
"""The ticket from "begin" and the browser's assertion."""
|
|
45
|
+
|
|
46
|
+
ticket = serializers.CharField()
|
|
47
|
+
credential = serializers.JSONField()
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class TrustedDeviceSerializer(serializers.ModelSerializer):
|
|
51
|
+
"""A trusted device as listed to its owner (never the token)."""
|
|
52
|
+
|
|
53
|
+
class Meta:
|
|
54
|
+
model = TrustedDevice
|
|
55
|
+
fields = [
|
|
56
|
+
"id",
|
|
57
|
+
"device_label",
|
|
58
|
+
"ip_address",
|
|
59
|
+
"user_agent",
|
|
60
|
+
"created_at",
|
|
61
|
+
"last_used_at",
|
|
62
|
+
"expires_at",
|
|
63
|
+
]
|
|
64
|
+
read_only_fields = fields
|