django-integrations 0.4.0__tar.gz → 2.0.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.
- django_integrations-2.0.0/PKG-INFO +116 -0
- django_integrations-2.0.0/README.md +66 -0
- {django_integrations-0.4.0 → django_integrations-2.0.0}/pyproject.toml +41 -8
- django_integrations-2.0.0/src/django_integrations.egg-info/PKG-INFO +116 -0
- django_integrations-2.0.0/src/django_integrations.egg-info/SOURCES.txt +70 -0
- {django_integrations-0.4.0 → django_integrations-2.0.0}/src/django_integrations.egg-info/requires.txt +5 -3
- django_integrations-2.0.0/src/integrations/__init__.py +23 -0
- django_integrations-2.0.0/src/integrations/admin.py +70 -0
- django_integrations-2.0.0/src/integrations/api/errors.py +24 -0
- django_integrations-2.0.0/src/integrations/api/openapi.py +269 -0
- django_integrations-2.0.0/src/integrations/api/serializers.py +48 -0
- django_integrations-2.0.0/src/integrations/api/urls.py +36 -0
- django_integrations-2.0.0/src/integrations/api/views.py +153 -0
- {django_integrations-0.4.0 → django_integrations-2.0.0}/src/integrations/apps.py +3 -0
- django_integrations-2.0.0/src/integrations/base.py +184 -0
- django_integrations-2.0.0/src/integrations/capabilities.py +13 -0
- django_integrations-2.0.0/src/integrations/checks.py +129 -0
- django_integrations-2.0.0/src/integrations/conf.py +85 -0
- django_integrations-2.0.0/src/integrations/encrypted_fields.py +55 -0
- django_integrations-2.0.0/src/integrations/exceptions.py +53 -0
- django_integrations-2.0.0/src/integrations/fields/__init__.py +27 -0
- django_integrations-2.0.0/src/integrations/fields/base.py +226 -0
- django_integrations-2.0.0/src/integrations/fields/encrypted.py +54 -0
- django_integrations-2.0.0/src/integrations/forms/__init__.py +3 -0
- django_integrations-2.0.0/src/integrations/forms/integrations.py +49 -0
- django_integrations-2.0.0/src/integrations/management/commands/__init__.py +0 -0
- django_integrations-2.0.0/src/integrations/management/commands/rotate_encryption_keys.py +99 -0
- django_integrations-2.0.0/src/integrations/migrations/0002_credential_config_credential_integration_and_more.py +56 -0
- django_integrations-2.0.0/src/integrations/migrations/__init__.py +0 -0
- {django_integrations-0.4.0 → django_integrations-2.0.0}/src/integrations/models.py +17 -1
- django_integrations-2.0.0/src/integrations/permissions.py +53 -0
- django_integrations-2.0.0/src/integrations/registry.py +45 -0
- django_integrations-2.0.0/src/integrations/scopes.py +28 -0
- django_integrations-2.0.0/src/integrations/services/__init__.py +17 -0
- django_integrations-2.0.0/src/integrations/services/credentials.py +171 -0
- django_integrations-2.0.0/src/integrations/templates/integrations/base.html +36 -0
- django_integrations-2.0.0/src/integrations/templates/integrations/configure_form.html +35 -0
- django_integrations-2.0.0/src/integrations/templates/integrations/confirm_delete.html +13 -0
- django_integrations-2.0.0/src/integrations/templates/integrations/detail.html +61 -0
- django_integrations-2.0.0/src/integrations/templates/integrations/list.html +35 -0
- django_integrations-2.0.0/src/integrations/urls.py +21 -0
- django_integrations-2.0.0/src/integrations/views/__init__.py +15 -0
- django_integrations-2.0.0/src/integrations/views/integrations.py +234 -0
- django_integrations-2.0.0/tests/test_admin.py +157 -0
- django_integrations-2.0.0/tests/test_api_errors.py +29 -0
- django_integrations-2.0.0/tests/test_api_serializers.py +95 -0
- django_integrations-2.0.0/tests/test_api_views.py +347 -0
- django_integrations-2.0.0/tests/test_base.py +112 -0
- django_integrations-2.0.0/tests/test_capabilities.py +33 -0
- django_integrations-2.0.0/tests/test_checks.py +146 -0
- django_integrations-2.0.0/tests/test_conf.py +84 -0
- django_integrations-2.0.0/tests/test_credential_service.py +320 -0
- django_integrations-2.0.0/tests/test_encrypted_fields.py +69 -0
- django_integrations-2.0.0/tests/test_encrypted_json_field.py +69 -0
- django_integrations-2.0.0/tests/test_fields.py +163 -0
- django_integrations-2.0.0/tests/test_forms.py +64 -0
- django_integrations-2.0.0/tests/test_html_views.py +368 -0
- django_integrations-2.0.0/tests/test_http_tenant_isolation.py +140 -0
- django_integrations-2.0.0/tests/test_models.py +111 -0
- django_integrations-2.0.0/tests/test_openapi.py +32 -0
- django_integrations-2.0.0/tests/test_permissions.py +75 -0
- django_integrations-2.0.0/tests/test_registry.py +84 -0
- django_integrations-2.0.0/tests/test_rotate_encryption_keys.py +100 -0
- django_integrations-2.0.0/tests/test_scopes.py +35 -0
- django_integrations-2.0.0/tests/test_urls.py +30 -0
- django_integrations-0.4.0/PKG-INFO +0 -121
- django_integrations-0.4.0/README.md +0 -78
- django_integrations-0.4.0/src/django_integrations.egg-info/PKG-INFO +0 -121
- django_integrations-0.4.0/src/django_integrations.egg-info/SOURCES.txt +0 -21
- django_integrations-0.4.0/src/integrations/admin.py +0 -12
- django_integrations-0.4.0/src/integrations/api/seriealizers.py +0 -9
- django_integrations-0.4.0/src/integrations/api/urls.py +0 -7
- django_integrations-0.4.0/src/integrations/api/views.py +0 -9
- django_integrations-0.4.0/src/integrations/encrypted_fields.py +0 -52
- django_integrations-0.4.0/src/integrations/tests.py +0 -125
- django_integrations-0.4.0/src/integrations/urls.py +0 -7
- django_integrations-0.4.0/src/integrations/views.py +0 -5
- {django_integrations-0.4.0 → django_integrations-2.0.0}/LICENSE.mit.txt +0 -0
- {django_integrations-0.4.0 → django_integrations-2.0.0}/setup.cfg +0 -0
- {django_integrations-0.4.0 → django_integrations-2.0.0}/src/django_integrations.egg-info/dependency_links.txt +0 -0
- {django_integrations-0.4.0 → django_integrations-2.0.0}/src/django_integrations.egg-info/top_level.txt +0 -0
- {django_integrations-0.4.0/src/integrations → django_integrations-2.0.0/src/integrations/api}/__init__.py +0 -0
- {django_integrations-0.4.0/src/integrations/migrations → django_integrations-2.0.0/src/integrations/management}/__init__.py +0 -0
- {django_integrations-0.4.0 → django_integrations-2.0.0}/src/integrations/migrations/0001_initial.py +0 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: django-integrations
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Tools for creating and managing multi-site integrations like API Keys and Tokens.
|
|
5
|
+
Author: Roberto Himmelbauer
|
|
6
|
+
Author-email: Grant Viklund <renderbox@gmail.com>
|
|
7
|
+
Project-URL: Homepage, https://github.com/renderbox/django-integrations
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/renderbox/django-integrations/issues
|
|
9
|
+
Keywords: django,app
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Framework :: Django
|
|
12
|
+
Classifier: Framework :: Django :: 5.2
|
|
13
|
+
Classifier: Framework :: Django :: 6.0
|
|
14
|
+
Classifier: Framework :: Django :: 6.1
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE.mit.txt
|
|
24
|
+
Requires-Dist: Django<7.0,>=5.2
|
|
25
|
+
Requires-Dist: cryptography<46.0.0,>=45.0.2
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: black; extra == "dev"
|
|
28
|
+
Requires-Dist: flake8; extra == "dev"
|
|
29
|
+
Requires-Dist: flake8-black; extra == "dev"
|
|
30
|
+
Requires-Dist: mypy; extra == "dev"
|
|
31
|
+
Requires-Dist: django-stubs; extra == "dev"
|
|
32
|
+
Requires-Dist: bandit; extra == "dev"
|
|
33
|
+
Requires-Dist: isort; extra == "dev"
|
|
34
|
+
Requires-Dist: dj-database-url; extra == "dev"
|
|
35
|
+
Requires-Dist: django-crispy-forms; extra == "dev"
|
|
36
|
+
Requires-Dist: django-allauth; extra == "dev"
|
|
37
|
+
Requires-Dist: django-extensions; extra == "dev"
|
|
38
|
+
Requires-Dist: psycopg2-binary; extra == "dev"
|
|
39
|
+
Provides-Extra: test
|
|
40
|
+
Requires-Dist: coverage; extra == "test"
|
|
41
|
+
Requires-Dist: pytest; extra == "test"
|
|
42
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
43
|
+
Requires-Dist: pytest-django>=4.12; extra == "test"
|
|
44
|
+
Requires-Dist: dj-database-url; extra == "test"
|
|
45
|
+
Requires-Dist: django-crispy-forms>=2.4; extra == "test"
|
|
46
|
+
Requires-Dist: django-allauth; extra == "test"
|
|
47
|
+
Requires-Dist: django-extensions; extra == "test"
|
|
48
|
+
Requires-Dist: psycopg2-binary; extra == "test"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
[](https://github.com/renderbox/django-integrations/actions/workflows/python-test.yml)
|
|
52
|
+
|
|
53
|
+
[](https://github.com/renderbox/django-integrations/actions/workflows/python-publish.yml)
|
|
54
|
+
|
|
55
|
+
# Django Integrations
|
|
56
|
+
|
|
57
|
+
Tools for defining, storing, validating, and managing multi-site
|
|
58
|
+
integrations - API keys, tokens, and their non-secret configuration -
|
|
59
|
+
without duplicating each provider's schema across models, forms, an API,
|
|
60
|
+
and an admin.
|
|
61
|
+
|
|
62
|
+
An `Integration` subclass is the single, canonical description of a
|
|
63
|
+
provider. Everything else - encrypted secret storage, tenant-scoped
|
|
64
|
+
retrieval, a generated edit form, JSON API metadata, secure partial
|
|
65
|
+
updates - is derived from it:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from integrations import Integration, register
|
|
69
|
+
from integrations.fields import SecretField, TextField
|
|
70
|
+
|
|
71
|
+
@register
|
|
72
|
+
class ZoomIntegration(Integration):
|
|
73
|
+
slug = "zoom"
|
|
74
|
+
name = "Zoom"
|
|
75
|
+
fields = [
|
|
76
|
+
TextField("account_id", label="Account ID", required=True),
|
|
77
|
+
SecretField("api_key", label="API Key", required=True),
|
|
78
|
+
]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
No stored secret is ever returned by any interface once saved.
|
|
82
|
+
|
|
83
|
+
## Installation
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install django-integrations
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
INSTALLED_APPS = [
|
|
91
|
+
...,
|
|
92
|
+
"django.contrib.sites",
|
|
93
|
+
"integrations",
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
SITE_ID = 1
|
|
97
|
+
ENCRYPTED_FIELD_KEYS = ["..."] # see docs/encryption.md - required
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Full documentation, including the required settings, the JSON API, the
|
|
101
|
+
built-in HTML UI, and connection testing, is in [`docs/`](docs/index.md).
|
|
102
|
+
|
|
103
|
+
## For developers
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pip install -e ".[dev,test]"
|
|
107
|
+
pytest --cov=integrations tests
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`develop/` is a complete, runnable Django project demonstrating the
|
|
111
|
+
package (see [`docs/installation.md`](docs/installation.md#try-it) for
|
|
112
|
+
how to run it) - its example integrations live in
|
|
113
|
+
[`develop/core/integrations.py`](develop/core/integrations.py).
|
|
114
|
+
|
|
115
|
+
See [`AGENTS.md`](AGENTS.md) and [`plans/`](plans/) for the
|
|
116
|
+
architecture and the project's own development plan.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
[](https://github.com/renderbox/django-integrations/actions/workflows/python-test.yml)
|
|
2
|
+
|
|
3
|
+
[](https://github.com/renderbox/django-integrations/actions/workflows/python-publish.yml)
|
|
4
|
+
|
|
5
|
+
# Django Integrations
|
|
6
|
+
|
|
7
|
+
Tools for defining, storing, validating, and managing multi-site
|
|
8
|
+
integrations - API keys, tokens, and their non-secret configuration -
|
|
9
|
+
without duplicating each provider's schema across models, forms, an API,
|
|
10
|
+
and an admin.
|
|
11
|
+
|
|
12
|
+
An `Integration` subclass is the single, canonical description of a
|
|
13
|
+
provider. Everything else - encrypted secret storage, tenant-scoped
|
|
14
|
+
retrieval, a generated edit form, JSON API metadata, secure partial
|
|
15
|
+
updates - is derived from it:
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from integrations import Integration, register
|
|
19
|
+
from integrations.fields import SecretField, TextField
|
|
20
|
+
|
|
21
|
+
@register
|
|
22
|
+
class ZoomIntegration(Integration):
|
|
23
|
+
slug = "zoom"
|
|
24
|
+
name = "Zoom"
|
|
25
|
+
fields = [
|
|
26
|
+
TextField("account_id", label="Account ID", required=True),
|
|
27
|
+
SecretField("api_key", label="API Key", required=True),
|
|
28
|
+
]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
No stored secret is ever returned by any interface once saved.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install django-integrations
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
INSTALLED_APPS = [
|
|
41
|
+
...,
|
|
42
|
+
"django.contrib.sites",
|
|
43
|
+
"integrations",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
SITE_ID = 1
|
|
47
|
+
ENCRYPTED_FIELD_KEYS = ["..."] # see docs/encryption.md - required
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Full documentation, including the required settings, the JSON API, the
|
|
51
|
+
built-in HTML UI, and connection testing, is in [`docs/`](docs/index.md).
|
|
52
|
+
|
|
53
|
+
## For developers
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install -e ".[dev,test]"
|
|
57
|
+
pytest --cov=integrations tests
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`develop/` is a complete, runnable Django project demonstrating the
|
|
61
|
+
package (see [`docs/installation.md`](docs/installation.md#try-it) for
|
|
62
|
+
how to run it) - its example integrations live in
|
|
63
|
+
[`develop/core/integrations.py`](develop/core/integrations.py).
|
|
64
|
+
|
|
65
|
+
See [`AGENTS.md`](AGENTS.md) and [`plans/`](plans/) for the
|
|
66
|
+
architecture and the project's own development plan.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "django-integrations"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "2.0.0"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name="Grant Viklund", email="renderbox@gmail.com" },
|
|
10
10
|
{ name="Roberto Himmelbauer" },
|
|
@@ -14,15 +14,20 @@ readme = "README.md"
|
|
|
14
14
|
requires-python = ">=3.10"
|
|
15
15
|
classifiers = [
|
|
16
16
|
"Intended Audience :: Developers",
|
|
17
|
+
"Framework :: Django",
|
|
18
|
+
"Framework :: Django :: 5.2",
|
|
19
|
+
"Framework :: Django :: 6.0",
|
|
20
|
+
"Framework :: Django :: 6.1",
|
|
17
21
|
"Programming Language :: Python :: 3 :: Only",
|
|
18
22
|
"Programming Language :: Python :: 3.10",
|
|
19
23
|
"Programming Language :: Python :: 3.11",
|
|
20
24
|
"Programming Language :: Python :: 3.12",
|
|
21
25
|
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Programming Language :: Python :: 3.14",
|
|
22
27
|
]
|
|
23
28
|
keywords = ["django", "app"]
|
|
24
29
|
dependencies = [
|
|
25
|
-
"Django>=
|
|
30
|
+
"Django>=5.2,<7.0",
|
|
26
31
|
"cryptography (>=45.0.2,<46.0.0)",
|
|
27
32
|
]
|
|
28
33
|
|
|
@@ -32,6 +37,7 @@ dev = [
|
|
|
32
37
|
"flake8",
|
|
33
38
|
"flake8-black",
|
|
34
39
|
"mypy",
|
|
40
|
+
"django-stubs",
|
|
35
41
|
"bandit",
|
|
36
42
|
"isort",
|
|
37
43
|
'dj-database-url',
|
|
@@ -43,9 +49,10 @@ dev = [
|
|
|
43
49
|
test = [
|
|
44
50
|
"coverage",
|
|
45
51
|
"pytest",
|
|
46
|
-
"pytest-
|
|
52
|
+
"pytest-cov",
|
|
53
|
+
"pytest-django>=4.12",
|
|
47
54
|
'dj-database-url',
|
|
48
|
-
'django-crispy-forms',
|
|
55
|
+
'django-crispy-forms>=2.4',
|
|
49
56
|
'django-allauth',
|
|
50
57
|
'django-extensions',
|
|
51
58
|
'psycopg2-binary',
|
|
@@ -58,9 +65,35 @@ test = [
|
|
|
58
65
|
[tool.setuptools.packages.find]
|
|
59
66
|
where = ["src"]
|
|
60
67
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
]
|
|
68
|
+
# Without this the wheel ships no templates and the built-in HTML views fail
|
|
69
|
+
# with TemplateDoesNotExist once installed from PyPI (the tests run against
|
|
70
|
+
# the source tree, so only the CI "package" job catches it).
|
|
71
|
+
[tool.setuptools.package-data]
|
|
72
|
+
integrations = ["templates/**/*"]
|
|
73
|
+
|
|
74
|
+
[tool.black]
|
|
75
|
+
|
|
76
|
+
[tool.isort]
|
|
77
|
+
profile = "black"
|
|
78
|
+
known_first_party = ["integrations"]
|
|
79
|
+
|
|
80
|
+
[tool.mypy]
|
|
81
|
+
python_version = "3.10"
|
|
82
|
+
plugins = ["mypy_django_plugin.main"]
|
|
83
|
+
mypy_path = "src"
|
|
84
|
+
explicit_package_bases = true
|
|
85
|
+
ignore_missing_imports = true
|
|
86
|
+
|
|
87
|
+
[tool.django-stubs]
|
|
88
|
+
django_settings_module = "tests.settings"
|
|
89
|
+
|
|
90
|
+
[tool.bandit]
|
|
91
|
+
exclude_dirs = ["tests", "develop"]
|
|
92
|
+
|
|
93
|
+
[tool.coverage.run]
|
|
94
|
+
source = ["integrations"]
|
|
95
|
+
branch = true
|
|
65
96
|
|
|
97
|
+
[tool.coverage.report]
|
|
98
|
+
show_missing = true
|
|
66
99
|
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: django-integrations
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Tools for creating and managing multi-site integrations like API Keys and Tokens.
|
|
5
|
+
Author: Roberto Himmelbauer
|
|
6
|
+
Author-email: Grant Viklund <renderbox@gmail.com>
|
|
7
|
+
Project-URL: Homepage, https://github.com/renderbox/django-integrations
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/renderbox/django-integrations/issues
|
|
9
|
+
Keywords: django,app
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Framework :: Django
|
|
12
|
+
Classifier: Framework :: Django :: 5.2
|
|
13
|
+
Classifier: Framework :: Django :: 6.0
|
|
14
|
+
Classifier: Framework :: Django :: 6.1
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE.mit.txt
|
|
24
|
+
Requires-Dist: Django<7.0,>=5.2
|
|
25
|
+
Requires-Dist: cryptography<46.0.0,>=45.0.2
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: black; extra == "dev"
|
|
28
|
+
Requires-Dist: flake8; extra == "dev"
|
|
29
|
+
Requires-Dist: flake8-black; extra == "dev"
|
|
30
|
+
Requires-Dist: mypy; extra == "dev"
|
|
31
|
+
Requires-Dist: django-stubs; extra == "dev"
|
|
32
|
+
Requires-Dist: bandit; extra == "dev"
|
|
33
|
+
Requires-Dist: isort; extra == "dev"
|
|
34
|
+
Requires-Dist: dj-database-url; extra == "dev"
|
|
35
|
+
Requires-Dist: django-crispy-forms; extra == "dev"
|
|
36
|
+
Requires-Dist: django-allauth; extra == "dev"
|
|
37
|
+
Requires-Dist: django-extensions; extra == "dev"
|
|
38
|
+
Requires-Dist: psycopg2-binary; extra == "dev"
|
|
39
|
+
Provides-Extra: test
|
|
40
|
+
Requires-Dist: coverage; extra == "test"
|
|
41
|
+
Requires-Dist: pytest; extra == "test"
|
|
42
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
43
|
+
Requires-Dist: pytest-django>=4.12; extra == "test"
|
|
44
|
+
Requires-Dist: dj-database-url; extra == "test"
|
|
45
|
+
Requires-Dist: django-crispy-forms>=2.4; extra == "test"
|
|
46
|
+
Requires-Dist: django-allauth; extra == "test"
|
|
47
|
+
Requires-Dist: django-extensions; extra == "test"
|
|
48
|
+
Requires-Dist: psycopg2-binary; extra == "test"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
[](https://github.com/renderbox/django-integrations/actions/workflows/python-test.yml)
|
|
52
|
+
|
|
53
|
+
[](https://github.com/renderbox/django-integrations/actions/workflows/python-publish.yml)
|
|
54
|
+
|
|
55
|
+
# Django Integrations
|
|
56
|
+
|
|
57
|
+
Tools for defining, storing, validating, and managing multi-site
|
|
58
|
+
integrations - API keys, tokens, and their non-secret configuration -
|
|
59
|
+
without duplicating each provider's schema across models, forms, an API,
|
|
60
|
+
and an admin.
|
|
61
|
+
|
|
62
|
+
An `Integration` subclass is the single, canonical description of a
|
|
63
|
+
provider. Everything else - encrypted secret storage, tenant-scoped
|
|
64
|
+
retrieval, a generated edit form, JSON API metadata, secure partial
|
|
65
|
+
updates - is derived from it:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from integrations import Integration, register
|
|
69
|
+
from integrations.fields import SecretField, TextField
|
|
70
|
+
|
|
71
|
+
@register
|
|
72
|
+
class ZoomIntegration(Integration):
|
|
73
|
+
slug = "zoom"
|
|
74
|
+
name = "Zoom"
|
|
75
|
+
fields = [
|
|
76
|
+
TextField("account_id", label="Account ID", required=True),
|
|
77
|
+
SecretField("api_key", label="API Key", required=True),
|
|
78
|
+
]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
No stored secret is ever returned by any interface once saved.
|
|
82
|
+
|
|
83
|
+
## Installation
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install django-integrations
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
INSTALLED_APPS = [
|
|
91
|
+
...,
|
|
92
|
+
"django.contrib.sites",
|
|
93
|
+
"integrations",
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
SITE_ID = 1
|
|
97
|
+
ENCRYPTED_FIELD_KEYS = ["..."] # see docs/encryption.md - required
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Full documentation, including the required settings, the JSON API, the
|
|
101
|
+
built-in HTML UI, and connection testing, is in [`docs/`](docs/index.md).
|
|
102
|
+
|
|
103
|
+
## For developers
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pip install -e ".[dev,test]"
|
|
107
|
+
pytest --cov=integrations tests
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`develop/` is a complete, runnable Django project demonstrating the
|
|
111
|
+
package (see [`docs/installation.md`](docs/installation.md#try-it) for
|
|
112
|
+
how to run it) - its example integrations live in
|
|
113
|
+
[`develop/core/integrations.py`](develop/core/integrations.py).
|
|
114
|
+
|
|
115
|
+
See [`AGENTS.md`](AGENTS.md) and [`plans/`](plans/) for the
|
|
116
|
+
architecture and the project's own development plan.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
LICENSE.mit.txt
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/django_integrations.egg-info/PKG-INFO
|
|
5
|
+
src/django_integrations.egg-info/SOURCES.txt
|
|
6
|
+
src/django_integrations.egg-info/dependency_links.txt
|
|
7
|
+
src/django_integrations.egg-info/requires.txt
|
|
8
|
+
src/django_integrations.egg-info/top_level.txt
|
|
9
|
+
src/integrations/__init__.py
|
|
10
|
+
src/integrations/admin.py
|
|
11
|
+
src/integrations/apps.py
|
|
12
|
+
src/integrations/base.py
|
|
13
|
+
src/integrations/capabilities.py
|
|
14
|
+
src/integrations/checks.py
|
|
15
|
+
src/integrations/conf.py
|
|
16
|
+
src/integrations/encrypted_fields.py
|
|
17
|
+
src/integrations/exceptions.py
|
|
18
|
+
src/integrations/models.py
|
|
19
|
+
src/integrations/permissions.py
|
|
20
|
+
src/integrations/registry.py
|
|
21
|
+
src/integrations/scopes.py
|
|
22
|
+
src/integrations/urls.py
|
|
23
|
+
src/integrations/api/__init__.py
|
|
24
|
+
src/integrations/api/errors.py
|
|
25
|
+
src/integrations/api/openapi.py
|
|
26
|
+
src/integrations/api/serializers.py
|
|
27
|
+
src/integrations/api/urls.py
|
|
28
|
+
src/integrations/api/views.py
|
|
29
|
+
src/integrations/fields/__init__.py
|
|
30
|
+
src/integrations/fields/base.py
|
|
31
|
+
src/integrations/fields/encrypted.py
|
|
32
|
+
src/integrations/forms/__init__.py
|
|
33
|
+
src/integrations/forms/integrations.py
|
|
34
|
+
src/integrations/management/__init__.py
|
|
35
|
+
src/integrations/management/commands/__init__.py
|
|
36
|
+
src/integrations/management/commands/rotate_encryption_keys.py
|
|
37
|
+
src/integrations/migrations/0001_initial.py
|
|
38
|
+
src/integrations/migrations/0002_credential_config_credential_integration_and_more.py
|
|
39
|
+
src/integrations/migrations/__init__.py
|
|
40
|
+
src/integrations/services/__init__.py
|
|
41
|
+
src/integrations/services/credentials.py
|
|
42
|
+
src/integrations/templates/integrations/base.html
|
|
43
|
+
src/integrations/templates/integrations/configure_form.html
|
|
44
|
+
src/integrations/templates/integrations/confirm_delete.html
|
|
45
|
+
src/integrations/templates/integrations/detail.html
|
|
46
|
+
src/integrations/templates/integrations/list.html
|
|
47
|
+
src/integrations/views/__init__.py
|
|
48
|
+
src/integrations/views/integrations.py
|
|
49
|
+
tests/test_admin.py
|
|
50
|
+
tests/test_api_errors.py
|
|
51
|
+
tests/test_api_serializers.py
|
|
52
|
+
tests/test_api_views.py
|
|
53
|
+
tests/test_base.py
|
|
54
|
+
tests/test_capabilities.py
|
|
55
|
+
tests/test_checks.py
|
|
56
|
+
tests/test_conf.py
|
|
57
|
+
tests/test_credential_service.py
|
|
58
|
+
tests/test_encrypted_fields.py
|
|
59
|
+
tests/test_encrypted_json_field.py
|
|
60
|
+
tests/test_fields.py
|
|
61
|
+
tests/test_forms.py
|
|
62
|
+
tests/test_html_views.py
|
|
63
|
+
tests/test_http_tenant_isolation.py
|
|
64
|
+
tests/test_models.py
|
|
65
|
+
tests/test_openapi.py
|
|
66
|
+
tests/test_permissions.py
|
|
67
|
+
tests/test_registry.py
|
|
68
|
+
tests/test_rotate_encryption_keys.py
|
|
69
|
+
tests/test_scopes.py
|
|
70
|
+
tests/test_urls.py
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Django<
|
|
1
|
+
Django<7.0,>=5.2
|
|
2
2
|
cryptography<46.0.0,>=45.0.2
|
|
3
3
|
|
|
4
4
|
[dev]
|
|
@@ -6,6 +6,7 @@ black
|
|
|
6
6
|
flake8
|
|
7
7
|
flake8-black
|
|
8
8
|
mypy
|
|
9
|
+
django-stubs
|
|
9
10
|
bandit
|
|
10
11
|
isort
|
|
11
12
|
dj-database-url
|
|
@@ -17,9 +18,10 @@ psycopg2-binary
|
|
|
17
18
|
[test]
|
|
18
19
|
coverage
|
|
19
20
|
pytest
|
|
20
|
-
pytest-
|
|
21
|
+
pytest-cov
|
|
22
|
+
pytest-django>=4.12
|
|
21
23
|
dj-database-url
|
|
22
|
-
django-crispy-forms
|
|
24
|
+
django-crispy-forms>=2.4
|
|
23
25
|
django-allauth
|
|
24
26
|
django-extensions
|
|
25
27
|
psycopg2-binary
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from integrations.base import Integration, IntegrationConfig
|
|
2
|
+
from integrations.exceptions import (
|
|
3
|
+
DuplicateIntegrationError,
|
|
4
|
+
FieldValidationError,
|
|
5
|
+
IntegrationError,
|
|
6
|
+
IntegrationNotRegisteredError,
|
|
7
|
+
IntegrationValidationError,
|
|
8
|
+
)
|
|
9
|
+
from integrations.fields.base import CLEAR, UNSET
|
|
10
|
+
from integrations.registry import register
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"CLEAR",
|
|
14
|
+
"UNSET",
|
|
15
|
+
"DuplicateIntegrationError",
|
|
16
|
+
"FieldValidationError",
|
|
17
|
+
"Integration",
|
|
18
|
+
"IntegrationConfig",
|
|
19
|
+
"IntegrationError",
|
|
20
|
+
"IntegrationNotRegisteredError",
|
|
21
|
+
"IntegrationValidationError",
|
|
22
|
+
"register",
|
|
23
|
+
]
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from django.contrib import admin
|
|
2
|
+
|
|
3
|
+
from integrations import registry
|
|
4
|
+
from integrations.exceptions import IntegrationNotRegisteredError
|
|
5
|
+
from integrations.models import Credential
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CredentialAdmin(admin.ModelAdmin):
|
|
9
|
+
list_display = ("name", "integration", "site", "integration_status")
|
|
10
|
+
list_filter = ("site__domain", "integration")
|
|
11
|
+
search_fields = ("name", "site__domain", "integration")
|
|
12
|
+
# Excluded, not just read-only: a read-only field still renders its
|
|
13
|
+
# value into the DOM via Django's default widget, which is exactly
|
|
14
|
+
# the exposure to avoid. This covers both the new `secrets` field and
|
|
15
|
+
# the legacy EncryptedTextFields, which decrypt on instance access and
|
|
16
|
+
# were never previously protected here.
|
|
17
|
+
exclude = ("secrets", "public_key", "private_key")
|
|
18
|
+
readonly_fields = ("secrets_summary",)
|
|
19
|
+
|
|
20
|
+
def get_readonly_fields(self, request, obj=None):
|
|
21
|
+
fields = list(self.readonly_fields)
|
|
22
|
+
if obj is not None:
|
|
23
|
+
# Locked after creation so an operator can't silently retarget
|
|
24
|
+
# a row's config to a different integration's schema, or break
|
|
25
|
+
# the (site, integration) uniqueness invariant. Still editable
|
|
26
|
+
# at creation time - exactly as unvalidated as `attrs` always
|
|
27
|
+
# has been; this doesn't newly validate it.
|
|
28
|
+
fields.extend(["integration", "config"])
|
|
29
|
+
return fields
|
|
30
|
+
|
|
31
|
+
@admin.display(description="Status")
|
|
32
|
+
def integration_status(self, obj):
|
|
33
|
+
if not obj.integration:
|
|
34
|
+
return "—"
|
|
35
|
+
try:
|
|
36
|
+
registry.get(obj.integration)
|
|
37
|
+
except IntegrationNotRegisteredError:
|
|
38
|
+
return "Unregistered"
|
|
39
|
+
return "Registered"
|
|
40
|
+
|
|
41
|
+
@admin.display(description="Secrets")
|
|
42
|
+
def secrets_summary(self, obj):
|
|
43
|
+
parts = []
|
|
44
|
+
|
|
45
|
+
integration_cls = None
|
|
46
|
+
if obj.integration:
|
|
47
|
+
try:
|
|
48
|
+
integration_cls = registry.get(obj.integration)
|
|
49
|
+
except IntegrationNotRegisteredError:
|
|
50
|
+
integration_cls = None
|
|
51
|
+
|
|
52
|
+
secrets = obj.secrets or {}
|
|
53
|
+
if integration_cls is not None:
|
|
54
|
+
for field in integration_cls.secret_fields():
|
|
55
|
+
configured = field.name in secrets
|
|
56
|
+
parts.append(
|
|
57
|
+
f"{field.label}: {'configured' if configured else 'not set'}"
|
|
58
|
+
)
|
|
59
|
+
else:
|
|
60
|
+
parts.extend(f"{name}: configured" for name in secrets)
|
|
61
|
+
|
|
62
|
+
if obj.public_key:
|
|
63
|
+
parts.append("Legacy public_key: configured")
|
|
64
|
+
if obj.private_key:
|
|
65
|
+
parts.append("Legacy private_key: configured")
|
|
66
|
+
|
|
67
|
+
return ", ".join(parts) if parts else "No secrets stored"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
admin.site.register(Credential, CredentialAdmin)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from django.http import JsonResponse
|
|
4
|
+
|
|
5
|
+
PROBLEM_CONTENT_TYPE = "application/problem+json"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def problem_response(
|
|
9
|
+
*,
|
|
10
|
+
status: int,
|
|
11
|
+
title: str,
|
|
12
|
+
detail: str | None = None,
|
|
13
|
+
type_: str = "about:blank",
|
|
14
|
+
**extra: Any,
|
|
15
|
+
) -> JsonResponse:
|
|
16
|
+
"""
|
|
17
|
+
One RFC 9457 (Problem Details for HTTP APIs) response shape, used for
|
|
18
|
+
every error this API returns.
|
|
19
|
+
"""
|
|
20
|
+
body: dict[str, Any] = {"type": type_, "title": title, "status": status}
|
|
21
|
+
if detail:
|
|
22
|
+
body["detail"] = detail
|
|
23
|
+
body.update(extra)
|
|
24
|
+
return JsonResponse(body, status=status, content_type=PROBLEM_CONTENT_TYPE)
|