Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change keyword used in auth #3609

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading