Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable introspection #127

Open
jhonnyperezm opened this issue Jan 9, 2023 · 1 comment
Open

Disable introspection #127

jhonnyperezm opened this issue Jan 9, 2023 · 1 comment

Comments

@jhonnyperezm
Copy link

There is some way to disable introspection, I can't find the way and in production it has security problems.

@saurabhgour
Copy link

Following customization worked for me for 'io.leangen.graphql:graphql-spqr-spring-boot-starter:0.0.5'
Hope this helps!

@Configuration
public class GraphqlSchemaConfig {

    @Bean
    public BeanPostProcessor graphqlSchemaCustomizer() {
        return new BeanPostProcessor() {
            @Override
            public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
                if (bean instanceof GraphQLSchemaGenerator) {
                    GraphQLSchemaGenerator generator = (GraphQLSchemaGenerator) bean;
                    generator.withSchemaProcessors((schemaBuilder, buildContext) -> {
                        schemaBuilder.fieldVisibility(NoIntrospectionGraphqlFieldVisibility.NO_INTROSPECTION_FIELD_VISIBILITY);
                        return schemaBuilder;
                    });
                    return generator;
                }
                return bean;
            }
        };
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants