Skip to content

Commit 6ae80e6

Browse files
committed
Sync documentation of main branch
1 parent 41ca465 commit 6ae80e6

File tree

4 files changed

+118
-5
lines changed

4 files changed

+118
-5
lines changed

_generated-doc/main/infra/quarkus-all-build-items.adoc

+4
Original file line numberDiff line numberDiff line change
@@ -8843,6 +8843,10 @@ _No Javadoc found_
88438843

88448844
If this interceptor is always accompanied by `io.quarkus.security.spi.runtime.SecurityCheck` . For example, we know that endpoint annotated with `HttpAuthenticationMechanism` is always secured.
88458845

8846+
`java.util.function.Function<AnnotationInstance,String> bindingValueExtractor`
8847+
8848+
_No Javadoc found_
8849+
88468850

88478851

88488852

_versions/main/guides/getting-started-testing.adoc

+5-3
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,6 @@ org.acme.getting.started.testing.MyQuarkusTestBeforeEachCallback
457457

458458
TIP: It is possible to read annotations from the test class or method to control what the callback shall be doing.
459459

460-
WARNING: While it is possible to use JUnit Jupiter callback interfaces like `BeforeEachCallback`, you might run into classloading issues because Quarkus has
461-
to run tests in a custom classloader which JUnit is not aware of.
462-
463460
[[testing_different_profiles]]
464461
== Testing Different Profiles
465462

@@ -705,6 +702,11 @@ match the value of `quarkus.test.profile.tags`.
705702
* `quarkus.test.profile.tags=test2,test3`: In this case only `MultipleTagsTest` will be run because `MultipleTagsTest` is the only `QuarkusTestProfile` implementation whose `tags` method
706703
matches the value of `quarkus.test.profile.tags`.
707704

705+
== Nested Tests
706+
707+
JUnit 5 https://junit.org/junit5/docs/current/user-guide/#writing-tests-nested[@Nested tests] are useful for structuring more complex test scenarios.
708+
However, note that it is not possible to assign different test profiles or resources to nested tests within the same parent class.
709+
708710
== Mock Support
709711

710712
Quarkus supports the use of mock objects using two different approaches. You can either use CDI alternatives to

_versions/main/guides/security-oidc-bearer-token-authentication.adoc

