-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to store OIDC JWT creds in PKCS12 keystore
- Loading branch information
1 parent
e878841
commit bf81d72
Showing
7 changed files
with
54 additions
and
5 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
34 changes: 34 additions & 0 deletions
34
.../src/test/java/io/quarkus/oidc/client/OidcClientCredentialsJwtPrivateP12KeyStoreTest.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,34 @@ | ||
package io.quarkus.oidc.client; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.quarkus.test.common.QuarkusTestResource; | ||
import io.restassured.RestAssured; | ||
|
||
@QuarkusTestResource(KeycloakRealmClientCredentialsJwtPrivateKeyStoreManager.class) | ||
public class OidcClientCredentialsJwtPrivateP12KeyStoreTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(OidcClientResource.class, ProtectedResource.class) | ||
.addAsResource("application-oidc-client-credentials-jwt-private-p12-key-store.properties", | ||
"application.properties") | ||
.addAsResource("exportedCertificate.pem") | ||
.addAsResource("exportedPrivateKey.pem") | ||
.addAsResource("keystore.pkcs12")); | ||
|
||
@Test | ||
public void testClientCredentialsToken() { | ||
String token = RestAssured.when().get("/client/token").body().asString(); | ||
RestAssured.given().auth().oauth2(token) | ||
.when().get("/protected") | ||
.then() | ||
.statusCode(200) | ||
.body(equalTo("service-account-quarkus-app")); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...c/test/resources/application-oidc-client-credentials-jwt-private-p12-key-store.properties
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,9 @@ | ||
quarkus.oidc.auth-server-url=${keycloak.url}/realms/quarkus6/ | ||
quarkus.oidc.client-id=quarkus-app | ||
|
||
quarkus.oidc-client.auth-server-url=${quarkus.oidc.auth-server-url} | ||
quarkus.oidc-client.client-id=${quarkus.oidc.client-id} | ||
quarkus.oidc-client.credentials.jwt.key-store-file=keystore.pkcs12 | ||
quarkus.oidc-client.credentials.jwt.key-store-password=password | ||
quarkus.oidc-client.credentials.jwt.key-id=keycloak | ||
quarkus.oidc-client.credentials.jwt.key-password=password |
Binary file not shown.
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