Skip to content

Commit

Permalink
Merge pull request #3609 from Thushani-Jayasekera/choreo
Browse files Browse the repository at this point in the history
Change keyword used in auth
  • Loading branch information
renuka-fernando authored Oct 26, 2024
2 parents f41aaa8 + d0c4d2e commit f2d432c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public class Constants {
public static final String DEFAULT_CON_FACTORY_JNDI_NAME = "TopicConnectionFactory";

// keyword to identify API-Key sent in sec-websocket-protocol header
public static final String WS_API_KEY_IDENTIFIER = "choreo-internal-API-Key";
public static final String WS_OAUTH2_KEY_IDENTIFIED = "choreo-oauth2-key";
public static final String WS_API_KEY_IDENTIFIER = "choreo-api-key";
public static final String WS_OAUTH2_KEY_IDENTIFIED = "choreo-oauth2-token";

// Modes for the temporary console test headers.
public static final String TEMP_CONSOLE_TEST_HEADERS_MONITOR_MODE = "monitor";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public AuthenticationContext authenticate(RequestContext requestContext) throws

// Since the Choreo console/ Devportal sends the token in the
// sec-websocket-protocol header, regardless of security enabled or not, we need
// to add the "choreo-internal-API-Key" to the sec-websocket-protocol response
// to add the "choreo-api-key" to the sec-websocket-protocol response
// header.
if (requestContext.getMatchedAPI().getApiType().equalsIgnoreCase(APIConstants.ApiType.WEB_SOCKET)) {
String secProtocolHeader = requestContext.getHeaders().get(HttpConstants.WEBSOCKET_PROTOCOL_HEADER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public void extractInternalKeyInWSProtocolHeaderTest() {
String secWebsocketProtocolHeader = "sec-websocket-protocol";

// Test case to test for an Upgrade request sent from the choreo console
// The token will be set to the sec-websocket-protocol header with choreo-internal-API-Key keyword
// the value after choreo-internal-API-Key will be the token
// The token will be set to the sec-websocket-protocol header with choreo-api-key keyword
// the value after choreo-api-key will be the token
RequestContext.Builder builder = new RequestContext.Builder("/pets");
builder.matchedAPI(new APIConfig.Builder("Petstore")
.basePath("/choreo")
Expand All @@ -76,7 +76,7 @@ public void extractInternalKeyInWSProtocolHeaderTest() {
Map<String, String> headersMap = new HashMap<>();
headersMap.put(
secWebsocketProtocolHeader,
"choreo-internal-API-Key," + mockToken);
"choreo-api-key," + mockToken);
builder.headers(headersMap);
RequestContext requestContext = builder.build();
InternalAPIKeyAuthenticator internalAPIKeyAuthenticator = new InternalAPIKeyAuthenticator(securityParam);
Expand Down Expand Up @@ -128,7 +128,7 @@ public void getProtocolsToSetInRequestHeadersTest() {
Map<String, String> headersMap = new HashMap<>();
headersMap.put(
secWebsocketProtocolHeader,
"choreo-internal-API-Key, " + mockToken + ", " + "chat, bar");
"choreo-api-key, " + mockToken + ", " + "chat, bar");
builder.headers(headersMap);
RequestContext requestContext = builder.build();
InternalAPIKeyAuthenticator internalAPIKeyAuthenticator = new InternalAPIKeyAuthenticator(securityParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ public void extractJWTInWSProtocolHeaderTest() {

// Test case to test for an Upgrade request sent from the choreo console
// The token will be set to the sec-websocket-protocol header with
// choreo-oauth2-key keyword
// the value after choreo-oauth2-key will be the token
// choreo-oauth2-token keyword
// the value after choreo-oauth2-token will be the token
RequestContext.Builder builder = new RequestContext.Builder("/pets");
builder.matchedAPI(new APIConfig.Builder("Petstore")
.basePath("/choreo")
Expand All @@ -129,7 +129,7 @@ public void extractJWTInWSProtocolHeaderTest() {
Map<String, String> headersMap = new HashMap<>();
headersMap.put(
secWebsocketProtocolHeader,
"choreo-oauth2-key," + mockToken);
"choreo-oauth2-token," + mockToken);
builder.headers(headersMap);
RequestContext requestContext = builder.build();
JWTAuthenticator jwtAuthenticator = new JWTAuthenticator();
Expand Down

0 comments on commit f2d432c

Please sign in to comment.