graphene-disable-introspection - 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-introspection-middleware
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 recommand to add it to the top of the middleware list.
GRAPHENE = {
...
"MIDDLEWARE": [
"graphene_introspection_middleware.DisableIntrospectionMiddleware",
...
],
}
Alternatively, you can deactivate Graphene Introspection for the Production System only.
if os.environ.get("APP_SETTINGS") == "production":
GRAPHENE["MIDDLEWARE"].insert(0, "graphene_introspection_middleware.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
File details
Details for the file graphene_disable_introspection-0.1.1.tar.gz
.
File metadata
- Download URL: graphene_disable_introspection-0.1.1.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfda6da712eecf5c55efbdd69f619aea28a4cad7294b6bcb67899a16a22807e2 |
|
MD5 | 3369b8bf092eaade54736d1e121ec0ef |
|
BLAKE2b-256 | 850fdb24ad18d6ae4951868c43a061c7eea8c4fa4c5c9b8fd729fa9cf33bd2bc |