Skip to content

Commit

Permalink
Merge pull request #3593 from Thushani-Jayasekera/websocket-mgw
Browse files Browse the repository at this point in the history
[choreo] set the value for auth header from sec-protocol header
  • Loading branch information
renuka-fernando authored Sep 30, 2024
2 parents 5eb62b5 + 3baf956 commit faaf4ac
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ public AuthenticationContext authenticate(RequestContext requestContext) throws
}
String jwtToken = retrieveAuthHeaderValue(requestContext);

if (jwtToken == null
&& requestContext.getMatchedAPI().getApiType().equalsIgnoreCase(APIConstants.ApiType.WEB_SOCKET)) {
String tokenValue = extractJWTInWSProtocolHeader(requestContext);
if (StringUtils.isNotEmpty(tokenValue)) {
jwtToken = JWTConstants.BEARER + " " + tokenValue;
}
}

if (jwtToken == null || !jwtToken.toLowerCase().contains(JWTConstants.BEARER)) {
throw new APISecurityException(APIConstants.StatusCodes.UNAUTHENTICATED.getCode(),
APISecurityConstants.API_AUTH_MISSING_CREDENTIALS, "Missing Credentials");
Expand Down

0 comments on commit faaf4ac

Please sign in to comment.