Replies: 2 comments 3 replies
-
The code you've posted looks like a JAX-RS filter. You're dealing with GraphQL, not JAX-RS here, that's why it's not called. If you're using Quarkus, you can use Quarkus's standard declarative security mechanisms, like it's described for example here: https://quarkus.io/guides/security-authorize-web-endpoints-reference - if you apply it on the |
Beta Was this translation helpful? Give feedback.
3 replies
-
I came up with this solution: @ApplicationScoped
public class GraphQLKeyFilter {
private final String graphqlPath;
@Inject
public GraphQLKeyFilter(@ConfigProperty(name = "quarkus.smallrye-graphql.root-path") String graphqlPath) {
this.graphqlPath = graphqlPath;
}
public void init(@Observes Router router, Vertx vertx) {
router.route("/" + this.graphqlPath)
.order(-900)
.handler(routingContext -> {
String apiKey = routingContext.request()
.getHeader("X-API-Key");
boolean isValid = apiKey == null
if (!isValid) {
routingContext.response()
.setStatusCode(Response.Status.UNAUTHORIZED.getStatusCode())
.end();
return;
}
routingContext.next();
});
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to secure the server with http headers. So i created a RequestFilter:
But this isn't called. How to secure the server?
Beta Was this translation helpful? Give feedback.
All reactions