forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d68580c
commit 7736fe5
Showing
7 changed files
with
117 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...ests/oidc-wiremock/src/main/java/io/quarkus/it/keycloak/BearerTenantsTokenCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package io.quarkus.it.keycloak; | ||
|
||
import jakarta.inject.Singleton; | ||
import jakarta.json.Json; | ||
import jakarta.json.JsonObject; | ||
|
||
import io.quarkus.arc.Unremovable; | ||
import io.quarkus.oidc.TenantFeature; | ||
import io.quarkus.oidc.TokenCustomizer; | ||
|
||
@Singleton | ||
@TenantFeature({ "bearer", "custombearer" }) | ||
@Unremovable | ||
public class BearerTenantsTokenCustomizer implements TokenCustomizer { | ||
|
||
volatile int rs256CountBearer; | ||
volatile int rs256CountCustomBearer; | ||
|
||
@Override | ||
public JsonObject customizeHeaders(JsonObject headers) { | ||
String customizeHeader = null; | ||
if (headers.containsKey("customize_bearer")) { | ||
customizeHeader = "customize_bearer"; | ||
} else if (headers.containsKey("customize_custombearer")) { | ||
customizeHeader = "customize_custombearer"; | ||
} | ||
if (customizeHeader == null) { | ||
return null; | ||
} | ||
String alg = headers.getString("alg"); | ||
if ("RS256".equals(alg)) { | ||
if ("customize_bearer".equals(customizeHeader)) { | ||
if (0 == rs256CountBearer++) { | ||
return null; | ||
} else { | ||
return Json.createObjectBuilder(headers).remove(customizeHeader).build(); | ||
} | ||
} else { | ||
if (0 == rs256CountCustomBearer++) { | ||
return null; | ||
} else { | ||
return Json.createObjectBuilder(headers).remove(customizeHeader).build(); | ||
} | ||
} | ||
} else if ("RS384".equals(alg)) { | ||
return null; | ||
} else if ("RS512".equals(alg)) { | ||
return Json.createObjectBuilder(headers).add("alg", "RS256").build(); | ||
} | ||
return null; | ||
} | ||
|
||
} |
38 changes: 0 additions & 38 deletions
38
...ests/oidc-wiremock/src/main/java/io/quarkus/it/keycloak/DefaultTenantTokenCustomizer.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters