1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Introduce IPNetworkSerializer to serialize allowed token IPs

This commit is contained in:
jeremystretch
2022-06-22 21:51:43 -04:00
parent e3b7bba84f
commit 3c15419bd0
6 changed files with 29 additions and 11 deletions

View File

@@ -4,12 +4,12 @@ import os
from django.contrib.auth.models import Group, User
from django.contrib.contenttypes.models import ContentType
from django.contrib.postgres.fields import ArrayField
from django.core.exceptions import ValidationError
from django.core.validators import MinLengthValidator
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils import timezone
from netaddr import IPNetwork
from ipam.fields import IPNetworkField
from netbox.config import get_config
@@ -17,8 +17,6 @@ from utilities.querysets import RestrictedQuerySet
from utilities.utils import flatten_dict
from .constants import *
import ipaddress
__all__ = (
'ObjectPermission',
'Token',
@@ -259,7 +257,7 @@ class Token(models.Model):
return True
for ip_network in self.allowed_ips:
if client_ip in ipaddress.ip_network(ip_network):
if client_ip in IPNetwork(ip_network):
return True
return False