+107
Original file line numberDiff line numberDiff line change
@@ -1604,6 +1604,113 @@ public class OidcStartup {
16041604
For more complex setup involving multiple tenants please see the xref:security-openid-connect-multitenancy.adoc#programmatic-startup[Programmatic OIDC start-up for multitenant application]
16051605
section of the OpenID Connect Multi-Tenancy guide.
16061606

1607+
== Step Up Authentication
1608+
1609+
The `io.quarkus.oidc.AuthenticationContext` annotation can be used to list one or more Authentication Context Class Reference (ACR) values to enforce a required authentication level for the Jakarta REST resource classes and methods.
1610+
The https://datatracker.ietf.org/doc/rfc9470/[OAuth 2.0 Step Up Authentication Challenge Protocol] introduces a mechanism for resource servers to request stronger authentication methods when the token does not have expected Authentication Context Class Reference (ACR) values.
1611+
Consider the following example:
1612+
1613+
[source,java]
1614+
----
1615+
package io.quarkus.it.oidc;
1616+
1617+
import io.quarkus.oidc.AuthenticationContext;
1618+
import io.quarkus.oidc.BearerTokenAuthentication;
1619+
import jakarta.ws.rs.GET;
1620+
import jakarta.ws.rs.Path;
1621+
1622+
@BearerTokenAuthentication
1623+
@Path("/")
1624+
public class GreetingsResource {
1625+
1626+
@Path("hello")
1627+
@AuthenticationContext("myACR") <1>
1628+
@GET
1629+
public String hello() {
1630+
return "hello";
1631+
}
1632+
1633+
@Path("hi")
1634+
@AuthenticationContext(value = "myACR", maxAge = "PT120m") <2>
1635+
@GET
1636+
public String hi() {
1637+
return "hi";
1638+
}
1639+
}
1640+
----
1641+
<1> Bearer access token must have an `acr` claim with the `myACR` ACR value.
1642+
<2> Bearer access token must have an `acr` claim with the `myACR` ACR value and be in use for no longer than 120 minutes since the authentication time.
1643+
1644+
[source,properties]
1645+
----
1646+
quarkus.http.auth.proactive=false <1>
1647+
----
1648+
<1> Disable proactive authentication so that the `@AuthenticationContext` annotation can be matched with the endpoint before Quarkus authenticates incoming requests.
1649+
1650+
If the bearer access token claim `acr` does not contain `myACR`, Quarkus returns an authentication requirements challenge indicating required `acr_values`:
1651+
1652+
----
1653+
HTTP/1.1 401 Unauthorized
1654+
WWW-Authenticate: Bearer error="insufficient_user_authentication",
1655+
error_description="A different authentication level is required",
1656+
acr_values="myACR"
1657+
----
1658+
1659+
When a client such as Single-page application (SPA) receives a challenge with the `insufficient_user_authentication` error code, it must parse `acr_values`, request a new user login which must meet the `acr_values` constraints, and use a new access token to access Quarkus.
1660+
1661+
[NOTE]
1662+
====
1663+
The `io.quarkus.oidc.AuthenticationContext` annotation can also be used to enforce required authentication level for a WebSockets Next server endpoint.
1664+
The annotation must be placed on the endpoint class, because the `SecurityIdentity` is created before the HTTP connection is upgraded to a WebSocket connection.
1665+
For more information about the HTTP upgrade security, see the xref:websockets-next-reference.adoc#secure-http-upgrade[Secure HTTP upgrade] section of the Quarkus "WebSockets Next reference" guide.
1666+
====
1667+
1668+
It is also possible to enforce the required authentication level for an OIDC tenant:
1669+
1670+
[source,properties]
1671+
----
1672+
quarkus.oidc.hr.token.required-claims.acr=myACR
1673+
----
1674+
1675+
Or, if you need more flexibility, write a <<jose4j-validator>>:
1676+
1677+
[source,java]
1678+
----
1679+
package io.quarkus.it.oidc;
1680+
1681+
import java.util.Map;
1682+
1683+
import jakarta.enterprise.context.ApplicationScoped;
1684+
1685+
import org.jose4j.jwt.MalformedClaimException;
1686+
import org.jose4j.jwt.consumer.JwtContext;
1687+
import org.jose4j.jwt.consumer.Validator;
1688+
1689+
import io.quarkus.arc.Unremovable;
1690+
import io.quarkus.oidc.TenantFeature;
1691+
import io.quarkus.oidc.common.runtime.OidcConstants;
1692+
import io.quarkus.security.AuthenticationFailedException;
1693+
1694+
@Unremovable
1695+
@ApplicationScoped
1696+
@TenantFeature("hr")
1697+
public class AcrValueValidator implements Validator {
1698+
1699+
@Override
1700+
public String validate(JwtContext jwtContext) throws MalformedClaimException {
1701+
var jwtClaims = jwtContext.getJwtClaims();
1702+
if (jwtClaims.hasClaim("acr")) {
1703+
var acrClaim = jwtClaims.getStringListClaimValue("acr");
1704+
if (acrClaim.contains("myACR") && acrClaim.contains("yourACR")) {
1705+
return null;
1706+
}
1707+
}
1708+
String requiredAcrValues = "myACR,yourACR";
1709+
throw new AuthenticationFailedException(Map.of(OidcConstants.ACR_VALUES, requiredAcrValues));
1710+
}
1711+
}
1712+
----
1713+
16071714
== References
16081715

16091716
* xref:security-oidc-configuration-properties-reference.adoc[OIDC configuration properties]

_versions/main/guides/smallrye-fault-tolerance.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ implementation("io.quarkus:quarkus-smallrye-fault-tolerance")
576576
== Additional resources
577577

578578
SmallRye Fault Tolerance has more features than shown here.
579-
Please check the link:https://smallrye.io/docs/smallrye-fault-tolerance/6.9.0/index.html[SmallRye Fault Tolerance documentation] to learn about them.
579+
Please check the link:https://smallrye.io/docs/smallrye-fault-tolerance/6.9.1/index.html[SmallRye Fault Tolerance documentation] to learn about them.
580580

581581
In Quarkus, you can use the SmallRye Fault Tolerance optional features out of the box.
582582

@@ -608,7 +608,7 @@ quarkus.fault-tolerance.mp-compatibility=true
608608
----
609609
====
610610

611-
The link:https://smallrye.io/docs/smallrye-fault-tolerance/6.9.0/reference/programmatic-api.html[programmatic API] is present and integrated with the declarative, annotation-based API.
611+
The link:https://smallrye.io/docs/smallrye-fault-tolerance/6.9.1/reference/programmatic-api.html[programmatic API] is present and integrated with the declarative, annotation-based API.
612612
You can use the `Guard`, `TypedGuard` and `@ApplyGuard` APIs out of the box.
613613

614614
Support for Kotlin is present (assuming you use the Quarkus extension for Kotlin), so you can guard your `suspend` functions with fault tolerance annotations.

0 commit comments

Comments
 (0)