From 4aed51438ae55931348f6ffe01a0c41f9e9ba8cc Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Tue, 22 Jun 2021 15:32:38 -0500 Subject: [PATCH] SecurityDataFetcherExceptionResolver handles AuthenticationException This is unlikely to happen as authentication happens prior to reaching the GraphQL APIs. However, a user may decide to implement security within GraphQL as it is possible to do through a Spring Controller. --- .../sample/graphql/SecurityDataFetcherExceptionResolver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/webflux-security/src/main/java/io/spring/sample/graphql/SecurityDataFetcherExceptionResolver.java b/samples/webflux-security/src/main/java/io/spring/sample/graphql/SecurityDataFetcherExceptionResolver.java index 28d2f7b1..e9ad6115 100644 --- a/samples/webflux-security/src/main/java/io/spring/sample/graphql/SecurityDataFetcherExceptionResolver.java +++ b/samples/webflux-security/src/main/java/io/spring/sample/graphql/SecurityDataFetcherExceptionResolver.java @@ -28,7 +28,7 @@ public class SecurityDataFetcherExceptionResolver implements DataFetcherExceptio @Override public Mono> resolveException(Throwable exception, DataFetchingEnvironment environment) { if (exception instanceof AuthenticationException) { - // TOTO: should this be empty ? + return unauthorized(environment); } if (exception instanceof AccessDeniedException) { return ReactiveSecurityContextHolder.getContext()