Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Sep 12, 2024
1 parent 12c09a0 commit b6ab81b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
8 changes: 0 additions & 8 deletions src/main/java/io/supertokens/oauth/OAuthToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@ public static String reSignToken(AppIdentifier appIdentifier, Main main, String
JWTCreationException {
JsonObject payload = JWT.getPayloadWithoutVerifying(token).payload;

// move keys in ext to root
if (tokenType == TokenType.ACCESS_TOKEN && payload.has("ext")) {
JsonObject ext = payload.getAsJsonObject("ext");
for (Map.Entry<String, JsonElement> entry : ext.entrySet()) {
payload.add(entry.getKey(), entry.getValue());
}
payload.remove("ext");
}
payload.addProperty("iss", iss);
payload.addProperty("stt", tokenType.getValue());

Expand Down
12 changes: 3 additions & 9 deletions src/main/java/io/supertokens/oauth/Transformations.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,14 @@ private static String transformQueryParamsInURLFromHydra(String redirectTo) {
for (String param : queryParams) {
String[] keyValue = param.split("=");
if (keyValue.length > 1 && keyValue[1].startsWith("ory_")) {
String decodedValue = URLDecoder.decode(keyValue[1], StandardCharsets.UTF_8.name());
if (decodedValue.startsWith("ory_")) {
decodedValue = decodedValue.replaceFirst("ory_", "st_");
}
String encodedValue = URLEncoder.encode(decodedValue, StandardCharsets.UTF_8.name());
updatedQuery.append(keyValue[0]).append("=").append(encodedValue).append("&");
updatedQuery.append(keyValue[0]).append("=").append(keyValue[1].replaceFirst("ory_", "st_")).append("&");
} else {
updatedQuery.append(param).append("&");
}
}
redirectTo = url.getProtocol() + "://" + url.getHost() + ":" + url.getPort() + url.getPath() + "?"
+ updatedQuery.toString().trim();
} catch (MalformedURLException | UnsupportedEncodingException e) {
} catch (MalformedURLException e) {
throw new IllegalStateException(e);
}

Expand Down Expand Up @@ -177,10 +172,9 @@ public static Map<String, List<String>> transformResponseHeadersFromHydra(Main m

headers = new HashMap<>(headers); // make it modifyable

// Location transformation
final String LOCATION_HEADER_NAME = "Location";

if (headers.containsKey(LOCATION_HEADER_NAME)) {
// Transform url in Location header
String redirectTo = headers.get(LOCATION_HEADER_NAME).get(0);
redirectTo = transformRedirectUrlFromHydra(main, appIdentifier, redirectTo);
headers.put(LOCATION_HEADER_NAME, List.of(redirectTo));
Expand Down

0 comments on commit b6ab81b

Please sign in to comment.