Class GraphQLProtectionInterceptor
java.lang.Object
com.predic8.membrane.core.interceptor.AbstractInterceptor
com.predic8.membrane.core.graphql.GraphQLProtectionInterceptor
- All Implemented Interfaces:
Interceptor
- Description
- Check GraphQL-over-HTTP requests, enforcing several limits and/or restrictions. This effectively helps to reduce
the attack surface.
GraphQL Specification "October2021" is used. (But GraphQL only covers formulation of Documents/Queries.)
GraphQL-over-HTTP, which specifies how to submit GraphQL queries via HTTP, has not been released/finalized yet. We therefore use Version a1e6d8ca.
Only GraphQL documents conforming to the 'ExecutableDocument' of the grammar are allowed: This includes the usual 'query', 'mutation', 'subscription' and 'fragment's.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.predic8.membrane.core.interceptor.Interceptor
Interceptor.Flow -
Field Summary
Fields inherited from class com.predic8.membrane.core.interceptor.AbstractInterceptor
name, router -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintintinthandleRequest(Exchange exc) voidinit()Called after parsing is complete and this has been added to the object tree (whose root is Router).booleanvoidsetAllowedMethods(String allowedMethods) voidsetAllowExtensions(boolean allowExtensions) voidsetMaxDepth(int maxDepth) voidsetMaxMutations(int maxMutations) voidsetMaxRecursion(int maxRecursion) toString()Methods inherited from class com.predic8.membrane.core.interceptor.AbstractInterceptor
getDisplayName, getFlow, getHelpId, getMessage, getRouter, getRule, handleAbort, handleResponse, init, setDisplayName, setFlow
-
Constructor Details
-
GraphQLProtectionInterceptor
public GraphQLProtectionInterceptor()
-
-
Method Details
-
init
Description copied from class:AbstractInterceptorCalled after parsing is complete and this has been added to the object tree (whose root is Router).- Overrides:
initin classAbstractInterceptor- Throws:
Exception
-
handleRequest
- Specified by:
handleRequestin interfaceInterceptor- Overrides:
handleRequestin classAbstractInterceptor- Throws:
Exception
-
setMaxMutations
public void setMaxMutations(int maxMutations) - Default
- 5
- Description
- Limit how many mutations can be defined in a document query.
- Example
- 2
-
getMaxMutations
public int getMaxMutations() -
setAllowExtensions
public void setAllowExtensions(boolean allowExtensions) - Default
- false
- Description
- Whether to allow GraphQL "extensions".
- Example
- true
-
isAllowExtensions
public boolean isAllowExtensions() -
getAllowedMethods
-
setAllowedMethods
- Default
- GET, POST
- Description
- Which HTTP methods to allow. Note that per the GraphQL-over-HTTP spec, you need POST for mutation or subscription queries.
-
getMaxRecursion
public int getMaxRecursion() -
setMaxRecursion
public void setMaxRecursion(int maxRecursion) - Default
- 3
- Description
- How deep recursive parts of queries can be nested.
-
getMaxDepth
public int getMaxDepth() -
setMaxDepth
public void setMaxDepth(int maxDepth) - Default
- 7
- Description
- How deep queries can be nested.
-
toString
-
getShortDescription
- Specified by:
getShortDescriptionin interfaceInterceptor- Overrides:
getShortDescriptionin classAbstractInterceptor
-
getLongDescription
- Specified by:
getLongDescriptionin interfaceInterceptor- Overrides:
getLongDescriptionin classAbstractInterceptor
-