Fixes: #16292 - Properly restrict GraphQL queries for querys with pk set (#17244)

* Fixes: #16292 - Properly restrict GraphQL queries for querys with pk set

* Update netbox/netbox/settings.py

* Apply schema adaptations across all apps

* Extend GraphQL API tests

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
Daniel Sheppard
2024-08-28 11:23:25 -05:00
committed by GitHub
parent 765a12378d
commit bc97b12bd2
14 changed files with 171 additions and 352 deletions

View File

@@ -3,58 +3,37 @@ from typing import List
import strawberry
import strawberry_django
from vpn import models
from .types import *
@strawberry.type
@strawberry.type(name="Query")
class VPNQuery:
@strawberry.field
def ike_policy(self, id: int) -> IKEPolicyType:
return models.IKEPolicy.objects.get(pk=id)
ike_policy: IKEPolicyType = strawberry_django.field()
ike_policy_list: List[IKEPolicyType] = strawberry_django.field()
@strawberry.field
def ike_proposal(self, id: int) -> IKEProposalType:
return models.IKEProposal.objects.get(pk=id)
ike_proposal: IKEProposalType = strawberry_django.field()
ike_proposal_list: List[IKEProposalType] = strawberry_django.field()
@strawberry.field
def ipsec_policy(self, id: int) -> IPSecPolicyType:
return models.IPSecPolicy.objects.get(pk=id)
ipsec_policy: IPSecPolicyType = strawberry_django.field()
ipsec_policy_list: List[IPSecPolicyType] = strawberry_django.field()
@strawberry.field
def ipsec_profile(self, id: int) -> IPSecProfileType:
return models.IPSecProfile.objects.get(pk=id)
ipsec_profile: IPSecProfileType = strawberry_django.field()
ipsec_profile_list: List[IPSecProfileType] = strawberry_django.field()
@strawberry.field
def ipsec_proposal(self, id: int) -> IPSecProposalType:
return models.IPSecProposal.objects.get(pk=id)
ipsec_proposal: IPSecProposalType = strawberry_django.field()
ipsec_proposal_list: List[IPSecProposalType] = strawberry_django.field()
@strawberry.field
def l2vpn(self, id: int) -> L2VPNType:
return models.L2VPN.objects.get(pk=id)
l2vpn: L2VPNType = strawberry_django.field()
l2vpn_list: List[L2VPNType] = strawberry_django.field()
@strawberry.field
def l2vpn_termination(self, id: int) -> L2VPNTerminationType:
return models.L2VPNTermination.objects.get(pk=id)
l2vpn_termination: L2VPNTerminationType = strawberry_django.field()
l2vpn_termination_list: List[L2VPNTerminationType] = strawberry_django.field()
@strawberry.field
def tunnel(self, id: int) -> TunnelType:
return models.Tunnel.objects.get(pk=id)
tunnel: TunnelType = strawberry_django.field()
tunnel_list: List[TunnelType] = strawberry_django.field()
@strawberry.field
def tunnel_group(self, id: int) -> TunnelGroupType:
return models.TunnelGroup.objects.get(pk=id)
tunnel_group: TunnelGroupType = strawberry_django.field()
tunnel_group_list: List[TunnelGroupType] = strawberry_django.field()
@strawberry.field
def tunnel_termination(self, id: int) -> TunnelTerminationType:
return models.TunnelTermination.objects.get(pk=id)
tunnel_termination: TunnelTerminationType = strawberry_django.field()
tunnel_termination_list: List[TunnelTerminationType] = strawberry_django.field()