netbox-secrets 2.2.1__tar.gz → 2.3.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.
- {netbox_secrets-2.2.1/netbox_secrets.egg-info → netbox_secrets-2.3.1}/PKG-INFO +5 -8
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/README.md +1 -4
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/__init__.py +2 -3
- netbox_secrets-2.3.1/netbox_secrets/filtersets.py +112 -0
- netbox_secrets-2.3.1/netbox_secrets/graphql/filters.py +38 -0
- netbox_secrets-2.3.1/netbox_secrets/graphql/schema.py +15 -0
- netbox_secrets-2.3.1/netbox_secrets/graphql/types.py +33 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/models/secrets.py +0 -6
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/signals.py +0 -12
- netbox_secrets-2.3.1/netbox_secrets/static/netbox_secrets/secrets.js +10 -0
- netbox_secrets-2.3.1/netbox_secrets/static/netbox_secrets/secrets.js.map +7 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/template_content.py +13 -11
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/templates/netbox_secrets/inc/secrets_panel.html +3 -1
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/tests/test_api.py +2 -14
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/views.py +3 -14
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1/netbox_secrets.egg-info}/PKG-INFO +5 -8
- netbox_secrets-2.3.1/netbox_secrets.egg-info/requires.txt +1 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/pyproject.toml +1 -1
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/setup.py +26 -6
- 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/static/netbox_secrets/secrets.js +0 -20
- netbox_secrets-2.2.1/netbox_secrets/static/netbox_secrets/secrets.js.map +0 -7
- netbox_secrets-2.2.1/netbox_secrets.egg-info/requires.txt +0 -1
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/LICENSE.md +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/MANIFEST.in +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/api/__init__.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/api/serializers.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/api/urls.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/api/views.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/constants.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/exceptions.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/forms/__init__.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/forms/bulk_edit.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/forms/bulk_import.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/forms/filterset.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/forms/model_forms.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/graphql/__init__.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/hashers.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/migrations/0001_initial.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/migrations/0002_populate_userkeys.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/migrations/0003_populate_secretroles.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/migrations/0004_populate_secrets.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/migrations/0005_alter_secret_custom_field_data_and_more.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/migrations/0006_alter_userkey_created_alter_userkey_last_updated.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/migrations/0007_secret__object_repr_secret_comments_and_more.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/migrations/0008_userkey_custom_field_data_userkey_tags.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/migrations/__init__.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/models/__init__.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/navigation.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/querysets.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/tables.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/templates/netbox_secrets/activate_keys.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/templates/netbox_secrets/inc/private_key_modal.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/templates/netbox_secrets/inc/secret_actions.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/templates/netbox_secrets/inc/secret_add_button.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/templates/netbox_secrets/secret.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/templates/netbox_secrets/secret_edit.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/templates/netbox_secrets/secretrole.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/templates/netbox_secrets/userkey.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/templates/netbox_secrets/userkey_edit.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/templates/netbox_secrets/userkey_list.html +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/tests/__init__.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/tests/constants.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/tests/test_filters.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/tests/test_form.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/tests/test_models.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/tests/test_views.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/urls.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/utils/__init__.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/utils/crypto.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/utils/hashers.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets/utils/helpers.py +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets.egg-info/SOURCES.txt +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets.egg-info/dependency_links.txt +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets.egg-info/not-zip-safe +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/netbox_secrets.egg-info/top_level.txt +0 -0
- {netbox_secrets-2.2.1 → netbox_secrets-2.3.1}/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.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
|
|
@@ -9,12 +9,12 @@ Maintainer: Prince Kumar
|
|
|
9
9
|
Maintainer-email: pkumar@onemindservices.com
|
|
10
10
|
License: Apache 2.0
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: License :: OSI Approved ::
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
13
|
Classifier: Operating System :: OS Independent
|
|
14
|
-
Requires-Python: >=3.
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE.md
|
|
17
|
-
Requires-Dist: pycryptodome
|
|
17
|
+
Requires-Dist: pycryptodome==3.23.0
|
|
18
18
|
Dynamic: author
|
|
19
19
|
Dynamic: author-email
|
|
20
20
|
Dynamic: classifier
|
|
@@ -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
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";(()=>{var C=Object.create;var b=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var D=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var O=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of _(n))!H.call(e,o)&&o!==t&&b(e,o,{get:()=>n[o],enumerable:!(r=M(n,o))||r.enumerable});return e};var q=(e,n,t)=>(t=e!=null?C($(e)):{},O(n||!e||!e.__esModule?b(t,"default",{value:e,enumerable:!0}):t,e));var y=(e,n,t)=>new Promise((r,o)=>{var i=a=>{try{l(t.next(a))}catch(c){o(c)}},s=a=>{try{l(t.throw(a))}catch(c){o(c)}},l=a=>a.done?r(a.value):Promise.resolve(a.value).then(i,s);l((t=t.apply(e,n)).next())});var A=D(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.parse=G;E.serialize=V;var j=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,K=/^[\u0021-\u003A\u003C-\u007E]*$/,U=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,z=/^[\u0020-\u003A\u003D-\u007E]*$/,F=Object.prototype.toString,N=(()=>{let e=function(){};return e.prototype=Object.create(null),e})();function G(e,n){let t=new N,r=e.length;if(r<2)return t;let o=(n==null?void 0:n.decode)||J,i=0;do{let s=e.indexOf("=",i);if(s===-1)break;let l=e.indexOf(";",i),a=l===-1?r:l;if(s>a){i=e.lastIndexOf(";",s-1)+1;continue}let c=v(e,i,s),d=T(e,s,c),u=e.slice(c,d);if(t[u]===void 0){let w=v(e,s+1,a),p=T(e,a,w),B=o(e.slice(w,p));t[u]=B}i=a+1}while(i<r);return t}function v(e,n,t){do{let r=e.charCodeAt(n);if(r!==32&&r!==9)return n}while(++n<t);return t}function T(e,n,t){for(;n>t;){let r=e.charCodeAt(--n);if(r!==32&&r!==9)return n+1}return t}function V(e,n,t){let r=(t==null?void 0:t.encode)||encodeURIComponent;if(!j.test(e))throw new TypeError(`argument name is invalid: ${e}`);let o=r(n);if(!K.test(o))throw new TypeError(`argument val is invalid: ${n}`);let i=e+"="+o;if(!t)return i;if(t.maxAge!==void 0){if(!Number.isInteger(t.maxAge))throw new TypeError(`option maxAge is invalid: ${t.maxAge}`);i+="; Max-Age="+t.maxAge}if(t.domain){if(!U.test(t.domain))throw new TypeError(`option domain is invalid: ${t.domain}`);i+="; Domain="+t.domain}if(t.path){if(!z.test(t.path))throw new TypeError(`option path is invalid: ${t.path}`);i+="; Path="+t.path}if(t.expires){if(!X(t.expires)||!Number.isFinite(t.expires.valueOf()))throw new TypeError(`option expires is invalid: ${t.expires}`);i+="; Expires="+t.expires.toUTCString()}if(t.httpOnly&&(i+="; HttpOnly"),t.secure&&(i+="; Secure"),t.partitioned&&(i+="; Partitioned"),t.priority)switch(typeof t.priority=="string"?t.priority.toLowerCase():void 0){case"low":i+="; Priority=Low";break;case"medium":i+="; Priority=Medium";break;case"high":i+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${t.priority}`)}if(t.sameSite)switch(typeof t.sameSite=="string"?t.sameSite.toLowerCase():t.sameSite){case!0:case"strict":i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"none":i+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${t.sameSite}`)}return i}function J(e){if(e.indexOf("%")===-1)return e;try{return decodeURIComponent(e)}catch(n){return e}}function X(e){return F.call(e)==="[object Date]"}});function m(e,n,t,r){let o="mdi-alert";switch(e){case"warning":o="mdi-alert";break;case"success":o="mdi-check-circle";break;case"info":o="mdi-information";break;case"danger":o="mdi-alert";break}let i=document.createElement("div");i.setAttribute("class","toast-container position-fixed bottom-0 end-0 m-3");let s=document.createElement("div");s.setAttribute("class",`toast bg-${e}`),s.setAttribute("role","alert"),s.setAttribute("aria-live","assertive"),s.setAttribute("aria-atomic","true");let l=document.createElement("div");l.setAttribute("class",`toast-header bg-${e} text-body`);let a=document.createElement("i");a.setAttribute("class",`mdi ${o}`);let c=document.createElement("strong");c.setAttribute("class","me-auto ms-1"),c.innerText=n;let d=document.createElement("button");d.setAttribute("type","button"),d.setAttribute("class","btn-close"),d.setAttribute("data-bs-dismiss","toast"),d.setAttribute("aria-label","Close");let u=document.createElement("div");if(u.setAttribute("class","toast-body"),l.appendChild(a),l.appendChild(c),typeof r!="undefined"){let p=document.createElement("small");p.setAttribute("class","text-muted"),l.appendChild(p)}return l.appendChild(d),u.innerText=t.trim(),s.appendChild(l),s.appendChild(u),i.appendChild(s),document.body.appendChild(i),new window.Toast(s)}var L=q(A());function S(e){return"error"in e&&"exception"in e}function k(e){return"error"in e}function x(e){return"value"in e&&"required"in e}function Y(){let{csrftoken:e}=L.default.parse(document.cookie);if(typeof e=="undefined")throw new Error("Invalid or missing CSRF token");return e}function I(e,n,t){return y(this,null,function*(){let r=Y(),o=new Headers({"X-CSRFToken":r}),i;typeof t!="undefined"&&(i=JSON.stringify(t),o.set("content-type","application/json"),o.set("Accept","application/json"));let s=yield fetch(e,{method:n,body:i,headers:o,credentials:"same-origin"}),l=s.headers.get("Content-Type");if(typeof l=="string"&&l.includes("text"))return{error:yield s.text()};let a=yield s.json();return!s.ok&&Array.isArray(a)?{error:a.join(`
|
|
2
|
+
`)}:!s.ok&&"detail"in a?{error:a.detail}:a})}function P(e,n){return y(this,null,function*(){return yield I(e,"POST",n)})}function g(e){return y(this,null,function*(){return yield I(e,"GET")})}function f(e){let n=window.location.pathname||"",t=n.indexOf("/plugins/"),r=n.indexOf("/api/"),o=t>=0?t:r;return`${o>=0?n.slice(0,o):""}${e}`}function Q(){let e=document.getElementById("new_keypair_modal"),n=document.getElementById("use_new_pubkey"),t=document.getElementById("copy_prikey"),r=document.getElementById("export_key");if(e===null||n===null||t===null||r===null)return;let o=e.querySelector("textarea#new_pubkey"),i=e.querySelector("textarea#new_privkey");function s(){for(let c of[o,i])c!==null&&c.setAttribute("readonly","");g(f("/api/plugins/secrets/generate-rsa-key-pair/")).then(c=>{if(k(c))m("danger","Error",c.error).show();else{let{private_key:d,public_key:u}=c;o!==null&&i!==null&&(o.value=u,i.value=d)}})}function l(){let c=document.getElementById("id_public_key");o!==null&&(c.value=o.value,c.innerText=o.value)}function a(){let c=`Public Key
|
|
3
|
+
|
|
4
|
+
${o==null?void 0:o.value}
|
|
5
|
+
|
|
6
|
+
Private Key
|
|
7
|
+
|
|
8
|
+
${i==null?void 0:i.value}`,d=new Blob([c],{type:"text/plain"}),u=document.createElement("a");u.style.display="none",u.href=window.URL.createObjectURL(d),u.download="key.txt",document.body.appendChild(u),u.click(),window.URL.revokeObjectURL(u.href),document.body.removeChild(u)}e.addEventListener("shown.bs.modal",()=>s()),n.addEventListener("click",()=>l()),t.addEventListener("click",()=>navigator.clipboard.writeText((i==null?void 0:i.value)||"")),r.addEventListener("click",()=>a())}function R(e,n){let t=document.querySelector(`button.unlock-secret[secret-id='${e}']`),r=document.querySelector(`button.lock-secret[secret-id='${e}']`),o=document.querySelector(`span[secret-id='${e}']`);t!==null&&(n==="unlock"&&t.classList.add("d-none"),n==="lock"&&t.classList.remove("d-none")),r!==null&&(n==="unlock"&&r.classList.remove("d-none"),n==="lock"&&r.classList.add("d-none")),o!==null&&(n==="unlock"&&o.classList.remove("d-none"),n==="lock"&&o.classList.add("d-none"))}function W(){let e=new window.Modal("#privkey_modal");function n(r){let o=document.getElementById(`secret_${r}`);typeof r=="string"&&r!==""&&g(f(`/api/plugins/secrets/secrets/${r}/`)).then(i=>{if(k(i))i.error.toLowerCase().includes("invalid session key")?e.show():m("danger","Error",i.error).show();else{let{plaintext:s}=i;o!==null&&s!==null?(x(o)?o.value=s:o.innerText=s,R(r,"unlock")):e.show()}})}function t(r){if(typeof r=="string"&&r!==""){let o=document.getElementById(`secret_${r}`);x(o)?o.value="********":o.innerText="********",R(r,"lock")}}for(let r of document.querySelectorAll("button.unlock-secret"))r.addEventListener("click",()=>n(r.getAttribute("secret-id")));for(let r of document.querySelectorAll("button.lock-secret"))r.addEventListener("click",()=>t(r.getAttribute("secret-id")))}function Z(e){P(f("/api/plugins/secrets/session-keys/"),{private_key:e,preserve_key:!0}).then(n=>{if(k(n)){let t=n.error;S(n)&&(t+=`
|
|
9
|
+
${n.exception}`),m("danger","Failed to Retrieve Session Key",t).show()}else if(window.location.pathname===f("/plugins/secrets/user-key/"))window.location.reload();else{let t=m("success","Session Key Received","You may now unlock secrets.");window.location.reload(),t.show()}})}function ee(){for(let n of document.querySelectorAll("#request_session_key")){let t=function(){for(let r of document.querySelectorAll("#user_privkey"))Z(r.value),r.value=""};var e=t;n.addEventListener("click",t)}}function te(){let e=new window.Modal("#privkey_modal");function n(t){document.cookie.indexOf("netbox_secrets_sessionid")===-1&&(t.preventDefault(),e.show())}for(let t of document.querySelectorAll(".requires-session-key")){let r=t.closest("form");r!==null&&r.addEventListener("submit",n)}}function h(){for(let e of[Q,W,ee,te])e()}document.readyState!=="loading"?h():document.addEventListener("DOMContentLoaded",h);})();
|
|
10
|
+
//# sourceMappingURL=/static/netbox_secrets/secrets.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../node_modules/cookie/src/index.ts", "../src/bs.ts", "../src/util.ts", "../src/secrets.ts", "../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * RegExp to match cookie-name in RFC 6265 sec 4.1.1\n * This refers out to the obsoleted definition of token in RFC 2616 sec 2.2\n * which has been replaced by the token definition in RFC 7230 appendix B.\n *\n * cookie-name = token\n * token = 1*tchar\n * tchar = \"!\" / \"#\" / \"$\" / \"%\" / \"&\" / \"'\" /\n * \"*\" / \"+\" / \"-\" / \".\" / \"^\" / \"_\" /\n * \"`\" / \"|\" / \"~\" / DIGIT / ALPHA\n *\n * Note: Allowing more characters - https://github.com/jshttp/cookie/issues/191\n * Allow same range as cookie value, except `=`, which delimits end of name.\n */\nconst cookieNameRegExp = /^[\\u0021-\\u003A\\u003C\\u003E-\\u007E]+$/;\n\n/**\n * RegExp to match cookie-value in RFC 6265 sec 4.1.1\n *\n * cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE )\n * cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E\n * ; US-ASCII characters excluding CTLs,\n * ; whitespace DQUOTE, comma, semicolon,\n * ; and backslash\n *\n * Allowing more characters: https://github.com/jshttp/cookie/issues/191\n * Comma, backslash, and DQUOTE are not part of the parsing algorithm.\n */\nconst cookieValueRegExp = /^[\\u0021-\\u003A\\u003C-\\u007E]*$/;\n\n/**\n * RegExp to match domain-value in RFC 6265 sec 4.1.1\n *\n * domain-value = <subdomain>\n * ; defined in [RFC1034], Section 3.5, as\n * ; enhanced by [RFC1123], Section 2.1\n * <subdomain> = <label> | <subdomain> \".\" <label>\n * <label> = <let-dig> [ [ <ldh-str> ] <let-dig> ]\n * Labels must be 63 characters or less.\n * 'let-dig' not 'letter' in the first char, per RFC1123\n * <ldh-str> = <let-dig-hyp> | <let-dig-hyp> <ldh-str>\n * <let-dig-hyp> = <let-dig> | \"-\"\n * <let-dig> = <letter> | <digit>\n * <letter> = any one of the 52 alphabetic characters A through Z in\n * upper case and a through z in lower case\n * <digit> = any one of the ten digits 0 through 9\n *\n * Keep support for leading dot: https://github.com/jshttp/cookie/issues/173\n *\n * > (Note that a leading %x2E (\".\"), if present, is ignored even though that\n * character is not permitted, but a trailing %x2E (\".\"), if present, will\n * cause the user agent to ignore the attribute.)\n */\nconst domainValueRegExp =\n /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;\n\n/**\n * RegExp to match path-value in RFC 6265 sec 4.1.1\n *\n * path-value = <any CHAR except CTLs or \";\">\n * CHAR = %x01-7F\n * ; defined in RFC 5234 appendix B.1\n */\nconst pathValueRegExp = /^[\\u0020-\\u003A\\u003D-\\u007E]*$/;\n\nconst __toString = Object.prototype.toString;\n\nconst NullObject = /* @__PURE__ */ (() => {\n const C = function () {};\n C.prototype = Object.create(null);\n return C;\n})() as unknown as { new (): any };\n\n/**\n * Parse options.\n */\nexport interface ParseOptions {\n /**\n * Specifies a function that will be used to decode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1).\n * Since the value of a cookie has a limited character set (and must be a simple string), this function can be used to decode\n * a previously-encoded cookie value into a JavaScript string.\n *\n * The default function is the global `decodeURIComponent`, wrapped in a `try..catch`. If an error\n * is thrown it will return the cookie's original value. If you provide your own encode/decode\n * scheme you must ensure errors are appropriately handled.\n *\n * @default decode\n */\n decode?: (str: string) => string | undefined;\n}\n\n/**\n * Parse a cookie header.\n *\n * Parse the given cookie header string into an object\n * The object has the various cookies as keys(names) => values\n */\nexport function parse(\n str: string,\n options?: ParseOptions,\n): Record<string, string | undefined> {\n const obj: Record<string, string | undefined> = new NullObject();\n const len = str.length;\n // RFC 6265 sec 4.1.1, RFC 2616 2.2 defines a cookie name consists of one char minimum, plus '='.\n if (len < 2) return obj;\n\n const dec = options?.decode || decode;\n let index = 0;\n\n do {\n const eqIdx = str.indexOf(\"=\", index);\n if (eqIdx === -1) break; // No more cookie pairs.\n\n const colonIdx = str.indexOf(\";\", index);\n const endIdx = colonIdx === -1 ? len : colonIdx;\n\n if (eqIdx > endIdx) {\n // backtrack on prior semicolon\n index = str.lastIndexOf(\";\", eqIdx - 1) + 1;\n continue;\n }\n\n const keyStartIdx = startIndex(str, index, eqIdx);\n const keyEndIdx = endIndex(str, eqIdx, keyStartIdx);\n const key = str.slice(keyStartIdx, keyEndIdx);\n\n // only assign once\n if (obj[key] === undefined) {\n let valStartIdx = startIndex(str, eqIdx + 1, endIdx);\n let valEndIdx = endIndex(str, endIdx, valStartIdx);\n\n const value = dec(str.slice(valStartIdx, valEndIdx));\n obj[key] = value;\n }\n\n index = endIdx + 1;\n } while (index < len);\n\n return obj;\n}\n\nfunction startIndex(str: string, index: number, max: number) {\n do {\n const code = str.charCodeAt(index);\n if (code !== 0x20 /* */ && code !== 0x09 /* \\t */) return index;\n } while (++index < max);\n return max;\n}\n\nfunction endIndex(str: string, index: number, min: number) {\n while (index > min) {\n const code = str.charCodeAt(--index);\n if (code !== 0x20 /* */ && code !== 0x09 /* \\t */) return index + 1;\n }\n return min;\n}\n\n/**\n * Serialize options.\n */\nexport interface SerializeOptions {\n /**\n * Specifies a function that will be used to encode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1).\n * Since value of a cookie has a limited character set (and must be a simple string), this function can be used to encode\n * a value into a string suited for a cookie's value, and should mirror `decode` when parsing.\n *\n * @default encodeURIComponent\n */\n encode?: (str: string) => string;\n /**\n * Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.2).\n *\n * The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and\n * `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,\n * so if both are set, they should point to the same date and time.\n */\n maxAge?: number;\n /**\n * Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.1).\n * When no expiration is set clients consider this a \"non-persistent cookie\" and delete it the current session is over.\n *\n * The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and\n * `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,\n * so if both are set, they should point to the same date and time.\n */\n expires?: Date;\n /**\n * Specifies the value for the [`Domain` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.3).\n * When no domain is set clients consider the cookie to apply to the current domain only.\n */\n domain?: string;\n /**\n * Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).\n * When no path is set, the path is considered the [\"default path\"](https://tools.ietf.org/html/rfc6265#section-5.1.4).\n */\n path?: string;\n /**\n * Enables the [`HttpOnly` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.6).\n * When enabled, clients will not allow client-side JavaScript to see the cookie in `document.cookie`.\n */\n httpOnly?: boolean;\n /**\n * Enables the [`Secure` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.5).\n * When enabled, clients will only send the cookie back if the browser has a HTTPS connection.\n */\n secure?: boolean;\n /**\n * Enables the [`Partitioned` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-cutler-httpbis-partitioned-cookies/).\n * When enabled, clients will only send the cookie back when the current domain _and_ top-level domain matches.\n *\n * This is an attribute that has not yet been fully standardized, and may change in the future.\n * This also means clients may ignore this attribute until they understand it. More information\n * about can be found in [the proposal](https://github.com/privacycg/CHIPS).\n */\n partitioned?: boolean;\n /**\n * Specifies the value for the [`Priority` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).\n *\n * - `'low'` will set the `Priority` attribute to `Low`.\n * - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.\n * - `'high'` will set the `Priority` attribute to `High`.\n *\n * More information about priority levels can be found in [the specification](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).\n */\n priority?: \"low\" | \"medium\" | \"high\";\n /**\n * Specifies the value for the [`SameSite` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).\n *\n * - `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.\n * - `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.\n * - `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.\n * - `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.\n *\n * More information about enforcement levels can be found in [the specification](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).\n */\n sameSite?: boolean | \"lax\" | \"strict\" | \"none\";\n}\n\n/**\n * Serialize data into a cookie header.\n *\n * Serialize a name value pair into a cookie string suitable for\n * http headers. An optional options object specifies cookie parameters.\n *\n * serialize('foo', 'bar', { httpOnly: true })\n * => \"foo=bar; httpOnly\"\n */\nexport function serialize(\n name: string,\n val: string,\n options?: SerializeOptions,\n): string {\n const enc = options?.encode || encodeURIComponent;\n\n if (!cookieNameRegExp.test(name)) {\n throw new TypeError(`argument name is invalid: ${name}`);\n }\n\n const value = enc(val);\n\n if (!cookieValueRegExp.test(value)) {\n throw new TypeError(`argument val is invalid: ${val}`);\n }\n\n let str = name + \"=\" + value;\n if (!options) return str;\n\n if (options.maxAge !== undefined) {\n if (!Number.isInteger(options.maxAge)) {\n throw new TypeError(`option maxAge is invalid: ${options.maxAge}`);\n }\n\n str += \"; Max-Age=\" + options.maxAge;\n }\n\n if (options.domain) {\n if (!domainValueRegExp.test(options.domain)) {\n throw new TypeError(`option domain is invalid: ${options.domain}`);\n }\n\n str += \"; Domain=\" + options.domain;\n }\n\n if (options.path) {\n if (!pathValueRegExp.test(options.path)) {\n throw new TypeError(`option path is invalid: ${options.path}`);\n }\n\n str += \"; Path=\" + options.path;\n }\n\n if (options.expires) {\n if (\n !isDate(options.expires) ||\n !Number.isFinite(options.expires.valueOf())\n ) {\n throw new TypeError(`option expires is invalid: ${options.expires}`);\n }\n\n str += \"; Expires=\" + options.expires.toUTCString();\n }\n\n if (options.httpOnly) {\n str += \"; HttpOnly\";\n }\n\n if (options.secure) {\n str += \"; Secure\";\n }\n\n if (options.partitioned) {\n str += \"; Partitioned\";\n }\n\n if (options.priority) {\n const priority =\n typeof options.priority === \"string\"\n ? options.priority.toLowerCase()\n : undefined;\n switch (priority) {\n case \"low\":\n str += \"; Priority=Low\";\n break;\n case \"medium\":\n str += \"; Priority=Medium\";\n break;\n case \"high\":\n str += \"; Priority=High\";\n break;\n default:\n throw new TypeError(`option priority is invalid: ${options.priority}`);\n }\n }\n\n if (options.sameSite) {\n const sameSite =\n typeof options.sameSite === \"string\"\n ? options.sameSite.toLowerCase()\n : options.sameSite;\n switch (sameSite) {\n case true:\n case \"strict\":\n str += \"; SameSite=Strict\";\n break;\n case \"lax\":\n str += \"; SameSite=Lax\";\n break;\n case \"none\":\n str += \"; SameSite=None\";\n break;\n default:\n throw new TypeError(`option sameSite is invalid: ${options.sameSite}`);\n }\n }\n\n return str;\n}\n\n/**\n * URL-decode string value. Optimized to skip native call when no %.\n */\nfunction decode(str: string): string {\n if (str.indexOf(\"%\") === -1) return str;\n\n try {\n return decodeURIComponent(str);\n } catch (e) {\n return str;\n }\n}\n\n/**\n * Determine if value is a Date.\n */\nfunction isDate(val: any): val is Date {\n return __toString.call(val) === \"[object Date]\";\n}\n", "type ToastLevel = 'danger' | 'warning' | 'success' | 'info';\n\nexport function createToast(\n level: ToastLevel,\n title: string,\n message: string,\n extra?: string,\n): InstanceType<typeof window.Toast> {\n let iconName = 'mdi-alert';\n switch (level) {\n case 'warning':\n iconName = 'mdi-alert';\n break;\n case 'success':\n iconName = 'mdi-check-circle';\n break;\n case 'info':\n iconName = 'mdi-information';\n break;\n case 'danger':\n iconName = 'mdi-alert';\n break;\n }\n\n const container = document.createElement('div');\n container.setAttribute('class', 'toast-container position-fixed bottom-0 end-0 m-3');\n\n const main = document.createElement('div');\n main.setAttribute('class', `toast bg-${level}`);\n main.setAttribute('role', 'alert');\n main.setAttribute('aria-live', 'assertive');\n main.setAttribute('aria-atomic', 'true');\n\n const header = document.createElement('div');\n header.setAttribute('class', `toast-header bg-${level} text-body`);\n\n const icon = document.createElement('i');\n icon.setAttribute('class', `mdi ${iconName}`);\n\n const titleElement = document.createElement('strong');\n titleElement.setAttribute('class', 'me-auto ms-1');\n titleElement.innerText = title;\n\n const button = document.createElement('button');\n button.setAttribute('type', 'button');\n button.setAttribute('class', 'btn-close');\n button.setAttribute('data-bs-dismiss', 'toast');\n button.setAttribute('aria-label', 'Close');\n\n const body = document.createElement('div');\n body.setAttribute('class', 'toast-body');\n\n header.appendChild(icon);\n header.appendChild(titleElement);\n\n if (typeof extra !== 'undefined') {\n const extraElement = document.createElement('small');\n extraElement.setAttribute('class', 'text-muted');\n header.appendChild(extraElement);\n }\n\n header.appendChild(button);\n\n body.innerText = message.trim();\n\n main.appendChild(header);\n main.appendChild(body);\n container.appendChild(main);\n document.body.appendChild(container);\n\n const toast = new window.Toast(main);\n return toast;\n}\n", "import Cookie from 'cookie';\n\ntype APIRes<T> = T | ErrorBase | APIError;\ntype Method = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';\ntype ReqData = URLSearchParams | Dict | undefined | unknown;\n\n/**\n * Type guard to determine if an API response is a detailed error.\n *\n * @param data API JSON Response\n * @returns Type guard for `data`.\n */\nexport function isApiError(data: Record<string, unknown>): data is APIError {\n return 'error' in data && 'exception' in data;\n}\n\n/**\n * Type guard to determine if an API response is an error.\n *\n * @param data API JSON Response\n * @returns Type guard for `data`.\n */\nexport function hasError(data: Record<string, unknown>): data is ErrorBase {\n return 'error' in data;\n}\n\n/**\n * Type guard to determine if an element is an `HTMLInputElement`.\n *\n * @param element HTML Element.\n */\nexport function isInputElement(element: HTMLElement): element is HTMLInputElement {\n return 'value' in element && 'required' in element;\n}\n\n/**\n * Retrieve the CSRF token from cookie storage.\n */\nexport function getCsrfToken(): string {\n const { csrftoken: csrfToken } = Cookie.parse(document.cookie);\n if (typeof csrfToken === 'undefined') {\n throw new Error('Invalid or missing CSRF token');\n }\n return csrfToken;\n}\n\n/**\n * Authenticate and interact with the NetBox API.\n *\n * @param url Request URL\n * @param method Request Method\n * @param data Data to `POST`, `PATCH`, or `PUT`, if applicable.\n * @returns JSON Response\n */\nexport async function apiRequest<R extends Dict, D extends ReqData = undefined>(\n url: string,\n method: Method,\n data?: D,\n): Promise<APIRes<R>> {\n const token = getCsrfToken();\n const headers = new Headers({ 'X-CSRFToken': token });\n\n let body;\n if (typeof data !== 'undefined') {\n body = JSON.stringify(data);\n headers.set('content-type', 'application/json');\n headers.set('Accept', 'application/json');\n }\n\n const res = await fetch(url, { method, body, headers, credentials: 'same-origin' });\n const contentType = res.headers.get('Content-Type');\n if (typeof contentType === 'string' && contentType.includes('text')) {\n const error = await res.text();\n return { error } as ErrorBase;\n }\n const json = (await res.json()) as R | APIError;\n if (!res.ok && Array.isArray(json)) {\n const error = json.join('\\n');\n return { error } as ErrorBase;\n } else if (!res.ok && 'detail' in json) {\n return { error: json.detail } as ErrorBase;\n }\n return json;\n}\n\n/**\n * `POST` an object as form data to the NetBox API.\n *\n * @param url Request URL\n * @param data Object to convert to form data\n * @returns JSON Response\n */\nexport async function apiPostForm<R extends Dict, D extends Dict>(\n url: string,\n data: D,\n): Promise<APIRes<R>> {\n return await apiRequest<R, D>(url, 'POST', data);\n}\n\n/**\n * `GET` data from the NetBox API.\n *\n * @param url Request URL\n * @returns JSON Response\n */\nexport async function apiGetBase<R extends Dict>(url: string): Promise<APIRes<R>> {\n return await apiRequest<R>(url, 'GET');\n}\n\n/**\n * Prefix a NetBox-relative path with the configured BASE_PATH derived from the current location.\n *\n * Example: with BASE_PATH 'netbox/', window.location.pathname might be '/netbox/plugins/...'.\n * This derives '/netbox' and prefixes it to the provided path (e.g., '/api/...').\n */\nexport function withBasePath(path: string): string {\n const pathname = window.location.pathname || '';\n const pluginsIdx = pathname.indexOf('/plugins/');\n const apiIdx = pathname.indexOf('/api/');\n const cutIdx = pluginsIdx >= 0 ? pluginsIdx : apiIdx;\n const base = cutIdx >= 0 ? pathname.slice(0, cutIdx) : '';\n return `${base}${path}`;\n}\n", "import { createToast } from './bs';\nimport { apiGetBase, apiPostForm, hasError, isApiError, isInputElement, withBasePath } from './util';\n\nimport type { APIKeyPair, APISecret } from './types';\n\n/**\n * Initialize Generate Private Key Pair Elements.\n */\nfunction initGenerateKeyPair() {\n const element = document.getElementById('new_keypair_modal') as HTMLDivElement;\n const accept = document.getElementById('use_new_pubkey') as HTMLButtonElement;\n const copyBtn = document.getElementById('copy_prikey') as HTMLButtonElement;\n const exportBtn = document.getElementById('export_key') as HTMLButtonElement;\n // If the elements are not loaded, stop.\n if (element === null || accept === null || copyBtn === null || exportBtn === null) {\n return;\n }\n const publicElem = element.querySelector<HTMLTextAreaElement>('textarea#new_pubkey');\n const privateElem = element.querySelector<HTMLTextAreaElement>('textarea#new_privkey');\n\n /**\n * Handle Generate Private Key Pair Modal opening.\n */\n function handleOpen() {\n // When the modal opens, set the `readonly` attribute on the textarea elements.\n for (const elem of [publicElem, privateElem]) {\n if (elem !== null) {\n elem.setAttribute('readonly', '');\n }\n }\n // Fetch the key pair from the API.\n apiGetBase<APIKeyPair>(withBasePath('/api/plugins/secrets/generate-rsa-key-pair/')).then(data => {\n if (!hasError(data)) {\n // If key pair generation was successful, set the textarea elements' value to the generated\n // values.\n const { private_key: priv, public_key: pub } = data;\n if (publicElem !== null && privateElem !== null) {\n publicElem.value = pub;\n privateElem.value = priv;\n }\n } else {\n // Otherwise, show an error.\n const toast = createToast('danger', 'Error', data.error);\n toast.show();\n }\n });\n }\n\n /**\n * Set the public key form field's value to the generated public key.\n */\n function handleAccept() {\n const publicKeyField = document.getElementById('id_public_key') as HTMLTextAreaElement;\n if (publicElem !== null) {\n publicKeyField.value = publicElem.value;\n publicKeyField.innerText = publicElem.value;\n }\n }\n\n /**\n * Handles file download functionality.\n */\n function handleExport() {\n const content = `Public Key\\n\\n${publicElem?.value}\\n\\nPrivate Key\\n\\n${privateElem?.value}`;\n\n const blob = new Blob([content], { type: 'text/plain' });\n\n const a = document.createElement('a');\n a.style.display = 'none';\n a.href = window.URL.createObjectURL(blob);\n a.download = 'key.txt';\n document.body.appendChild(a);\n\n a.click();\n\n window.URL.revokeObjectURL(a.href);\n document.body.removeChild(a);\n }\n\n element.addEventListener('shown.bs.modal', () => handleOpen());\n accept.addEventListener('click', () => handleAccept());\n copyBtn.addEventListener('click', () => navigator.clipboard.writeText(privateElem?.value || ''));\n exportBtn.addEventListener('click', () => handleExport());\n}\n\n/**\n * Toggle copy/lock/unlock button visibility based on the action occurring.\n * @param id Secret ID.\n * @param action Lock or Unlock, so we know which buttons to display.\n */\nfunction toggleSecretButtons(id: string, action: 'lock' | 'unlock') {\n const unlockButton = document.querySelector(`button.unlock-secret[secret-id='${id}']`);\n const lockButton = document.querySelector(`button.lock-secret[secret-id='${id}']`);\n const copyButton = document.querySelector(`span[secret-id='${id}']`);\n // If we're unlocking, hide the unlock button. Otherwise, show it.\n if (unlockButton !== null) {\n if (action === 'unlock') unlockButton.classList.add('d-none');\n if (action === 'lock') unlockButton.classList.remove('d-none');\n }\n // If we're unlocking, show the lock button. Otherwise, hide it.\n if (lockButton !== null) {\n if (action === 'unlock') lockButton.classList.remove('d-none');\n if (action === 'lock') lockButton.classList.add('d-none');\n }\n // If we're unlocking, show the copy button. Otherwise, hide it.\n if (copyButton !== null) {\n if (action === 'unlock') copyButton.classList.remove('d-none');\n if (action === 'lock') copyButton.classList.add('d-none');\n }\n}\n\n/**\n * Initialize Lock & Unlock button event listeners & callbacks.\n */\nfunction initLockUnlock() {\n const privateKeyModal = new window.Modal('#privkey_modal');\n\n /**\n * Unlock a secret, or prompt the user for their private key, if a session key is not available.\n *\n * @param id Secret ID\n */\n function unlock(id: string | null) {\n const target = document.getElementById(`secret_${id}`) as HTMLDivElement | HTMLInputElement;\n if (typeof id === 'string' && id !== '') {\n apiGetBase<APISecret>(withBasePath(`/api/plugins/secrets/secrets/${id}/`)).then(data => {\n if (!hasError(data)) {\n const { plaintext } = data;\n // `plaintext` is the plain text value of the secret. If it is null, it has not been\n // decrypted, likely due to a mission session key.\n\n if (target !== null && plaintext !== null) {\n // If `plaintext` is not null, we have the decrypted value. Set the target element's\n // inner text to the decrypted value and toggle copy/lock button visibility.\n if (isInputElement(target)) {\n target.value = plaintext;\n } else {\n target.innerText = plaintext;\n }\n\n toggleSecretButtons(id, 'unlock');\n } else {\n // Otherwise, we do _not_ have the decrypted value and need to prompt the user for\n // their private RSA key, in order to get a session key. The session key is then sent\n // as a cookie in future requests.\n privateKeyModal.show();\n }\n } else {\n if (data.error.toLowerCase().includes('invalid session key')) {\n // If, for some reason, a request was made but resulted in an API error that complains\n // of a missing session key, prompt the user for their session key.\n privateKeyModal.show();\n } else {\n // If we received an API error but it doesn't contain 'invalid session key', show the\n // user an error message.\n const toast = createToast('danger', 'Error', data.error);\n toast.show();\n }\n }\n });\n }\n }\n\n /**\n * Lock a secret and toggle visibility of the unlock button.\n * @param id Secret ID\n */\n function lock(id: string | null) {\n if (typeof id === 'string' && id !== '') {\n const target = document.getElementById(`secret_${id}`) as HTMLDivElement | HTMLInputElement;\n\n // Obscure the inner text of the secret element.\n if (isInputElement(target)) {\n target.value = '********';\n } else {\n target.innerText = '********';\n }\n\n // Toggle visibility of the copy/lock/unlock buttons.\n toggleSecretButtons(id, 'lock');\n }\n }\n\n for (const element of document.querySelectorAll<HTMLButtonElement>('button.unlock-secret')) {\n element.addEventListener('click', () => unlock(element.getAttribute('secret-id')));\n }\n for (const element of document.querySelectorAll<HTMLButtonElement>('button.lock-secret')) {\n element.addEventListener('click', () => lock(element.getAttribute('secret-id')));\n }\n}\n\n/**\n * Request a session key from the API.\n * @param privateKey RSA Private Key (valid JSON string)\n */\nfunction requestSessionKey(privateKey: string) {\n apiPostForm(withBasePath('/api/plugins/secrets/session-keys/'), {\n private_key: privateKey,\n preserve_key: true,\n }).then(res => {\n if (!hasError(res)) {\n // If the session key has been added from the user key page, reload the page.\n if (window.location.pathname === withBasePath('/plugins/secrets/user-key/')) {\n window.location.reload();\n } else {\n // If the response received was not an error, show the user a success message.\n const toast = createToast('success', 'Session Key Received', 'You may now unlock secrets.');\n window.location.reload();\n toast.show();\n }\n } else {\n // Otherwise, show the user an error message.\n let message = res.error;\n if (isApiError(res)) {\n // If the error received was a standard API error containing a Python exception message,\n // append it to the error.\n message += `\\n${res.exception}`;\n }\n const toast = createToast('danger', 'Failed to Retrieve Session Key', message);\n toast.show();\n }\n });\n}\n\n/**\n * Initialize Request Session Key Elements.\n */\nfunction initGetSessionKey() {\n for (const element of document.querySelectorAll<HTMLButtonElement>('#request_session_key')) {\n /**\n * Send the user's input private key to the API to get a session key, which will be stored as\n * a cookie for future requests.\n */\n function handleClick() {\n for (const pk of document.querySelectorAll<HTMLTextAreaElement>('#user_privkey')) {\n requestSessionKey(pk.value);\n // Clear the private key form field value.\n pk.value = '';\n }\n }\n element.addEventListener('click', handleClick);\n }\n}\n\n/**\n * Initialize Secret Edit Form Handler.\n */\nfunction initSecretsEdit() {\n const privateKeyModal = new window.Modal('#privkey_modal');\n\n /**\n * Check the cookie store for a `netbox_secrets_sessionid`. If not present, prompt the user to submit their\n * private key.\n */\n function handleSubmit(event: Event): void {\n if (document.cookie.indexOf('netbox_secrets_sessionid') === -1) {\n event.preventDefault();\n privateKeyModal.show();\n }\n }\n\n for (const element of document.querySelectorAll<HTMLInputElement>('.requires-session-key')) {\n const form = element.closest<HTMLFormElement>('form');\n if (form !== null) {\n form.addEventListener('submit', handleSubmit);\n }\n }\n}\n\nexport function initSecrets() {\n for (const func of [initGenerateKeyPair, initLockUnlock, initGetSessionKey, initSecretsEdit]) {\n func();\n }\n}\n", "import { initSecrets } from './secrets';\n\nif (document.readyState !== 'loading') {\n initSecrets();\n} else {\n document.addEventListener('DOMContentLoaded', initSecrets);\n}\n"],
|
|
5
|
+
"mappings": "mzBAiGAA,EAAA,MAAAC,E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,SAAS,OAAO,EACvB4B,EAAM,KAAK,CACb,CAYJ,CAAC,CACH,CAKA,SAASC,IAAoB,CAC3B,QAAWzC,KAAW,SAAS,iBAAoC,sBAAsB,EAAG,CAK1F,IAAS0C,EAAT,UAAuB,CACrB,QAAWC,KAAM,SAAS,iBAAsC,eAAe,EAC7ET,EAAkBS,EAAG,KAAK,EAE1BA,EAAG,MAAQ,EAEf,EANS,IAAAD,IAOT1C,EAAQ,iBAAiB,QAAS0C,CAAW,CAC/C,CACF,CAKA,SAASE,IAAkB,CACzB,IAAMhB,EAAkB,IAAI,OAAO,MAAM,gBAAgB,EAMzD,SAASiB,EAAaC,EAAoB,CACpC,SAAS,OAAO,QAAQ,0BAA0B,IAAM,KAC1DA,EAAM,eAAe,EACrBlB,EAAgB,KAAK,EAEzB,CAEA,QAAW5B,KAAW,SAAS,iBAAmC,uBAAuB,EAAG,CAC1F,IAAM+C,EAAO/C,EAAQ,QAAyB,MAAM,EAChD+C,IAAS,MACXA,EAAK,iBAAiB,SAAUF,CAAY,CAEhD,CACF,CAEO,SAASG,GAAc,CAC5B,QAAWC,IAAQ,CAAClD,EAAqB4B,EAAgBc,GAAmBG,EAAe,EACzFK,EAAK,CAET,CC/QI,SAAS,aAAe,UAC1BC,EAAY,EAEZ,SAAS,iBAAiB,mBAAoBA,CAAW",
|
|
6
|
+
"names": ["exports", "parse", "serialize", "cookieNameRegExp", "cookieValueRegExp", "domainValueRegExp", "pathValueRegExp", "__toString", "NullObject", "C", "str", "options", "obj", "len", "dec", "decode", "index", "eqIdx", "colonIdx", "endIdx", "keyStartIdx", "startIndex", "keyEndIdx", "endIndex", "key", "valStartIdx", "valEndIdx", "value", "max", "code", "min", "name", "val", "enc", "isDate", "e", "createToast", "level", "title", "message", "extra", "iconName", "container", "main", "header", "icon", "titleElement", "button", "body", "extraElement", "import_cookie", "isApiError", "data", "hasError", "isInputElement", "element", "getCsrfToken", "csrfToken", "Cookie", "apiRequest", "url", "method", "__async", "token", "headers", "body", "res", "contentType", "json", "apiPostForm", "apiGetBase", "withBasePath", "path", "pathname", "pluginsIdx", "apiIdx", "cutIdx", "initGenerateKeyPair", "element", "accept", "copyBtn", "exportBtn", "publicElem", "privateElem", "handleOpen", "elem", "apiGetBase", "withBasePath", "data", "hasError", "createToast", "priv", "pub", "handleAccept", "publicKeyField", "handleExport", "content", "blob", "a", "toggleSecretButtons", "id", "action", "unlockButton", "lockButton", "copyButton", "initLockUnlock", "privateKeyModal", "unlock", "target", "plaintext", "isInputElement", "lock", "requestSessionKey", "privateKey", "apiPostForm", "res", "message", "isApiError", "toast", "initGetSessionKey", "handleClick", "pk", "initSecretsEdit", "handleSubmit", "event", "form", "initSecrets", "func", "initSecrets"]
|
|
7
|
+
}
|
|
@@ -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:
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
<th>Name</th>
|
|
14
14
|
<th>Role</th>
|
|
15
15
|
<th>Secret</th>
|
|
16
|
-
<th
|
|
16
|
+
<th>Description</th>
|
|
17
|
+
<th class="text-end">Actions</th>
|
|
17
18
|
</tr>
|
|
18
19
|
{% for secret in secrets %}
|
|
19
20
|
<tr>
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
{% if secret.name %}{{ secret.name }}{% else %}(Not Set){% endif %}</a></td>
|
|
22
23
|
<td><a href="{{ secret.role.get_absolute_url }}">{{ secret.role }}</a></td>
|
|
23
24
|
<td class="font-monospace" id="secret_{{ secret.pk }}">********</td>
|
|
25
|
+
<td>{{ secret.description|placeholder }}</td>
|
|
24
26
|
<td class="text-end noprint">
|
|
25
27
|
{% include 'netbox_secrets/inc/secret_actions.html' with object=secret %}
|
|
26
28
|
</td>
|
|
@@ -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
|
#
|