Skip to content

Commit

Permalink
Merge pull request #3599 from mevan-karu/pat_impl_choreo
Browse files Browse the repository at this point in the history
Improve x-forwarded-authorization header setting logic
  • Loading branch information
renuka-fernando authored Oct 4, 2024
2 parents 227525e + 434b925 commit 2208e9e
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ private String exchangeJWTForPAT(RequestContext requestContext, String pat) thro
if (log.isDebugEnabled()) {
log.debug("Token retrieved from the cache. Token: " + FilterUtils.getMaskedToken(pat));
}
setXForwardedAuthorizationHeader(requestContext, (String) cachedJWT);
return (String) cachedJWT;
}
Optional<String> jwt = APIKeyUtils.exchangePATToJWT(keyHash);
Expand All @@ -828,10 +829,14 @@ private String exchangeJWTForPAT(RequestContext requestContext, String pat) thro
}
CacheProvider.getGatewayAPIKeyJWTCache().put(keyHash, jwt.get());
// Add jwt to x-forwarded-authorization header.
requestContext.addOrModifyHeaders("x-forwarded-authorization", jwt.get());
setXForwardedAuthorizationHeader(requestContext, jwt.get());
return jwt.get();
}

private void setXForwardedAuthorizationHeader(RequestContext requestContext, String jwt) {
requestContext.addOrModifyHeaders("x-forwarded-authorization", String.format("Bearer %s", jwt));
}

public String extractJWTInWSProtocolHeader(RequestContext requestContext) {
String protocolHeader = requestContext.getHeaders().get(
HttpConstants.WEBSOCKET_PROTOCOL_HEADER);
Expand Down

0 comments on commit 2208e9e

Please sign in to comment.