Skip to content

Commit

Permalink
Merge pull request #108 from Sgitario/fix_oidc_module
Browse files Browse the repository at this point in the history
Enable tests to cover access token (new oidc token propagation module)
  • Loading branch information
Sgitario authored Mar 8, 2021
2 parents 88af8f6 + 46ead90 commit 068504e
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 14 deletions.
2 changes: 1 addition & 1 deletion 013-quarkus-oidc-restclient/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ Variants:
- Using Reactive endpoints (quarkus-resteasy-mutiny extension)
- Using Lookup authorization via `@ClientHeaderParam` annotation
- Using `OIDC Client Filter` extension to automatically acquire the access token from Keycloak when calling to the RestClient.
- Using `OIDC Token Propagation` extension to propagate the tokens from the source REST call to the target RestClient. (Disabled because https://github.com/quarkusio/quarkus/issues/14466)
- Using `OIDC Token Propagation` extension to propagate the tokens from the source REST call to the target RestClient.
6 changes: 2 additions & 4 deletions 013-quarkus-oidc-restclient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-client-filter</artifactId>
</dependency>
<!-- TODO: Can't use both OIDC Client Filter and OIDC Token extensions.
Reported in https://github.com/quarkusio/quarkus/issues/14466 -->
<!-- <dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-token-propagation</artifactId>
</dependency> -->
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-authz-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package io.quarkus.qe.ping;

import javax.inject.Inject;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.eclipse.microprofile.rest.client.inject.RestClient;

import io.quarkus.qe.model.Score;
import io.quarkus.qe.ping.clients.TokenPropagationPongClient;

@Path("/token-propagation-ping")
Expand All @@ -22,4 +27,31 @@ public class TokenPropagationPingResource {
public String getPing() {
return "ping " + pongClient.getPong();
}

@GET
@Path("/name/{name}")
@Produces(MediaType.TEXT_PLAIN)
public String getPingWithPathName(@PathParam("name") String name) {
return "ping " + pongClient.getPongWithPathName(name);
}

@POST
@Path("/withBody")
@Produces(MediaType.TEXT_PLAIN)
public String createPongWithBody(Score score) {
return "ping -> " + pongClient.createPongWithBody(score);
}

@PUT
@Path("/withBody")
@Produces(MediaType.TEXT_PLAIN)
public String updatePongWithBody(Score score) {
return "ping -> " + pongClient.updatePongWithBody(score);
}

@DELETE
@Path("/{id}")
public String deleteById(@PathParam("id") String id) {
return "ping -> " + pongClient.deletePongById(id);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,49 @@
package io.quarkus.qe.ping.clients;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

import io.quarkus.oidc.token.propagation.AccessToken;
import io.quarkus.qe.model.Score;

@RegisterRestClient
// TODO: Can't use both OIDC Client Filter and OIDC Token extensions. Reported in https://github.com/quarkusio/quarkus/issues/14466
//@AccessToken
@AccessToken
@Path("/rest-pong")
public interface TokenPropagationPongClient {

@GET
@Path("/rest-pong")
@Produces(MediaType.TEXT_PLAIN)
String getPong();

@GET
@Path("/name/{name}")
@Produces(MediaType.TEXT_PLAIN)
String getPongWithPathName(@PathParam("name") String name);

@POST
@Path("/withBody")
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.APPLICATION_JSON)
String createPongWithBody(Score score);

@PUT
@Path("/withBody")
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.APPLICATION_JSON)
String updatePongWithBody(Score score);

@DELETE
@Path("/{id}")
@Produces(MediaType.TEXT_PLAIN)
boolean deletePongById(@PathParam("id") String id);

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package io.quarkus.qe;

import org.junit.jupiter.api.Disabled;

import io.quarkus.test.junit.NativeImageTest;

@Disabled("TODO: Can't use both OIDC Client Filter and OIDC Token extensions. Reported in https://github.com/quarkusio/quarkus/issues/14466")
@NativeImageTest
public class NativeTokenPropagationPingPongResourceIT extends TokenPropagationPingPongResourceTest {
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package io.quarkus.qe;

import org.junit.jupiter.api.Disabled;

import io.quarkus.test.junit.QuarkusTest;

@Disabled("TODO: Can't use both OIDC Client Filter and OIDC Token extensions. Reported in https://github.com/quarkusio/quarkus/issues/14466")
@QuarkusTest
public class TokenPropagationPingPongResourceTest extends AbstractPingPongResourceTest {

Expand Down

0 comments on commit 068504e

Please sign in to comment.