Skip to main content

Middleware for Python Graphene to disable introspection

Project description

Graphene Middleware to Disable Introspection

This middleware for Python's Graphene library disables introspection queries, enhancing the security of your GraphQL API by preventing clients from discovering the schema.

Installation

To install the middleware, you can use pip:

pip install graphene-disable-introspection

Usage

To use the middleware in your Graphene project, you need to add it to your GraphQL schema.

Example

Python Usage

Import the middleware and add it to your schema.

from graphene_disable_introspection import DisableIntrospectionMiddleware

GraphqlView.as_view(middleware=[DisableIntrospectionMiddleware()])

Django Usage

Add the middleware to your Django settings. I recommend to add it to the top of the middleware list.

GRAPHENE = {
    ...
    "MIDDLEWARE": [
        "graphene_disable_introspection.DisableIntrospectionMiddleware",
        ...
    ],
}

Alternatively, you can deactivate Graphene introspection for the production system only.

if os.environ.get("APP_SETTINGS") == "production":
    GRAPHENE["MIDDLEWARE"].insert(0, "graphene_disable_introspection.DisableIntrospectionMiddleware")

License

This project is licensed under the GPL-3.0 License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graphene_disable_introspection-0.1.2.tar.gz (14.8 kB view details)

Uploaded Source

File details

Details for the file graphene_disable_introspection-0.1.2.tar.gz.

File metadata

File hashes

Hashes for graphene_disable_introspection-0.1.2.tar.gz
Algorithm Hash digest
SHA256 02b07b822b816abe660893c20e8293d1efdc9c9eeafc2c3286eed29b40575d5a
MD5 9ceaf03b234b5beddb807ef935c16de1
BLAKE2b-256 0b834f9dc99519b42d6bfe788b850123f1292f4f279a8b4c41cbc9b1f483cab8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page