forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
13 changed files
with
207 additions
and
26 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
39 changes: 39 additions & 0 deletions
39
...t/src/main/java/io/quarkus/oidc/client/graphql/OidcGraphQLClientIntegrationProcessor.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,39 @@ | ||
package io.quarkus.oidc.client.graphql; | ||
|
||
import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT; | ||
|
||
import io.quarkus.arc.deployment.AdditionalBeanBuildItem; | ||
import io.quarkus.arc.deployment.BeanContainerBuildItem; | ||
import io.quarkus.deployment.Feature; | ||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.Record; | ||
import io.quarkus.deployment.builditem.FeatureBuildItem; | ||
import io.quarkus.oidc.client.graphql.runtime.GraphQLClientOidcClientAdder; | ||
import io.quarkus.oidc.client.graphql.runtime.OidcGraphQLClientIntegrationRecorder; | ||
import io.quarkus.oidc.client.runtime.GraphQLClientOidcTokenProducer; | ||
|
||
public class OidcGraphQLClientIntegrationProcessor { | ||
|
||
@BuildStep | ||
void feature(BuildProducer<FeatureBuildItem> featureProducer) { | ||
featureProducer.produce(new FeatureBuildItem(Feature.OIDC_CLIENT_GRAPHQL_CLIENT_INTEGRATION)); | ||
} | ||
|
||
@BuildStep | ||
AdditionalBeanBuildItem tokenProducerBean() { | ||
return AdditionalBeanBuildItem.unremovableOf(GraphQLClientOidcTokenProducer.class); | ||
} | ||
|
||
@BuildStep | ||
AdditionalBeanBuildItem adderBean() { | ||
return AdditionalBeanBuildItem.unremovableOf(GraphQLClientOidcClientAdder.class); | ||
} | ||
|
||
@BuildStep | ||
@Record(RUNTIME_INIT) | ||
void initializeAdderBean(BeanContainerBuildItem containerBuildItem, | ||
OidcGraphQLClientIntegrationRecorder recorder) { | ||
recorder.initializeAdderBean(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...src/test/java/io/quarkus/oidc/client/reactive/filter/AnnotationTypesafeGraphQLClient.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,15 @@ | ||
package io.quarkus.oidc.client.reactive.filter; | ||
|
||
import org.eclipse.microprofile.graphql.Query; | ||
|
||
import io.quarkus.oidc.client.filter.OidcClientFilter; | ||
import io.smallrye.graphql.client.typesafe.api.GraphQLClientApi; | ||
|
||
@GraphQLClientApi | ||
@OidcClientFilter("annotation") | ||
public interface AnnotationTypesafeGraphQLClient { | ||
|
||
@Query | ||
String principalName(); | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...eployment/src/test/java/io/quarkus/oidc/client/reactive/filter/GraphQLClientResource.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,23 @@ | ||
package io.quarkus.oidc.client.reactive.filter; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
|
||
@Path("/oidc-graphql-client") | ||
public class GraphQLClientResource { | ||
|
||
@Inject | ||
AnnotationTypesafeGraphQLClient annotationTypesafeClient; | ||
|
||
@GET | ||
@Path("/annotation-typesafe") | ||
public String annotationUserName() { | ||
return annotationTypesafeClient.principalName(); | ||
} | ||
|
||
//TODO: | ||
// annotated dynamic client | ||
// config-property based typesafe client | ||
// config-property based dynamic client | ||
} |
52 changes: 52 additions & 0 deletions
52
...rc/test/java/io/quarkus/oidc/client/reactive/filter/GraphQLClientUsingOidcClientTest.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,52 @@ | ||
package io.quarkus.oidc.client.reactive.filter; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.quarkus.test.common.QuarkusTestResource; | ||
import io.quarkus.test.keycloak.server.KeycloakTestResourceLifecycleManager; | ||
import io.restassured.RestAssured; | ||
|
||
@QuarkusTestResource(KeycloakTestResourceLifecycleManager.class) | ||
public class GraphQLClientUsingOidcClientTest { | ||
|
||
private static final Class<?>[] testClasses = { | ||
ProtectedResource.class, | ||
GraphQLClientResource.class, | ||
AnnotationTypesafeGraphQLClient.class | ||
}; | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest test = new QuarkusDevModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(testClasses) | ||
.addAsResource("application.properties", "application.properties")); | ||
|
||
@Test | ||
public void doTest() { // TODO: name | ||
// OidcClient selected via @OidcClient("clientName") | ||
RestAssured.when().get("/oidc-graphql-client/annotation-typesafe") | ||
.then() | ||
.statusCode(200) | ||
.body(equalTo("jdoe")); | ||
|
||
/* | ||
* // @OidcClientFilter: OidcClient selected via `quarkus.oidc-client-filter.client-name=config-property` | ||
* RestAssured.when().get("/oidc-client/config-property/user-name") | ||
* .then() | ||
* .statusCode(200) | ||
* .body(equalTo("alice")); | ||
* | ||
* // @RegisterProvider(OidcClientRequestReactiveFilter.class): OidcClient selected via | ||
* `quarkus.oidc-client-filter.client-name=config-property` | ||
* RestAssured.when().get("/oidc-client/custom-provider-config-property/user-name") | ||
* .then() | ||
* .statusCode(200) | ||
* .body(equalTo("alice")); | ||
*/ | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...ql/deployment/src/test/java/io/quarkus/oidc/client/reactive/filter/ProtectedResource.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,23 @@ | ||
package io.quarkus.oidc.client.reactive.filter; | ||
|
||
import java.security.Principal; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.eclipse.microprofile.graphql.GraphQLApi; | ||
import org.eclipse.microprofile.graphql.Query; | ||
|
||
import io.quarkus.security.Authenticated; | ||
|
||
@GraphQLApi | ||
@Authenticated | ||
public class ProtectedResource { | ||
|
||
@Inject | ||
Principal principal; | ||
|
||
@Query | ||
public String principalName() { | ||
return principal.getName(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
extensions/oidc-client-graphql/deployment/src/test/resources/application.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,20 @@ | ||
quarkus.oidc.auth-server-url=${keycloak.url}/realms/quarkus/ | ||
quarkus.oidc.client-id=quarkus-service-app | ||
quarkus.oidc.credentials.secret=secret | ||
|
||
#quarkus.oidc-client-reactive-filter.client-name=config-property | ||
#quarkus.oidc-client.config-property.auth-server-url=${quarkus.oidc.auth-server-url} | ||
#quarkus.oidc-client.config-property.client-id=${quarkus.oidc.client-id} | ||
#quarkus.oidc-client.config-property.credentials.client-secret.value=${quarkus.oidc.credentials.secret} | ||
#quarkus.oidc-client.config-property.credentials.client-secret.method=POST | ||
#quarkus.oidc-client.config-property.grant.type=password | ||
#quarkus.oidc-client.config-property.grant-options.password.username=alice | ||
#quarkus.oidc-client.config-property.grant-options.password.password=alice | ||
|
||
quarkus.oidc-client.annotation.auth-server-url=${quarkus.oidc.auth-server-url} | ||
quarkus.oidc-client.annotation.client-id=${quarkus.oidc.client-id} | ||
quarkus.oidc-client.annotation.credentials.client-secret.value=${quarkus.oidc.credentials.secret} | ||
quarkus.oidc-client.annotation.credentials.client-secret.method=POST | ||
quarkus.oidc-client.annotation.grant.type=password | ||
quarkus.oidc-client.annotation.grant-options.password.username=jdoe | ||
quarkus.oidc-client.annotation.grant-options.password.password=jdoe |
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
14 changes: 14 additions & 0 deletions
14
...ain/java/io/quarkus/oidc/client/graphql/runtime/OidcGraphQLClientIntegrationRecorder.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,14 @@ | ||
package io.quarkus.oidc.client.graphql.runtime; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.runtime.annotations.Recorder; | ||
|
||
@Recorder | ||
public class OidcGraphQLClientIntegrationRecorder { | ||
|
||
public void initializeAdderBean() { | ||
GraphQLClientOidcClientAdder adder = Arc.container().instance(GraphQLClientOidcClientAdder.class).get(); | ||
adder.toString(); | ||
} | ||
|
||
} |
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