From 3e0113c0a94c22bdd1ead91f923b1ce4a356953e Mon Sep 17 00:00:00 2001 From: Jayendra Date: Tue, 2 Jun 2020 12:30:56 +0530 Subject: [PATCH] Updated grpc interceptor for desktop request electron v5 --- .../AuthenticationServiceInterceptor.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/biz/nynja/auth/grpc/services/interceptors/AuthenticationServiceInterceptor.java b/src/main/java/biz/nynja/auth/grpc/services/interceptors/AuthenticationServiceInterceptor.java index 436959a..97a9716 100644 --- a/src/main/java/biz/nynja/auth/grpc/services/interceptors/AuthenticationServiceInterceptor.java +++ b/src/main/java/biz/nynja/auth/grpc/services/interceptors/AuthenticationServiceInterceptor.java @@ -29,13 +29,27 @@ public class AuthenticationServiceInterceptor implements ServerInterceptor { /** * @Date 27-May-2020 * @UpdatedBy Jayendra - * Checking if the request is made by Desktop application + * Checking if the request is made by Desktop application to update redirect URI for facebook and google + * */ if (metadata.get(Metadata.Key.of("user-agent", ASCII_STRING_MARSHALLER)).contains("Electron") || metadata.get(Metadata.Key.of("user-agent", ASCII_STRING_MARSHALLER)).contains("electron") ) { - ctx = Context.current().withValues(AuthenticationServiceConstants.ACCESS_TOKEN_CTX, tokenParts[1], AuthenticationServiceConstants.DESKTOP_APP_REQUEST_CTX, DesktopAppRequestConstants.YES); + /** + * Special condition If request is from Electron/5.0.... then we will mark DesktopRequest to be No + * Since, we don't want to change redirect URI to desktop redirectURI for google and facebook in this case. + */ + if (metadata.get(Metadata.Key.of("user-agent", ASCII_STRING_MARSHALLER)).contains("Electron/5") || + metadata.get(Metadata.Key.of("user-agent", ASCII_STRING_MARSHALLER)).contains("electron/5") + ) { + + ctx = Context.current().withValues(AuthenticationServiceConstants.ACCESS_TOKEN_CTX, tokenParts[1], AuthenticationServiceConstants.DESKTOP_APP_REQUEST_CTX, DesktopAppRequestConstants.NO); + + } else { + + ctx = Context.current().withValues(AuthenticationServiceConstants.ACCESS_TOKEN_CTX, tokenParts[1], AuthenticationServiceConstants.DESKTOP_APP_REQUEST_CTX, DesktopAppRequestConstants.YES); + } } else { -- GitLab