netbox-secrets 2.2.0__tar.gz → 2.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. {netbox_secrets-2.2.0/netbox_secrets.egg-info → netbox_secrets-2.2.1}/PKG-INFO +3 -2
  2. netbox_secrets-2.2.1/netbox_secrets/__init__.py +32 -0
  3. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/models/secrets.py +4 -11
  4. netbox_secrets-2.2.1/netbox_secrets/signals.py +49 -0
  5. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/tables.py +2 -1
  6. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1/netbox_secrets.egg-info}/PKG-INFO +3 -2
  7. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets.egg-info/SOURCES.txt +1 -0
  8. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/setup.py +1 -1
  9. netbox_secrets-2.2.0/netbox_secrets/__init__.py +0 -55
  10. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/LICENSE.md +0 -0
  11. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/MANIFEST.in +0 -0
  12. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/README.md +0 -0
  13. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/api/__init__.py +0 -0
  14. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/api/serializers.py +0 -0
  15. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/api/urls.py +0 -0
  16. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/api/views.py +0 -0
  17. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/constants.py +0 -0
  18. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/exceptions.py +0 -0
  19. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/filtersets.py +0 -0
  20. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/forms/__init__.py +0 -0
  21. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/forms/bulk_edit.py +0 -0
  22. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/forms/bulk_import.py +0 -0
  23. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/forms/filterset.py +0 -0
  24. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/forms/model_forms.py +0 -0
  25. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/graphql/__init__.py +0 -0
  26. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/graphql/filters.py +0 -0
  27. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/graphql/schema.py +0 -0
  28. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/graphql/types.py +0 -0
  29. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/hashers.py +0 -0
  30. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/migrations/0001_initial.py +0 -0
  31. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/migrations/0002_populate_userkeys.py +0 -0
  32. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/migrations/0003_populate_secretroles.py +0 -0
  33. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/migrations/0004_populate_secrets.py +0 -0
  34. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/migrations/0005_alter_secret_custom_field_data_and_more.py +0 -0
  35. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/migrations/0006_alter_userkey_created_alter_userkey_last_updated.py +0 -0
  36. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/migrations/0007_secret__object_repr_secret_comments_and_more.py +0 -0
  37. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/migrations/0008_userkey_custom_field_data_userkey_tags.py +0 -0
  38. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/migrations/__init__.py +0 -0
  39. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/models/__init__.py +0 -0
  40. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/navigation.py +0 -0
  41. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/querysets.py +0 -0
  42. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/static/netbox_secrets/secrets.js +0 -0
  43. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/static/netbox_secrets/secrets.js.map +0 -0
  44. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/template_content.py +0 -0
  45. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/templates/netbox_secrets/activate_keys.html +0 -0
  46. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/templates/netbox_secrets/inc/private_key_modal.html +0 -0
  47. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/templates/netbox_secrets/inc/secret_actions.html +0 -0
  48. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/templates/netbox_secrets/inc/secret_add_button.html +0 -0
  49. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/templates/netbox_secrets/inc/secrets_panel.html +0 -0
  50. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/templates/netbox_secrets/secret.html +0 -0
  51. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/templates/netbox_secrets/secret_edit.html +0 -0
  52. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/templates/netbox_secrets/secretrole.html +0 -0
  53. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/templates/netbox_secrets/userkey.html +0 -0
  54. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/templates/netbox_secrets/userkey_edit.html +0 -0
  55. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/templates/netbox_secrets/userkey_list.html +0 -0
  56. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/tests/__init__.py +0 -0
  57. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/tests/constants.py +0 -0
  58. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/tests/test_api.py +0 -0
  59. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/tests/test_filters.py +0 -0
  60. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/tests/test_form.py +0 -0
  61. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/tests/test_models.py +0 -0
  62. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/tests/test_views.py +0 -0
  63. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/urls.py +0 -0
  64. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/utils/__init__.py +0 -0
  65. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/utils/crypto.py +0 -0
  66. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/utils/hashers.py +0 -0
  67. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/utils/helpers.py +0 -0
  68. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets/views.py +0 -0
  69. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets.egg-info/dependency_links.txt +0 -0
  70. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets.egg-info/not-zip-safe +0 -0
  71. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets.egg-info/requires.txt +0 -0
  72. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/netbox_secrets.egg-info/top_level.txt +0 -0
  73. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/pyproject.toml +0 -0
  74. {netbox_secrets-2.2.0 → netbox_secrets-2.2.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: netbox-secrets
3
- Version: 2.2.0
3
+ Version: 2.2.1
4
4
  Summary: Enhance your secret management with encrypted storage and flexible, user-friendly features.
5
5
  Home-page: https://github.com/Onemind-Services-LLC/netbox-secrets/
6
6
  Author: Abhimanyu Saharan
@@ -22,6 +22,7 @@ Dynamic: description
22
22
  Dynamic: description-content-type
23
23
  Dynamic: home-page
24
24
  Dynamic: license
25
+ Dynamic: license-file
25
26
  Dynamic: maintainer
26
27
  Dynamic: maintainer-email
27
28
  Dynamic: requires-dist
@@ -0,0 +1,32 @@
1
+ from importlib.metadata import metadata
2
+
3
+ from netbox.plugins import PluginConfig
4
+
5
+ metadata = metadata('netbox_secrets')
6
+
7
+
8
+ class NetBoxSecrets(PluginConfig):
9
+ name = metadata.get('Name').replace('-', '_')
10
+ verbose_name = metadata.get('Name')
11
+ description = metadata.get('Summary')
12
+ version = metadata.get('Version')
13
+ author = metadata.get('Author')
14
+ author_email = metadata.get('Author-email')
15
+ base_url = 'secrets'
16
+ min_version = '4.2.0'
17
+ max_version = '4.2.99'
18
+ required_settings = []
19
+ default_settings = {
20
+ 'apps': ['dcim.device', 'virtualization.virtualmachine'],
21
+ 'display_default': 'left_page',
22
+ 'display_setting': {},
23
+ 'enable_contacts': False,
24
+ 'public_key_size': 2048,
25
+ }
26
+
27
+ def ready(self):
28
+ super().ready()
29
+ from . import signals
30
+
31
+
32
+ config = NetBoxSecrets
@@ -9,6 +9,7 @@ from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelatio
9
9
  from django.contrib.contenttypes.models import ContentType
10
10
  from django.core.exceptions import ValidationError
11
11
  from django.db import models
12
+ from django.db.models import ProtectedError
12
13
  from django.urls import reverse
13
14
  from django.utils.encoding import force_bytes
14
15
 
@@ -116,12 +117,13 @@ class UserKey(NetBoxModel):
116
117
  # If Secrets exist and this is the last active UserKey, prevent its deletion. Deleting the last UserKey will
117
118
  # result in the master key being destroyed and rendering all Secrets inaccessible.
118
119
  if Secret.objects.count() and [uk.pk for uk in UserKey.objects.active()] == [self.pk]:
119
- raise Exception(
120
+ raise ProtectedError(
120
121
  "Cannot delete the last active UserKey when Secrets exist! This would render all secrets "
121
122
  "inaccessible.",
123
+ [secret for secret in Secret.objects.all()],
122
124
  )
123
125
 
124
- super().delete(*args, **kwargs)
126
+ return super().delete(*args, **kwargs)
125
127
 
126
128
  def to_objectchange(self, action):
127
129
  objectchange = super().to_objectchange(action)
@@ -402,12 +404,3 @@ class Secret(PrimaryModel, ContactsMixin):
402
404
  @property
403
405
  def enable_contacts(self):
404
406
  return plugin_settings.get('enable_contacts', False)
405
-
406
-
407
- if plugin_settings.get('enable_contacts', False):
408
- GenericRelation(
409
- to='tenancy.ContactAssignment',
410
- content_type_field='object_type',
411
- object_id_field='object_id',
412
- related_query_name='secret',
413
- ).contribute_to_class(Secret, 'contacts')
@@ -0,0 +1,49 @@
1
+ import sys
2
+ from django.conf import settings
3
+ from django.contrib.contenttypes.fields import GenericRelation
4
+ from django.contrib.contenttypes.models import ContentType
5
+ from django.db import ProgrammingError
6
+ from django.db.backends.postgresql.base import DatabaseWrapper
7
+ from django.db.backends.signals import connection_created
8
+ from django.dispatch import receiver
9
+
10
+
11
+ @receiver(connection_created, sender=DatabaseWrapper)
12
+ def configure_generic_relations(sender, **kwargs):
13
+ if 'test' in sys.argv:
14
+ # Skip this signal during tests to avoid issues with test database destruction
15
+ return
16
+
17
+ from .constants import SECRET_ASSIGNABLE_MODELS
18
+ from .models import Secret
19
+
20
+ plugin_settings = settings.PLUGINS_CONFIG.get('netbox_secrets', {})
21
+
22
+ try:
23
+ for content_type in ContentType.objects.filter(SECRET_ASSIGNABLE_MODELS):
24
+ model_class = content_type.model_class()
25
+ if model_class is None:
26
+ continue
27
+ if not hasattr(model_class, 'secrets'):
28
+ GenericRelation(
29
+ to='netbox_secrets.Secret',
30
+ content_type_field='assigned_object_type',
31
+ object_id_field='assigned_object_id',
32
+ related_query_name=str(content_type.model),
33
+ ).contribute_to_class(
34
+ model_class,
35
+ 'secrets',
36
+ )
37
+
38
+ if plugin_settings.get('enable_contacts', False):
39
+ if not hasattr(Secret, 'contacts'):
40
+ GenericRelation(
41
+ to='tenancy.ContactAssignment',
42
+ content_type_field='object_type',
43
+ object_id_field='object_id',
44
+ related_query_name='secret',
45
+ ).contribute_to_class(Secret, 'contacts')
46
+
47
+ except ProgrammingError:
48
+ # DB may still not be ready during very early migrations
49
+ pass
@@ -82,9 +82,10 @@ class UserKeyTable(NetBoxTable):
82
82
  user = tables.Column(linkify=True)
83
83
  is_active = columns.BooleanColumn(
84
84
  verbose_name=_('Is Active'),
85
+ orderable=False,
85
86
  )
86
87
  tags = columns.TagColumn(url_name='plugins:netbox_secrets:userkey_list')
87
- actions = columns.ActionsColumn(actions=())
88
+ actions = columns.ActionsColumn(actions=('delete',))
88
89
 
89
90
  class Meta(NetBoxTable.Meta):
90
91
  model = UserKey
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: netbox-secrets
3
- Version: 2.2.0
3
+ Version: 2.2.1
4
4
  Summary: Enhance your secret management with encrypted storage and flexible, user-friendly features.
5
5
  Home-page: https://github.com/Onemind-Services-LLC/netbox-secrets/
6
6
  Author: Abhimanyu Saharan
@@ -22,6 +22,7 @@ Dynamic: description
22
22
  Dynamic: description-content-type
23
23
  Dynamic: home-page
24
24
  Dynamic: license
25
+ Dynamic: license-file
25
26
  Dynamic: maintainer
26
27
  Dynamic: maintainer-email
27
28
  Dynamic: requires-dist
@@ -10,6 +10,7 @@ netbox_secrets/filtersets.py
10
10
  netbox_secrets/hashers.py
11
11
  netbox_secrets/navigation.py
12
12
  netbox_secrets/querysets.py
13
+ netbox_secrets/signals.py
13
14
  netbox_secrets/tables.py
14
15
  netbox_secrets/template_content.py
15
16
  netbox_secrets/urls.py
@@ -11,7 +11,7 @@ with open(readme) as fh:
11
11
 
12
12
  setup(
13
13
  name='netbox-secrets',
14
- version='2.2.0',
14
+ version='2.2.1',
15
15
  description=description,
16
16
  long_description=long_description,
17
17
  long_description_content_type="text/markdown",
@@ -1,55 +0,0 @@
1
- from importlib.metadata import metadata
2
-
3
- from django.db.utils import OperationalError, ProgrammingError
4
-
5
- from netbox.plugins import PluginConfig
6
-
7
- metadata = metadata('netbox_secrets')
8
-
9
-
10
- def configure_generic_relations():
11
- from django.contrib.contenttypes.fields import GenericRelation
12
- from django.contrib.contenttypes.models import ContentType
13
-
14
- from .constants import SECRET_ASSIGNABLE_MODELS
15
-
16
- try:
17
- for content_type in ContentType.objects.filter(SECRET_ASSIGNABLE_MODELS):
18
- GenericRelation(
19
- to='netbox_secrets.Secret',
20
- content_type_field='assigned_object_type',
21
- object_id_field='assigned_object_id',
22
- related_query_name=str(content_type.model),
23
- ).contribute_to_class(
24
- content_type.model_class(),
25
- 'secrets',
26
- )
27
- except (OperationalError, ProgrammingError):
28
- pass
29
-
30
-
31
- class NetBoxSecrets(PluginConfig):
32
- name = metadata.get('Name').replace('-', '_')
33
- verbose_name = metadata.get('Name')
34
- description = metadata.get('Summary')
35
- version = metadata.get('Version')
36
- author = metadata.get('Author')
37
- author_email = metadata.get('Author-email')
38
- base_url = 'secrets'
39
- min_version = '4.2.0'
40
- max_version = '4.2.99'
41
- required_settings = []
42
- default_settings = {
43
- 'apps': ['dcim.device', 'virtualization.virtualmachine'],
44
- 'display_default': 'left_page',
45
- 'display_setting': {},
46
- 'enable_contacts': False,
47
- 'public_key_size': 2048,
48
- }
49
-
50
- def ready(self):
51
- super().ready()
52
- configure_generic_relations()
53
-
54
-
55
- config = NetBoxSecrets
File without changes
File without changes