netbox-secrets 2.2.1__tar.gz → 2.3.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.
- {netbox_secrets-2.2.1/netbox_secrets.egg-info → netbox_secrets-2.3.0}/PKG-INFO +2 -5
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/README.md +1 -4
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/__init__.py +2 -3
- netbox_secrets-2.3.0/netbox_secrets/filtersets.py +112 -0
- netbox_secrets-2.3.0/netbox_secrets/graphql/filters.py +38 -0
- netbox_secrets-2.3.0/netbox_secrets/graphql/schema.py +15 -0
- netbox_secrets-2.3.0/netbox_secrets/graphql/types.py +33 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/models/secrets.py +0 -6
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/signals.py +0 -12
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/template_content.py +13 -11
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/tests/test_api.py +2 -14
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/views.py +3 -14
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0/netbox_secrets.egg-info}/PKG-INFO +2 -5
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/pyproject.toml +1 -1
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/setup.py +1 -1
- netbox_secrets-2.2.1/netbox_secrets/filtersets.py +0 -162
- netbox_secrets-2.2.1/netbox_secrets/graphql/filters.py +0 -22
- netbox_secrets-2.2.1/netbox_secrets/graphql/schema.py +0 -15
- netbox_secrets-2.2.1/netbox_secrets/graphql/types.py +0 -27
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/LICENSE.md +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/MANIFEST.in +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/api/__init__.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/api/serializers.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/api/urls.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/api/views.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/constants.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/exceptions.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/forms/__init__.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/forms/bulk_edit.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/forms/bulk_import.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/forms/filterset.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/forms/model_forms.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/graphql/__init__.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/hashers.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/migrations/0001_initial.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/migrations/0002_populate_userkeys.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/migrations/0003_populate_secretroles.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/migrations/0004_populate_secrets.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/migrations/0005_alter_secret_custom_field_data_and_more.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/migrations/0006_alter_userkey_created_alter_userkey_last_updated.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/migrations/0007_secret__object_repr_secret_comments_and_more.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/migrations/0008_userkey_custom_field_data_userkey_tags.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/migrations/__init__.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/models/__init__.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/navigation.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/querysets.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/static/netbox_secrets/secrets.js +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/static/netbox_secrets/secrets.js.map +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/tables.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/templates/netbox_secrets/activate_keys.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/templates/netbox_secrets/inc/private_key_modal.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/templates/netbox_secrets/inc/secret_actions.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/templates/netbox_secrets/inc/secret_add_button.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/templates/netbox_secrets/inc/secrets_panel.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/templates/netbox_secrets/secret.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/templates/netbox_secrets/secret_edit.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/templates/netbox_secrets/secretrole.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/templates/netbox_secrets/userkey.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/templates/netbox_secrets/userkey_edit.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/templates/netbox_secrets/userkey_list.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/tests/__init__.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/tests/constants.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/tests/test_filters.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/tests/test_form.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/tests/test_models.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/tests/test_views.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/urls.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/utils/__init__.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/utils/crypto.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/utils/hashers.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/utils/helpers.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets.egg-info/SOURCES.txt +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets.egg-info/dependency_links.txt +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets.egg-info/not-zip-safe +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets.egg-info/requires.txt +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets.egg-info/top_level.txt +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: netbox-secrets
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
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
|
|
@@ -56,6 +56,7 @@ and stability.
|
|
|
56
56
|
| 4.0.x | 2.0.x |
|
|
57
57
|
| 4.1.x | 2.1.x |
|
|
58
58
|
| 4.2.x | 2.2.x |
|
|
59
|
+
| 4.3.x | 2.3.x |
|
|
59
60
|
|
|
60
61
|
# Installation
|
|
61
62
|
|
|
@@ -89,10 +90,6 @@ The following options are available in the configuration file:
|
|
|
89
90
|
- __Default__: `{}`
|
|
90
91
|
- __Options__: `{'app.model': 'display_default'}`
|
|
91
92
|
- __Example__: `{'dcim.device': 'full_width_page', 'virtualization.virtualmachine': 'right_page'}`
|
|
92
|
-
- `enable_contacts`
|
|
93
|
-
- __Type__: `Boolean`
|
|
94
|
-
- __Description__: Enable contacts for secret
|
|
95
|
-
- __Default__: `False`
|
|
96
93
|
- `public_key_size`
|
|
97
94
|
- __Type__: `Integer`
|
|
98
95
|
- __Description__: Size of the public key
|
|
@@ -25,6 +25,7 @@ and stability.
|
|
|
25
25
|
| 4.0.x | 2.0.x |
|
|
26
26
|
| 4.1.x | 2.1.x |
|
|
27
27
|
| 4.2.x | 2.2.x |
|
|
28
|
+
| 4.3.x | 2.3.x |
|
|
28
29
|
|
|
29
30
|
# Installation
|
|
30
31
|
|
|
@@ -58,10 +59,6 @@ The following options are available in the configuration file:
|
|
|
58
59
|
- __Default__: `{}`
|
|
59
60
|
- __Options__: `{'app.model': 'display_default'}`
|
|
60
61
|
- __Example__: `{'dcim.device': 'full_width_page', 'virtualization.virtualmachine': 'right_page'}`
|
|
61
|
-
- `enable_contacts`
|
|
62
|
-
- __Type__: `Boolean`
|
|
63
|
-
- __Description__: Enable contacts for secret
|
|
64
|
-
- __Default__: `False`
|
|
65
62
|
- `public_key_size`
|
|
66
63
|
- __Type__: `Integer`
|
|
67
64
|
- __Description__: Size of the public key
|
|
@@ -13,14 +13,13 @@ class NetBoxSecrets(PluginConfig):
|
|
|
13
13
|
author = metadata.get('Author')
|
|
14
14
|
author_email = metadata.get('Author-email')
|
|
15
15
|
base_url = 'secrets'
|
|
16
|
-
min_version = '4.
|
|
17
|
-
max_version = '4.
|
|
16
|
+
min_version = '4.3.0'
|
|
17
|
+
max_version = '4.3.99'
|
|
18
18
|
required_settings = []
|
|
19
19
|
default_settings = {
|
|
20
20
|
'apps': ['dcim.device', 'virtualization.virtualmachine'],
|
|
21
21
|
'display_default': 'left_page',
|
|
22
22
|
'display_setting': {},
|
|
23
|
-
'enable_contacts': False,
|
|
24
23
|
'public_key_size': 2048,
|
|
25
24
|
}
|
|
26
25
|
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import django_filters
|
|
2
|
+
from django.contrib.auth import get_user_model
|
|
3
|
+
from django.contrib.contenttypes.models import ContentType
|
|
4
|
+
from django.db.models import Q
|
|
5
|
+
from django.utils.translation import gettext as _
|
|
6
|
+
|
|
7
|
+
from netbox.filtersets import NetBoxModelFilterSet
|
|
8
|
+
from tenancy.models import Contact
|
|
9
|
+
from utilities.filters import ContentTypeFilter, MultiValueCharFilter
|
|
10
|
+
from .constants import SECRET_ASSIGNABLE_MODELS
|
|
11
|
+
from .models import Secret, SecretRole, UserKey
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
'SecretFilterSet',
|
|
15
|
+
'SecretRoleFilterSet',
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class UserKeyFilterSet(NetBoxModelFilterSet):
|
|
20
|
+
user_id = django_filters.ModelMultipleChoiceFilter(
|
|
21
|
+
queryset=get_user_model().objects.all(),
|
|
22
|
+
label=_('User (ID)'),
|
|
23
|
+
)
|
|
24
|
+
user = django_filters.ModelMultipleChoiceFilter(
|
|
25
|
+
field_name='user__username',
|
|
26
|
+
queryset=get_user_model().objects.all(),
|
|
27
|
+
to_field_name='username',
|
|
28
|
+
label=_('User (name)'),
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
class Meta:
|
|
32
|
+
model = UserKey
|
|
33
|
+
fields = [
|
|
34
|
+
'id',
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
def search(self, queryset, name, value):
|
|
38
|
+
if not value.strip():
|
|
39
|
+
return queryset
|
|
40
|
+
return queryset.filter(Q(user__username__icontains=value))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class SecretRoleFilterSet(NetBoxModelFilterSet):
|
|
44
|
+
name = MultiValueCharFilter(lookup_expr='iexact')
|
|
45
|
+
|
|
46
|
+
class Meta:
|
|
47
|
+
model = SecretRole
|
|
48
|
+
fields = ['id', 'name', 'slug', 'description', 'comments']
|
|
49
|
+
|
|
50
|
+
def search(self, queryset, name, value):
|
|
51
|
+
if not value.strip():
|
|
52
|
+
return queryset
|
|
53
|
+
return queryset.filter(
|
|
54
|
+
Q(name__icontains=value)
|
|
55
|
+
| Q(slug__icontains=value)
|
|
56
|
+
| Q(description__icontains=value)
|
|
57
|
+
| Q(comments__icontains=value),
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class SecretFilterSet(NetBoxModelFilterSet):
|
|
62
|
+
name = MultiValueCharFilter(lookup_expr='iexact')
|
|
63
|
+
|
|
64
|
+
role_id = django_filters.ModelMultipleChoiceFilter(
|
|
65
|
+
queryset=SecretRole.objects.all(),
|
|
66
|
+
label='Role (ID)',
|
|
67
|
+
)
|
|
68
|
+
role = django_filters.ModelMultipleChoiceFilter(
|
|
69
|
+
field_name='role__slug',
|
|
70
|
+
queryset=SecretRole.objects.all(),
|
|
71
|
+
to_field_name='slug',
|
|
72
|
+
label='Role (slug)',
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
assigned_object_type = ContentTypeFilter()
|
|
76
|
+
|
|
77
|
+
assigned_object_type_id = django_filters.ModelMultipleChoiceFilter(
|
|
78
|
+
queryset=ContentType.objects.filter(SECRET_ASSIGNABLE_MODELS),
|
|
79
|
+
label='Object type (ID)',
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
contact = django_filters.ModelMultipleChoiceFilter(
|
|
83
|
+
field_name='contacts__contact',
|
|
84
|
+
queryset=Contact.objects.all(),
|
|
85
|
+
label=_('Contact'),
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
class Meta:
|
|
89
|
+
model = Secret
|
|
90
|
+
fields = [
|
|
91
|
+
'id',
|
|
92
|
+
'assigned_object_type',
|
|
93
|
+
'assigned_object_type_id',
|
|
94
|
+
'assigned_object_id',
|
|
95
|
+
'role_id',
|
|
96
|
+
'role',
|
|
97
|
+
'name',
|
|
98
|
+
'contact',
|
|
99
|
+
'_object_repr',
|
|
100
|
+
'description',
|
|
101
|
+
'comments',
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
def search(self, queryset, name, value):
|
|
105
|
+
if not value.strip():
|
|
106
|
+
return queryset
|
|
107
|
+
return queryset.filter(
|
|
108
|
+
Q(name__icontains=value)
|
|
109
|
+
| Q(_object_repr__icontains=value)
|
|
110
|
+
| Q(description__icontains=value)
|
|
111
|
+
| Q(comments__icontains=value),
|
|
112
|
+
)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from typing import Annotated, TYPE_CHECKING
|
|
2
|
+
|
|
3
|
+
import strawberry
|
|
4
|
+
import strawberry_django
|
|
5
|
+
from strawberry.scalars import ID
|
|
6
|
+
from strawberry_django import FilterLookup
|
|
7
|
+
|
|
8
|
+
from netbox.graphql.filter_mixins import (
|
|
9
|
+
OrganizationalModelFilterMixin,
|
|
10
|
+
PrimaryModelFilterMixin,
|
|
11
|
+
)
|
|
12
|
+
from ..models import *
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from core.graphql.filters import ContentTypeFilter
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
'SecretFilter',
|
|
19
|
+
'SecretRoleFilter',
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@strawberry_django.filter_type(SecretRole, lookups=True)
|
|
24
|
+
class SecretRoleFilter(OrganizationalModelFilterMixin):
|
|
25
|
+
pass
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@strawberry_django.filter_type(Secret, lookups=True)
|
|
29
|
+
class SecretFilter(PrimaryModelFilterMixin):
|
|
30
|
+
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
|
31
|
+
role: Annotated[
|
|
32
|
+
'SecretRoleFilter', strawberry.lazy('netbox_secrets.graphql.filters')
|
|
33
|
+
] | None = strawberry_django.filter_field()
|
|
34
|
+
role_id: ID | None = strawberry_django.filter_field()
|
|
35
|
+
assigned_object_type: Annotated[
|
|
36
|
+
'ContentTypeFilter', strawberry.lazy('core.graphql.filters')
|
|
37
|
+
] | None = strawberry_django.filter_field()
|
|
38
|
+
assigned_object_id: ID | None = strawberry_django.filter_field()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
import strawberry
|
|
4
|
+
import strawberry_django
|
|
5
|
+
|
|
6
|
+
from .types import *
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@strawberry.type(name='Query')
|
|
10
|
+
class NetboxSecretsQuery:
|
|
11
|
+
secret_role: SecretRoleType = strawberry_django.field()
|
|
12
|
+
secret_role_list: List[SecretRoleType] = strawberry_django.field()
|
|
13
|
+
|
|
14
|
+
secret: SecretType = strawberry_django.field()
|
|
15
|
+
secret_list: List[SecretType] = strawberry_django.field()
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from typing import Annotated, TYPE_CHECKING
|
|
2
|
+
|
|
3
|
+
import strawberry
|
|
4
|
+
import strawberry_django
|
|
5
|
+
|
|
6
|
+
from netbox.graphql.types import NetBoxObjectType, OrganizationalObjectType
|
|
7
|
+
from netbox_secrets.models import Secret, SecretRole
|
|
8
|
+
from .filters import *
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from netbox.graphql.types import ContentTypeType
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
'SecretRoleType',
|
|
15
|
+
'SecretType',
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@strawberry_django.type(SecretRole, fields="__all__", filters=SecretRoleFilter, pagination=True)
|
|
20
|
+
class SecretRoleType(OrganizationalObjectType):
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@strawberry_django.type(Secret, exclude=['ciphertext', 'hash', 'plaintext'], filters=SecretFilter, pagination=True)
|
|
25
|
+
class SecretType(NetBoxObjectType):
|
|
26
|
+
role: Annotated['SecretRoleType', strawberry.lazy('netbox_secrets.graphql.types')]
|
|
27
|
+
name: str
|
|
28
|
+
description: str
|
|
29
|
+
assigned_object_type: Annotated["ContentTypeType", strawberry.lazy('netbox.graphql.types')] | None
|
|
30
|
+
|
|
31
|
+
@strawberry_django.field
|
|
32
|
+
def role(self) -> Annotated["SecretRoleType", strawberry.lazy('netbox_secrets.graphql.types')] | None:
|
|
33
|
+
return self.role
|
|
@@ -296,8 +296,6 @@ class Secret(PrimaryModel, ContactsMixin):
|
|
|
296
296
|
|
|
297
297
|
clone_fields = ('role', 'assigned_object_id', 'assigned_object_type', 'tags')
|
|
298
298
|
|
|
299
|
-
prerequisite_models = ('netbox_secrets.SecretRole', *plugin_settings.get('apps'))
|
|
300
|
-
|
|
301
299
|
class Meta:
|
|
302
300
|
ordering = ('role', 'name', 'pk')
|
|
303
301
|
unique_together = ('assigned_object_type', 'assigned_object_id', 'role', 'name')
|
|
@@ -400,7 +398,3 @@ class Secret(PrimaryModel, ContactsMixin):
|
|
|
400
398
|
if not self.hash:
|
|
401
399
|
raise Exception("Hash has not been generated for this secret.")
|
|
402
400
|
return check_password(plaintext, self.hash, preferred=SecretValidationHasher())
|
|
403
|
-
|
|
404
|
-
@property
|
|
405
|
-
def enable_contacts(self):
|
|
406
|
-
return plugin_settings.get('enable_contacts', False)
|
|
@@ -15,9 +15,6 @@ def configure_generic_relations(sender, **kwargs):
|
|
|
15
15
|
return
|
|
16
16
|
|
|
17
17
|
from .constants import SECRET_ASSIGNABLE_MODELS
|
|
18
|
-
from .models import Secret
|
|
19
|
-
|
|
20
|
-
plugin_settings = settings.PLUGINS_CONFIG.get('netbox_secrets', {})
|
|
21
18
|
|
|
22
19
|
try:
|
|
23
20
|
for content_type in ContentType.objects.filter(SECRET_ASSIGNABLE_MODELS):
|
|
@@ -35,15 +32,6 @@ def configure_generic_relations(sender, **kwargs):
|
|
|
35
32
|
'secrets',
|
|
36
33
|
)
|
|
37
34
|
|
|
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
35
|
except ProgrammingError:
|
|
48
36
|
# DB may still not be ready during very early migrations
|
|
49
37
|
pass
|
|
@@ -19,15 +19,17 @@ template_extensions = []
|
|
|
19
19
|
|
|
20
20
|
def secrets_panel(self):
|
|
21
21
|
obj = self.context['object']
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
for model in self.models:
|
|
23
|
+
app_label, model = model.split('.')
|
|
24
|
+
assigned_object_type = ContentType.objects.get(app_label=app_label, model=model).id
|
|
25
|
+
|
|
26
|
+
return self.render(
|
|
27
|
+
'netbox_secrets/inc/secrets_panel.html',
|
|
28
|
+
extra_context={
|
|
29
|
+
'secrets': Secret.objects.filter(assigned_object_type=assigned_object_type, assigned_object_id=obj.id),
|
|
30
|
+
},
|
|
31
|
+
)
|
|
32
|
+
return None
|
|
31
33
|
|
|
32
34
|
|
|
33
35
|
def get_display_on(app_model):
|
|
@@ -67,7 +69,7 @@ def tab_view(_model):
|
|
|
67
69
|
|
|
68
70
|
def secret_add_button(_app_model):
|
|
69
71
|
class Button(PluginTemplateExtension):
|
|
70
|
-
|
|
72
|
+
models = [_app_model]
|
|
71
73
|
|
|
72
74
|
def buttons(self):
|
|
73
75
|
return self.render(
|
|
@@ -92,7 +94,7 @@ try:
|
|
|
92
94
|
dynamic_klass = type(
|
|
93
95
|
klass_name,
|
|
94
96
|
(PluginTemplateExtension,),
|
|
95
|
-
{'
|
|
97
|
+
{'models': [app_model], get_display_on(app_model): secrets_panel},
|
|
96
98
|
)
|
|
97
99
|
template_extensions.append(dynamic_klass)
|
|
98
100
|
except OperationalError as e:
|
|
@@ -31,13 +31,7 @@ class AppTest(APITestCase):
|
|
|
31
31
|
self.assertEqual(response.status_code, 200)
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
class SecretRoleTest(
|
|
35
|
-
APIViewTestCases.GetObjectViewTestCase,
|
|
36
|
-
APIViewTestCases.ListObjectsViewTestCase,
|
|
37
|
-
APIViewTestCases.CreateObjectViewTestCase,
|
|
38
|
-
APIViewTestCases.UpdateObjectViewTestCase,
|
|
39
|
-
APIViewTestCases.DeleteObjectViewTestCase,
|
|
40
|
-
):
|
|
34
|
+
class SecretRoleTest(APIViewTestCases.APIViewTestCase):
|
|
41
35
|
model = SecretRole
|
|
42
36
|
view_namespace = 'plugins-api:netbox_secrets'
|
|
43
37
|
brief_fields = ['display', 'id', 'name', 'secret_count', 'slug', 'url']
|
|
@@ -67,13 +61,7 @@ class SecretRoleTest(
|
|
|
67
61
|
]
|
|
68
62
|
|
|
69
63
|
|
|
70
|
-
class SecretTest(
|
|
71
|
-
APIViewTestCases.GetObjectViewTestCase,
|
|
72
|
-
APIViewTestCases.ListObjectsViewTestCase,
|
|
73
|
-
APIViewTestCases.CreateObjectViewTestCase,
|
|
74
|
-
APIViewTestCases.UpdateObjectViewTestCase,
|
|
75
|
-
APIViewTestCases.DeleteObjectViewTestCase,
|
|
76
|
-
):
|
|
64
|
+
class SecretTest(APIViewTestCases.APIViewTestCase):
|
|
77
65
|
model = Secret
|
|
78
66
|
view_namespace = 'plugins-api:netbox_secrets'
|
|
79
67
|
brief_fields = ['display', 'id', 'name', 'url']
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
-
from django.conf import settings
|
|
4
3
|
from django.contrib import messages
|
|
5
4
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
6
5
|
from django.contrib.contenttypes.models import ContentType
|
|
@@ -11,20 +10,17 @@ from django.utils.html import escape
|
|
|
11
10
|
from django.utils.safestring import mark_safe
|
|
12
11
|
from django.utils.translation import gettext as _
|
|
13
12
|
from django.views.generic.base import View
|
|
14
|
-
from netbox_secrets.models import SecretRole, UserKey
|
|
15
13
|
|
|
16
14
|
from core.signals import clear_events
|
|
17
15
|
from netbox.views import generic
|
|
18
|
-
from
|
|
16
|
+
from netbox_secrets.models import UserKey
|
|
19
17
|
from utilities.exceptions import AbortRequest, PermissionsViolation
|
|
20
18
|
from utilities.forms import restrict_form_fields
|
|
21
19
|
from utilities.query import count_related
|
|
22
20
|
from utilities.querydict import prepare_cloned_fields
|
|
23
|
-
from utilities.views import GetReturnURLMixin, ViewTab, register_model_view
|
|
21
|
+
from utilities.views import GetRelatedModelsMixin, GetReturnURLMixin, ViewTab, register_model_view
|
|
24
22
|
from . import constants, exceptions, filtersets, forms, models, tables, utils
|
|
25
23
|
|
|
26
|
-
plugin_settings = settings.PLUGINS_CONFIG.get('netbox_secrets')
|
|
27
|
-
|
|
28
24
|
|
|
29
25
|
#
|
|
30
26
|
# Secret roles
|
|
@@ -119,7 +115,7 @@ class SecretListView(generic.ObjectListView):
|
|
|
119
115
|
|
|
120
116
|
|
|
121
117
|
@register_model_view(models.Secret)
|
|
122
|
-
class SecretView(generic.ObjectView):
|
|
118
|
+
class SecretView(GetRelatedModelsMixin, generic.ObjectView):
|
|
123
119
|
queryset = models.Secret.objects.prefetch_related('role', 'tags')
|
|
124
120
|
|
|
125
121
|
|
|
@@ -289,13 +285,6 @@ class SecretBulkDeleteView(generic.BulkDeleteView):
|
|
|
289
285
|
table = tables.SecretTable
|
|
290
286
|
|
|
291
287
|
|
|
292
|
-
if plugin_settings.get('enable_contacts'):
|
|
293
|
-
|
|
294
|
-
@register_model_view(models.Secret, 'contacts')
|
|
295
|
-
class SecretContactsView(ObjectContactsView):
|
|
296
|
-
queryset = models.Secret.objects.prefetch_related('role', 'tags')
|
|
297
|
-
|
|
298
|
-
|
|
299
288
|
#
|
|
300
289
|
# User Key
|
|
301
290
|
#
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: netbox-secrets
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
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
|
|
@@ -56,6 +56,7 @@ and stability.
|
|
|
56
56
|
| 4.0.x | 2.0.x |
|
|
57
57
|
| 4.1.x | 2.1.x |
|
|
58
58
|
| 4.2.x | 2.2.x |
|
|
59
|
+
| 4.3.x | 2.3.x |
|
|
59
60
|
|
|
60
61
|
# Installation
|
|
61
62
|
|
|
@@ -89,10 +90,6 @@ The following options are available in the configuration file:
|
|
|
89
90
|
- __Default__: `{}`
|
|
90
91
|
- __Options__: `{'app.model': 'display_default'}`
|
|
91
92
|
- __Example__: `{'dcim.device': 'full_width_page', 'virtualization.virtualmachine': 'right_page'}`
|
|
92
|
-
- `enable_contacts`
|
|
93
|
-
- __Type__: `Boolean`
|
|
94
|
-
- __Description__: Enable contacts for secret
|
|
95
|
-
- __Default__: `False`
|
|
96
93
|
- `public_key_size`
|
|
97
94
|
- __Type__: `Integer`
|
|
98
95
|
- __Description__: Size of the public key
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import django_filters
|
|
2
|
-
from django.conf import settings
|
|
3
|
-
from django.contrib.auth import get_user_model
|
|
4
|
-
from django.contrib.contenttypes.models import ContentType
|
|
5
|
-
from django.db.models import Q
|
|
6
|
-
from django.utils.translation import gettext as _
|
|
7
|
-
|
|
8
|
-
from netbox.filtersets import NetBoxModelFilterSet
|
|
9
|
-
from tenancy.models import Contact
|
|
10
|
-
from utilities.filters import ContentTypeFilter, MultiValueCharFilter
|
|
11
|
-
from .constants import SECRET_ASSIGNABLE_MODELS
|
|
12
|
-
from .models import Secret, SecretRole, UserKey
|
|
13
|
-
|
|
14
|
-
__all__ = [
|
|
15
|
-
'SecretFilterSet',
|
|
16
|
-
'SecretRoleFilterSet',
|
|
17
|
-
]
|
|
18
|
-
|
|
19
|
-
plugin_settings = settings.PLUGINS_CONFIG['netbox_secrets']
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class UserKeyFilterSet(NetBoxModelFilterSet):
|
|
23
|
-
user_id = django_filters.ModelMultipleChoiceFilter(
|
|
24
|
-
queryset=get_user_model().objects.all(),
|
|
25
|
-
label=_('User (ID)'),
|
|
26
|
-
)
|
|
27
|
-
user = django_filters.ModelMultipleChoiceFilter(
|
|
28
|
-
field_name='user__username',
|
|
29
|
-
queryset=get_user_model().objects.all(),
|
|
30
|
-
to_field_name='username',
|
|
31
|
-
label=_('User (name)'),
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
class Meta:
|
|
35
|
-
model = UserKey
|
|
36
|
-
fields = [
|
|
37
|
-
'id',
|
|
38
|
-
]
|
|
39
|
-
|
|
40
|
-
def search(self, queryset, name, value):
|
|
41
|
-
if not value.strip():
|
|
42
|
-
return queryset
|
|
43
|
-
return queryset.filter(Q(user__username__icontains=value))
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
class SecretRoleFilterSet(NetBoxModelFilterSet):
|
|
47
|
-
name = MultiValueCharFilter(lookup_expr='iexact')
|
|
48
|
-
|
|
49
|
-
class Meta:
|
|
50
|
-
model = SecretRole
|
|
51
|
-
fields = ['id', 'name', 'slug', 'description', 'comments']
|
|
52
|
-
|
|
53
|
-
def search(self, queryset, name, value):
|
|
54
|
-
if not value.strip():
|
|
55
|
-
return queryset
|
|
56
|
-
return queryset.filter(
|
|
57
|
-
Q(name__icontains=value)
|
|
58
|
-
| Q(slug__icontains=value)
|
|
59
|
-
| Q(description__icontains=value)
|
|
60
|
-
| Q(comments__icontains=value),
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if plugin_settings.get('enable_contacts', False):
|
|
65
|
-
|
|
66
|
-
class SecretFilterSet(NetBoxModelFilterSet):
|
|
67
|
-
role_id = django_filters.ModelMultipleChoiceFilter(
|
|
68
|
-
queryset=SecretRole.objects.all(),
|
|
69
|
-
label='Role (ID)',
|
|
70
|
-
)
|
|
71
|
-
role = django_filters.ModelMultipleChoiceFilter(
|
|
72
|
-
field_name='role__slug',
|
|
73
|
-
queryset=SecretRole.objects.all(),
|
|
74
|
-
to_field_name='slug',
|
|
75
|
-
label='Role (slug)',
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
assigned_object_type = ContentTypeFilter()
|
|
79
|
-
|
|
80
|
-
assigned_object_type_id = django_filters.ModelMultipleChoiceFilter(
|
|
81
|
-
queryset=ContentType.objects.filter(SECRET_ASSIGNABLE_MODELS),
|
|
82
|
-
label='Object type (ID)',
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
contact = django_filters.ModelMultipleChoiceFilter(
|
|
86
|
-
field_name='contacts__contact',
|
|
87
|
-
queryset=Contact.objects.all(),
|
|
88
|
-
label=_('Contact'),
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
class Meta:
|
|
92
|
-
model = Secret
|
|
93
|
-
fields = [
|
|
94
|
-
'id',
|
|
95
|
-
'assigned_object_type',
|
|
96
|
-
'assigned_object_type_id',
|
|
97
|
-
'assigned_object_id',
|
|
98
|
-
'role_id',
|
|
99
|
-
'role',
|
|
100
|
-
'name',
|
|
101
|
-
'contact',
|
|
102
|
-
'description',
|
|
103
|
-
'comments',
|
|
104
|
-
'_object_repr',
|
|
105
|
-
]
|
|
106
|
-
|
|
107
|
-
def search(self, queryset, name, value):
|
|
108
|
-
if not value.strip():
|
|
109
|
-
return queryset
|
|
110
|
-
return queryset.filter(
|
|
111
|
-
Q(name__icontains=value)
|
|
112
|
-
| Q(_object_repr__icontains=value)
|
|
113
|
-
| Q(description__icontains=value)
|
|
114
|
-
| Q(comments__icontains=value),
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
else:
|
|
118
|
-
|
|
119
|
-
class SecretFilterSet(NetBoxModelFilterSet):
|
|
120
|
-
name = MultiValueCharFilter(lookup_expr='iexact')
|
|
121
|
-
role_id = django_filters.ModelMultipleChoiceFilter(
|
|
122
|
-
queryset=SecretRole.objects.all(),
|
|
123
|
-
label='Role (ID)',
|
|
124
|
-
)
|
|
125
|
-
role = django_filters.ModelMultipleChoiceFilter(
|
|
126
|
-
field_name='role__slug',
|
|
127
|
-
queryset=SecretRole.objects.all(),
|
|
128
|
-
to_field_name='slug',
|
|
129
|
-
label='Role (slug)',
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
assigned_object_type = ContentTypeFilter()
|
|
133
|
-
|
|
134
|
-
assigned_object_type_id = django_filters.ModelMultipleChoiceFilter(
|
|
135
|
-
queryset=ContentType.objects.filter(SECRET_ASSIGNABLE_MODELS),
|
|
136
|
-
label='Object type (ID)',
|
|
137
|
-
)
|
|
138
|
-
|
|
139
|
-
class Meta:
|
|
140
|
-
model = Secret
|
|
141
|
-
fields = [
|
|
142
|
-
'id',
|
|
143
|
-
'assigned_object_type',
|
|
144
|
-
'assigned_object_type_id',
|
|
145
|
-
'assigned_object_id',
|
|
146
|
-
'role_id',
|
|
147
|
-
'role',
|
|
148
|
-
'name',
|
|
149
|
-
'_object_repr',
|
|
150
|
-
'description',
|
|
151
|
-
'comments',
|
|
152
|
-
]
|
|
153
|
-
|
|
154
|
-
def search(self, queryset, name, value):
|
|
155
|
-
if not value.strip():
|
|
156
|
-
return queryset
|
|
157
|
-
return queryset.filter(
|
|
158
|
-
Q(name__icontains=value)
|
|
159
|
-
| Q(_object_repr__icontains=value)
|
|
160
|
-
| Q(description__icontains=value)
|
|
161
|
-
| Q(comments__icontains=value),
|
|
162
|
-
)
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import strawberry_django
|
|
2
|
-
|
|
3
|
-
from netbox.graphql.filter_mixins import BaseFilterMixin, autotype_decorator
|
|
4
|
-
from ..filtersets import *
|
|
5
|
-
from ..models import *
|
|
6
|
-
|
|
7
|
-
__all__ = [
|
|
8
|
-
'SecretFilter',
|
|
9
|
-
'SecretRoleFilter',
|
|
10
|
-
]
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@strawberry_django.filter(Secret, lookups=True)
|
|
14
|
-
@autotype_decorator(SecretFilterSet)
|
|
15
|
-
class SecretFilter(BaseFilterMixin):
|
|
16
|
-
pass
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
@strawberry_django.filter(SecretRole, lookups=True)
|
|
20
|
-
@autotype_decorator(SecretRoleFilterSet)
|
|
21
|
-
class SecretRoleFilter(BaseFilterMixin):
|
|
22
|
-
pass
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
from typing import List
|
|
2
|
-
|
|
3
|
-
import strawberry
|
|
4
|
-
import strawberry_django
|
|
5
|
-
|
|
6
|
-
from .types import *
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@strawberry.type(name='Query')
|
|
10
|
-
class NetboxSecretsQuery:
|
|
11
|
-
secret_roles: List[SecretRoleType] = strawberry_django.field()
|
|
12
|
-
secret_roles_list: List[SecretRoleType] = strawberry_django.field()
|
|
13
|
-
|
|
14
|
-
secrets: List[SecretType] = strawberry_django.field()
|
|
15
|
-
secrets_list: List[SecretType] = strawberry_django.field()
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
from typing import Annotated
|
|
2
|
-
|
|
3
|
-
import strawberry
|
|
4
|
-
import strawberry_django
|
|
5
|
-
|
|
6
|
-
from netbox.graphql.types import NetBoxObjectType
|
|
7
|
-
from .filters import *
|
|
8
|
-
from ..models import *
|
|
9
|
-
|
|
10
|
-
__all__ = [
|
|
11
|
-
'SecretRoleType',
|
|
12
|
-
'SecretType',
|
|
13
|
-
]
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@strawberry_django.type(SecretRole, fields="__all__", filters=SecretRoleFilter)
|
|
17
|
-
class SecretRoleType(NetBoxObjectType):
|
|
18
|
-
name: str
|
|
19
|
-
slug: str
|
|
20
|
-
description: str
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
@strawberry_django.type(Secret, exclude=('ciphertext', 'hash', 'plaintext'), filters=SecretFilter)
|
|
24
|
-
class SecretType(NetBoxObjectType):
|
|
25
|
-
role: Annotated['SecretRoleType', strawberry.lazy('netbox_secrets.graphql.types')]
|
|
26
|
-
name: str
|
|
27
|
-
description: str
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/migrations/0002_populate_userkeys.py
RENAMED
|
File without changes
|
{netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/migrations/0003_populate_secretroles.py
RENAMED
|
File without changes
|
{netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/migrations/0004_populate_secrets.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/static/netbox_secrets/secrets.js
RENAMED
|
File without changes
|
{netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/static/netbox_secrets/secrets.js.map
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/templates/netbox_secrets/secret.html
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{netbox_secrets-2.2.1 → netbox_secrets-2.3.0}/netbox_secrets/templates/netbox_secrets/userkey.html
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|