Skip to content

Commit

Permalink
Merge pull request #45046 from gsmet/3.17.4-backports-2
Browse files Browse the repository at this point in the history
[3.17] 3.17.4 backports 2
  • Loading branch information
gsmet authored Dec 11, 2024
2 parents 040947e + f21e114 commit 72b3d01
Show file tree
Hide file tree
Showing 39 changed files with 422 additions and 81 deletions.
4 changes: 2 additions & 2 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
<microprofile-jwt.version>2.1</microprofile-jwt.version>
<microprofile-lra.version>2.0</microprofile-lra.version>
<microprofile-openapi.version>4.0.2</microprofile-openapi.version>
<smallrye-common.version>2.8.0</smallrye-common.version>
<smallrye-common.version>2.9.0</smallrye-common.version>
<smallrye-config.version>3.10.2</smallrye-config.version>
<smallrye-health.version>4.1.0</smallrye-health.version>
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
<smallrye-open-api.version>4.0.4</smallrye-open-api.version>
<smallrye-open-api.version>4.0.5</smallrye-open-api.version>
<smallrye-graphql.version>2.11.0</smallrye-graphql.version>
<smallrye-fault-tolerance.version>6.6.3</smallrye-fault-tolerance.version>
<smallrye-jwt.version>4.6.1</smallrye-jwt.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public String formatPorts() {
return Arrays.stream(getExposedPorts())
.filter(p -> p.getPublicPort() != null)
.map(c -> c.getIp() + ":" + c.getPublicPort() + "->" + c.getPrivatePort() + "/" + c.getType())
.collect(Collectors.joining(" ,"));
.collect(Collectors.joining(", "));
}

