Skip to content

Commit

Permalink
fix(graphql): disable introspection endpoint on production
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabauke committed Dec 22, 2023
1 parent 94271b9 commit 6bd1d5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions caluma/schema.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from functools import partial

import graphene
from django.conf import settings
from graphene.relay import Node
from graphene.validation import DisableIntrospection
from graphene_django.converter import convert_django_field, convert_field_to_string
from graphene_django.debug import DjangoDebug
from graphql import validate
from localized_fields.fields import LocalizedField

from .caluma_analytics import schema as analytics_schema
Expand Down Expand Up @@ -93,3 +97,10 @@ class Query(*query_inherit_from):
# TODO: define what app exposes what types
types=types,
)

if settings.DISABLE_INTROSPECTION:
validate = partial(validate, rules=(DisableIntrospection,))

validation_errors = validate(
schema=schema.graphql_schema,
)
1 change: 1 addition & 0 deletions caluma/settings/caluma.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def default(default_dev=env.NOTSET, default_prod=env.NOTSET):
"MIDDLEWARE": [],
"RELAY_CONNECTION_MAX_LIMIT": None,
}
DISABLE_INTROSPECTION = env.bool("DISABLE_INTROSPECTION", default=default(False, True))

# OpenID connect

Expand Down

0 comments on commit 6bd1d5a

Please sign in to comment.