Skip to content

Commit

Permalink
Merge pull request #163 from Onemind-Services-LLC/dev
Browse files Browse the repository at this point in the history
Release v2.1.0
  • Loading branch information
abhi1693 authored Oct 18, 2024
2 parents f6f7415 + 5b4a088 commit c17c1ae
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 31 deletions.
29 changes: 28 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Changelog

## [Unreleased](https://github.com/Onemind-Services-LLC/netbox-secrets/tree/HEAD)

[Full Changelog](https://github.com/Onemind-Services-LLC/netbox-secrets/compare/v2.0.3...HEAD)

**Closed issues:**

- \[Bug\]: ImproperlyConfigured: Application labels aren't unique, duplicates [\#160](https://github.com/Onemind-Services-LLC/netbox-secrets/issues/160)
- \[maintenance\]: NetBox Community v4.1.0 [\#159](https://github.com/Onemind-Services-LLC/netbox-secrets/issues/159)
- \[Bug\]: error deleting users [\#151](https://github.com/Onemind-Services-LLC/netbox-secrets/issues/151)
- \[Bug\]: Cannot post on '/api/plugins/secrets/user-keys/' endpoint [\#89](https://github.com/Onemind-Services-LLC/netbox-secrets/issues/89)

**Merged pull requests:**

- Bump micromatch from 4.0.5 to 4.0.8 in /netbox\_secrets/project-static in the npm\_and\_yarn group across 1 directory [\#155](https://github.com/Onemind-Services-LLC/netbox-secrets/pull/155) ([dependabot[bot]](https://github.com/apps/dependabot))

## [v2.0.3](https://github.com/Onemind-Services-LLC/netbox-secrets/tree/v2.0.3) (2024-07-26)

[Full Changelog](https://github.com/Onemind-Services-LLC/netbox-secrets/compare/v2.0.2...v2.0.3)

**Closed issues:**

- \[Bug\]: Unable to access netbox api schema with plugin enabled [\#148](https://github.com/Onemind-Services-LLC/netbox-secrets/issues/148)

**Merged pull requests:**

- Release v2.0.3 [\#150](https://github.com/Onemind-Services-LLC/netbox-secrets/pull/150) ([abhi1693](https://github.com/abhi1693))
- Fixed failing schema [\#149](https://github.com/Onemind-Services-LLC/netbox-secrets/pull/149) ([abhi1693](https://github.com/abhi1693))

## [v2.0.2](https://github.com/Onemind-Services-LLC/netbox-secrets/tree/v2.0.2) (2024-07-20)

[Full Changelog](https://github.com/Onemind-Services-LLC/netbox-secrets/compare/v2.0.1...v2.0.2)
Expand Down Expand Up @@ -69,7 +97,6 @@
**Closed issues:**

- \[Docs\]: top\_level\_menu is not documented [\#122](https://github.com/Onemind-Services-LLC/netbox-secrets/issues/122)
- \[Bug\]: ENHANCE YOUR SECRET MANAGEMENT... description is too long and unusable [\#121](https://github.com/Onemind-Services-LLC/netbox-secrets/issues/121)
- \[Bug\]: Unable to import plugin netbox-secrets: Module not found. [\#120](https://github.com/Onemind-Services-LLC/netbox-secrets/issues/120)

**Merged pull requests:**
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ARG NETBOX_VARIANT=v4.0
ARG NETBOX_VARIANT=v4.1

FROM netboxcommunity/netbox:${NETBOX_VARIANT}

RUN mkdir -pv /plugins/netbox-secrets
COPY . /plugins/netbox-secrets

RUN /opt/netbox/venv/bin/python3 /plugins/netbox-secrets/setup.py develop
RUN cp -rf /plugins/netbox-secrets/netbox_secrets/ /opt/netbox/venv/lib/python3.11/site-packages/netbox_secrets
RUN cp -rf /plugins/netbox-secrets/netbox_secrets/ /opt/netbox/venv/lib/python3.12/site-packages/netbox_secrets
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and stability.
| 3.6.x | 1.9.x |
| 3.7.x | 1.10.x |
| 4.0.x | 2.0.x |
| 4.1.x | 2.1.x |

# Installation

Expand Down
4 changes: 2 additions & 2 deletions netbox_secrets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class NetBoxSecrets(PluginConfig):
author = metadata.get('Author')
author_email = metadata.get('Author-email')
base_url = 'secrets'
min_version = '4.0.0'
max_version = '4.0.99'
min_version = '4.1.0'
max_version = '4.1.99'
required_settings = []
default_settings = {
'apps': ['dcim.device', 'virtualization.virtualmachine'],
Expand Down
1 change: 0 additions & 1 deletion netbox_secrets/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from ..constants import SECRET_ASSIGNABLE_MODELS
from ..models import *


__all__ = [
'SecretRoleSerializer',
'SecretSerializer',
Expand Down
16 changes: 10 additions & 6 deletions netbox_secrets/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
from django.conf import settings
from django.http import HttpResponseBadRequest
from drf_spectacular import utils as drf_utils
from netbox.api.viewsets import BaseViewSet, NetBoxModelViewSet, mixins
from rest_framework import mixins as drf_mixins, status
from rest_framework.exceptions import ValidationError
from rest_framework.exceptions import PermissionDenied, ValidationError
from rest_framework.parsers import FormParser, JSONParser, MultiPartParser
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.routers import APIRootView
from rest_framework.viewsets import ReadOnlyModelViewSet, ViewSet

from netbox.api.viewsets import BaseViewSet, NetBoxModelViewSet, mixins
from utilities.query import count_related

from . import serializers
from .. import constants, exceptions, filtersets, models

Expand Down Expand Up @@ -347,9 +347,9 @@ def create(self, request):

class ActivateUserKeyViewSet(ViewSet):
"""
This endpoint expects a private key and a list of user keys to be activated.
The private key is used to derive a master key, which is then used to activate
each user key provided.
This endpoint expects a private key and a list of user keys to be activated.
The private key is used to derive a master key, which is then used to activate
each user key provided.
"""

permission_classes = [IsAuthenticated]
Expand Down Expand Up @@ -380,6 +380,10 @@ class ActivateUserKeyViewSet(ViewSet):
},
)
def create(self, request):
# Check if the user has the permission to change UserKey
if not request.user.has_perm('netbox_secrets.change_userkey'):
raise PermissionDenied("You do not have permission to active User Keys.")

serializer = self.serializer_class(data=request.data)
if not serializer.is_valid():
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Expand Down
4 changes: 2 additions & 2 deletions netbox_secrets/graphql/filters.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import strawberry_django
from netbox.graphql.filter_mixins import autotype_decorator, BaseFilterMixin

from ..models import *
from netbox.graphql.filter_mixins import BaseFilterMixin, autotype_decorator
from ..filtersets import *
from ..models import *

__all__ = [
'SecretFilter',
Expand Down
13 changes: 3 additions & 10 deletions netbox_secrets/graphql/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,13 @@
import strawberry
import strawberry_django

from ..models import *
from .types import *


@strawberry.type
@strawberry.type(name='Query')
class NetboxSecretsQuery:
@strawberry.field
def secret_roles(self, id: int) -> List[SecretRoleType]:
return SecretRole.objects.get(pk=id)

secret_roles: List[SecretRoleType] = strawberry_django.field()
secret_roles_list: List[SecretRoleType] = strawberry_django.field()

@strawberry.field
def secrets(self, id: int) -> List[SecretType]:
return Secret.objects.get(pk=id)

secrets: List[SecretType] = strawberry_django.field()
secrets_list: List[SecretType] = strawberry_django.field()
2 changes: 1 addition & 1 deletion netbox_secrets/migrations/0004_populate_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def update_objectchanges(apps, schema_editor):
"""
Update the ObjectChange records to reflect the new model name.
"""
ObjectChange = apps.get_model('extras', 'ObjectChange')
ObjectChange = apps.get_model('core', 'ObjectChange')
ContentType = apps.get_model('contenttypes', 'ContentType')

try:
Expand Down
8 changes: 5 additions & 3 deletions netbox_secrets/templates/netbox_secrets/userkey_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
{% endif %}
</a>
{% endif %}
<a href="{% url 'plugins:netbox_secrets:userkey_activate'%}" type="button" class="btn btn-primary">
<i class="mdi mdi-auto-fix"></i> Activate User Key
</a>
{% if perms.netbox_secrets.change_userkey %}
<a href="{% url 'plugins:netbox_secrets:userkey_activate' %}" type="button" class="btn btn-primary">
<i class="mdi mdi-auto-fix"></i> Activate User Key
</a>
{% endif %}
</div>
{% endblock controls %}
8 changes: 6 additions & 2 deletions netbox_secrets/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import PermissionDenied
from django.db import transaction
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils.translation import gettext as _
from django.views.generic.base import View
from netbox_secrets.models import UserKey

from extras.signals import clear_events
from core.signals import clear_events
from netbox.views import generic
from netbox_secrets.models import UserKey
from tenancy.views import ObjectContactsView
from utilities.exceptions import AbortRequest, PermissionsViolation
from utilities.forms import restrict_form_fields
Expand Down Expand Up @@ -385,6 +386,9 @@ def get(self, request):
)

def post(self, request):
if not request.user.has_perm('netbox_secrets.change_userkey'):
raise PermissionDenied("You do not have permission to activate User Keys.")

if not self.userkey or not self.userkey.is_active():
messages.error(request, "You do not have an active User Key.")
return redirect('plugins:netbox_secrets:userkey_activate')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name='netbox-secrets',
version='2.0.3',
version='2.1.0',
description=description,
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit c17c1ae

Please sign in to comment.