public static class ContainerPort {
Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/kafka-dev-services.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ Dev Services for Kafka supports https://redpanda.com[Redpanda], https://github/o
and https://strimzi.io[Strimzi] (in https://github.com/apache/kafka/blob/trunk/config/kraft/README.md[Kraft] mode) images.

**Redpanda** is a Kafka compatible event streaming platform.
Because it provides a fast startup times, Dev Services defaults to Redpanda images from `vectorized/redpanda`.
You can select any version from https://hub.docker.com/r/vectorized/redpanda.
Because it provides a fast startup times, Dev Services defaults to Redpanda images from `redpandadata/redpanda`.
You can select any version from https://hub.docker.com/r/redpandadata/redpanda.

**kafka-native** provides images of standard Apache Kafka distribution compiled to native binary using Quarkus and GraalVM.
While still being _experimental_, it provides very fast startup times with small footprint.
Expand Down
8 changes: 4 additions & 4 deletions docs/src/main/asciidoc/native-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ invoke Maven's `verify` goal with `-DskipITs=false -Dquarkus.test.integration-te
generate the native image configuration.
For example:

[source,bash]
[source,bash,subs=attributes+]
----
$ ./mvnw verify -DskipITs=false -Dquarkus.test.integration-test-profile=test-with-native-agent
...
Expand Down Expand Up @@ -660,7 +660,7 @@ This can be useful to verify that the native integration tests work as expected,
assuming that the JVM unit tests have generated the correct native image configuration.
The typical workflow here would be to first run the integration tests with the native image agent as shown in the previous section:

[source,bash]
[source,bash,subs=attributes+]
----
$ ./mvnw verify -DskipITs=false -Dquarkus.test.integration-test-profile=test-with-native-agent
...
Expand All @@ -671,7 +671,7 @@ $ ./mvnw verify -DskipITs=false -Dquarkus.test.integration-test-profile=test-wit
And then request a native build passing in the configuration apply flag.
A message during the native build process will indicate that the native image agent generated configuration files are being applied:

[source,bash]
[source,bash,subs=attributes+]
----
$ ./mvnw verify -Dnative -Dquarkus.native.agent-configuration-apply
...
Expand Down Expand Up @@ -702,7 +702,7 @@ and confirm that the class and/or package making the call or being accessed is n
If the missing entry is related to some resource,
you should inspect the Quarkus build debug output and verify which resource patterns are being discarded, e.g.

[source,bash]
[source,bash,subs=attributes+]
----
$ ./mvnw -X verify -DskipITs=false -Dquarkus.test.integration-test-profile=test-with-native-agent
...
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/observability-devservices-lgtm.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Add the Quarkus Grafana OTel LGTM sink (where data goes) extension to your build
[source,gradle,role="secondary asciidoc-tabs-target-sync-gradle"]
.build.gradle
----
implementation("quarkus-observability-devservices-lgtm")
implementation("io.quarkus:quarkus-observability-devservices-lgtm")
----

=== Metrics
Expand Down
32 changes: 32 additions & 0 deletions docs/src/main/asciidoc/rest-client.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,38 @@ public interface ExtensionsService {
}
----

=== Dynamic base URLs

The REST client allows for a per invocation override of the base URL using the `io.quarkus.rest.client.reactive.Url` annotation.

Here is a simple example:

[source, java]
----
package org.acme.rest.client;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.QueryParam;
import java.util.Set;
import io.quarkus.rest.client.reactive.Url;
@Path("/extensions")
@RegisterRestClient
public interface ExtensionsService {
@GET
@Path("/stream/{stream}")
Set<Extension> getByStream(@Url String url, @PathParam("stream") String stream, @QueryParam("id") String id);
}
----

When the `url` parameter is non-null, it will override the base URL that is configured for the client (the default base URL configuration is still mandatory).

=== Sending large payloads

The REST Client is capable of sending arbitrarily large HTTP bodies without buffering the contents in memory, if one of the following types is used:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ private static String[] getNetworks(Container container) {
return networks.entrySet().stream()
.map(e -> {
List<String> aliases = e.getValue().getAliases();
if (aliases == null) {
if (aliases == null || aliases.isEmpty()) {
return e.getKey();
}
return e.getKey() + " (" + String.join(",", aliases) + ")";
return e.getKey() + " (" + String.join(", ", aliases) + ")";
})
.toArray(String[]::new);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,19 @@ public void testJaxrsUserRoleSuccess() {
setupAuth("standardUser", "standardUserPassword")
.when().get("/jaxrs-secured/subject/secured").then()
.statusCode(200)
.body(equalTo("standardUser"));
.body(equalTo(expectedStandardUserName()));
}

@Test
public void testJaxrsInjectedPrincipalSuccess() {
setupAuth("standardUser", "standardUserPassword")
.when().get("/jaxrs-secured/subject/principal-secured").then()
.statusCode(200)
.body(equalTo("standardUser"));
.body(equalTo(expectedStandardUserName()));
}

protected String expectedStandardUserName() {
return "standardUser";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ public class MinimalConfigurationTest extends LdapSecurityRealmTest {
.addClasses(testClasses)
.addAsResource("minimal-config/application.properties", "application.properties"));

protected String expectedStandardUserName() {
return "standardUser:Standard User";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,27 @@
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.SecurityContext;

import org.wildfly.security.authz.Attributes;

import io.quarkus.security.identity.SecurityIdentity;

@Path("subject")
public class SubjectExposingResource {

@Inject
Principal principal;

@Inject
SecurityIdentity identity;

@GET
@RolesAllowed("standardRole")
@Path("secured")
public String getSubjectSecured(@Context SecurityContext sec) {
Principal user = sec.getUserPrincipal();
public String getSubjectSecured() {
Principal user = identity.getPrincipal();
String name = user != null ? user.getName() : "anonymous";
return name;
Attributes.Entry attributeEntry = (Attributes.Entry) identity.getAttributes().get("displayName");
return attributeEntry == null ? name : name + ":" + attributeEntry.get(0);
}

@GET
Expand All @@ -34,7 +42,8 @@ public String getPrincipalSecured(@Context SecurityContext sec) {
throw new IllegalStateException("No injected principal");
}
String name = principal.getName();
return name;
Attributes.Entry attributeEntry = (Attributes.Entry) identity.getAttributes().get("displayName");
return attributeEntry == null ? name : name + ":" + attributeEntry.get(0);
}

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ quarkus.security.ldap.identity-mapping.search-base-dn=ou=Users,dc=quarkus,dc=io
quarkus.security.ldap.identity-mapping.attribute-mappings."0".from=cn
quarkus.security.ldap.identity-mapping.attribute-mappings."0".filter=(member=uid={0},ou=Users,dc=quarkus,dc=io)
quarkus.security.ldap.identity-mapping.attribute-mappings."0".filter-base-dn=ou=Roles,dc=quarkus,dc=io

quarkus.security.ldap.identity-mapping.attribute-mappings."1".from=displayName
quarkus.security.ldap.identity-mapping.attribute-mappings."1".to=displayName
quarkus.security.ldap.identity-mapping.attribute-mappings."1".filter=(uid={0})
quarkus.security.ldap.identity-mapping.attribute-mappings."1".filter-base-dn=ou=Users,dc=quarkus,dc=io
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.jboss.logging.Logger;
import org.wildfly.security.auth.server.RealmUnavailableException;
import org.wildfly.security.auth.server.SecurityDomain;
import org.wildfly.security.authz.Attributes;
import org.wildfly.security.evidence.PasswordGuessEvidence;

import io.quarkus.security.AuthenticationFailedException;
Expand Down Expand Up @@ -52,6 +53,10 @@ public SecurityIdentity get() {
throw new AuthenticationFailedException();
}
QuarkusSecurityIdentity.Builder builder = QuarkusSecurityIdentity.builder();
for (Attributes.Entry entry : result.getAttributes().entries()) {
builder.addAttribute(entry.getKey(), entry);
}

builder.setPrincipal(result.getPrincipal());
for (String i : result.getRoles()) {
builder.addRole(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.jboss.logging.Logger;
import org.wildfly.security.auth.server.RealmUnavailableException;
import org.wildfly.security.auth.server.SecurityDomain;
import org.wildfly.security.authz.Attributes;
import org.wildfly.security.evidence.BearerTokenEvidence;

import io.quarkus.security.AuthenticationFailedException;
Expand Down Expand Up @@ -51,6 +52,9 @@ public SecurityIdentity get() {
throw new AuthenticationFailedException();
}
QuarkusSecurityIdentity.Builder builder = QuarkusSecurityIdentity.builder();
for (Attributes.Entry entry : result.getAttributes().entries()) {
builder.addAttribute(entry.getKey(), entry);
}
builder.setPrincipal(result.getPrincipal());
for (String i : result.getRoles()) {
builder.addRole(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.wildfly.security.auth.server.RealmUnavailableException;
import org.wildfly.security.auth.server.SecurityDomain;
import org.wildfly.security.auth.server.ServerAuthenticationContext;
import org.wildfly.security.authz.Attributes;
import org.wildfly.security.credential.PasswordCredential;

import io.quarkus.security.AuthenticationFailedException;
Expand Down Expand Up @@ -62,6 +63,9 @@ public SecurityIdentity get() {
throw new AuthenticationFailedException();
}
QuarkusSecurityIdentity.Builder builder = QuarkusSecurityIdentity.builder();
for (Attributes.Entry entry : result.getAttributes().entries()) {
builder.addAttribute(entry.getKey(), entry);
}
builder.setPrincipal(result.getPrincipal());
for (String i : result.getRoles()) {
builder.addRole(i);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.quarkus.grpc.client.interceptors;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.List;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.grpc.examples.helloworld.Greeter;
import io.grpc.examples.helloworld.GreeterBean;
import io.grpc.examples.helloworld.GreeterGrpc;
import io.grpc.examples.helloworld.HelloReply;
import io.grpc.examples.helloworld.HelloReplyOrBuilder;
import io.grpc.examples.helloworld.HelloRequest;
import io.grpc.examples.helloworld.HelloRequestOrBuilder;
import io.grpc.examples.helloworld.MutinyGreeterGrpc;
import io.quarkus.grpc.GrpcClient;
import io.quarkus.grpc.RegisterClientInterceptor;
import io.quarkus.grpc.server.services.MutinyHelloService;
import io.quarkus.test.QuarkusUnitTest;

public class ClientInterceptorConstructorRegistrationTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest().setArchiveProducer(
() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(MutinyHelloService.class, MyThirdClientInterceptor.class, MyLastClientInterceptor.class,
Calls.class,
GreeterGrpc.class, Greeter.class, GreeterBean.class, HelloRequest.class, HelloReply.class,
MutinyGreeterGrpc.class,
HelloRequestOrBuilder.class, HelloReplyOrBuilder.class))
.withConfigurationResource("hello-config.properties");
private static final Logger log = LoggerFactory.getLogger(ClientInterceptorConstructorRegistrationTest.class);

private GreeterGrpc.GreeterBlockingStub client;

public ClientInterceptorConstructorRegistrationTest(
@RegisterClientInterceptor(MyLastClientInterceptor.class) @RegisterClientInterceptor(MyThirdClientInterceptor.class) @GrpcClient("hello-service") GreeterGrpc.GreeterBlockingStub client) {
this.client = client;
}

@Test
public void testInterceptorRegistration() {
Calls.LIST.clear();

HelloReply reply = client
.sayHello(HelloRequest.newBuilder().setName("neo").build());
assertThat(reply.getMessage()).isEqualTo("Hello neo");

List<String> calls = Calls.LIST;
assertEquals(2, calls.size());
assertEquals(MyThirdClientInterceptor.class.getName(), calls.get(0));
assertEquals(MyLastClientInterceptor.class.getName(), calls.get(1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private RunningDevService startKafka(DockerStatusBuildItem dockerStatusBuildItem
switch (config.provider) {
case REDPANDA:
RedpandaKafkaContainer redpanda = new RedpandaKafkaContainer(
DockerImageName.parse(config.imageName).asCompatibleSubstituteFor("vectorized/redpanda"),
DockerImageName.parse(config.imageName).asCompatibleSubstituteFor("redpandadata/redpanda"),
config.fixedExposedPort,
launchMode.getLaunchMode() == LaunchMode.DEVELOPMENT ? config.serviceName : null,
useSharedNetwork, config.redpanda);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class KafkaDevServicesBuildTimeConfig {
* Redpanda, Strimzi and kafka-native container providers are supported. Default is redpanda.
* <p>
* For Redpanda:
* See https://docs.redpanda.com/current/get-started/quick-start/ and https://hub.docker.com/r/vectorized/redpanda
* See https://docs.redpanda.com/current/get-started/quick-start/ and https://hub.docker.com/r/redpandadata/redpanda
* <p>
* For Strimzi:
* See https://github.com/strimzi/test-container and https://quay.io/repository/strimzi-test-container/test-container
Expand All @@ -48,7 +48,7 @@ public class KafkaDevServicesBuildTimeConfig {
public Provider provider = Provider.REDPANDA;

public enum Provider {
REDPANDA("docker.io/vectorized/redpanda:v24.1.2"),
REDPANDA("docker.io/redpandadata/redpanda:v24.1.2"),
STRIMZI("quay.io/strimzi-test-container/test-container:latest-kafka-3.7.0"),
KAFKA_NATIVE("quay.io/ogunalp/kafka-native:latest");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ public String getEndSessionUri() {
return endSessionUri;
}

public String getRegistrationUri() {
return registrationUri;
}

public List<String> getSupportedScopes() {
return getStringList(SCOPES_SUPPORTED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ private UniOnItem<HttpResponse<Buffer>> getHttpResponse(OidcRequestContextProper

private AuthorizationCodeTokens getAuthorizationCodeTokens(OidcRequestContextProperties requestProps,
HttpResponse<Buffer> resp) {
JsonObject json = getJsonObject(requestProps, metadata.getAuthorizationUri(), resp, OidcEndpoint.Type.TOKEN);
JsonObject json = getJsonObject(requestProps, metadata.getTokenUri(), resp, OidcEndpoint.Type.TOKEN);
final String idToken = json.getString(OidcConstants.ID_TOKEN_VALUE);
final String accessToken = json.getString(OidcConstants.ACCESS_TOKEN_VALUE);
final String refreshToken = json.getString(OidcConstants.REFRESH_TOKEN_VALUE);
Expand Down
Loading

0 comments on commit 72b3d01

Please sign in to comment.