Skip to content

Commit 2564e62

Browse files
committed
Sync documentation of main branch
1 parent 9428d45 commit 2564e62

File tree

7 files changed

+39
-7
lines changed

7 files changed

+39
-7
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ _No Javadoc found_
309309
a| https://github.com/quarkusio/quarkus/blob/main/core/deployment/src/main/java/io/quarkus/deployment/builditem/BytecodeRecorderObjectLoaderBuildItem.java[`io.quarkus.deployment.builditem.BytecodeRecorderObjectLoaderBuildItem`, window="_blank"]
310310
[.description]
311311
--
312-
312+
_No Javadoc found_
313313
-- a|`io.quarkus.deployment.recording.ObjectLoader objectLoader`
314314

315315
_No Javadoc found_
@@ -9359,7 +9359,7 @@ a| https://github.com/quarkusio/quarkus/blob/main/extensions/vertx-http/deployme
93599359
[.description]
93609360
--
93619361
_No Javadoc found_
9362-
-- a|`java.util.List<String> endpoints`
9362+
-- a|`java.util.Set<String> endpoints`
93639363

93649364
_No Javadoc found_
93659365

_versions/main/guides/cdi-reference.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ public class EagerAppBean {
333333

334334
NOTE: Quarkus users are encouraged to always prefer the `@Observes StartupEvent` to `@Initialized(ApplicationScoped.class)` as explained in the xref:lifecycle.adoc[Application Initialization and Termination] guide.
335335

336+
[[request-context-lifecycle]]
336337
=== Request Context Lifecycle
337338

338339
The request context is also active:

_versions/main/guides/drools.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ We can create a standard Quarkus and JUnit test to check the behaviour of the Ru
509509
package org.drools.quarkus.quickstart.test;
510510
511511
@QuarkusTest
512-
public class RuntimeIT {
512+
public class RuntimeTest {
513513
514514
@Inject
515515
RuleUnit<HomeRuleUnitData> ruleUnit;

_versions/main/guides/rest-client.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ import jakarta.ws.rs.QueryParam;
157157
import jakarta.ws.rs.core.MultivaluedMap;
158158
import java.util.Map;
159159
import java.util.Set;
160+
import java util.Optional;
160161
161162
@Path("/extensions")
162163
@RegisterRestClient(configKey = "extensions-api")
@@ -168,6 +169,9 @@ public interface ExtensionsService {
168169
@GET
169170
Set<Extension> getByName(@RestQuery String name); <1>
170171
172+
@GET
173+
Set<Extension> getByOptionalName(@RestQuery Optional<String> name);
174+
171175
@GET
172176
Set<Extension> getByFilter(@RestQuery Map<String, String> filter); <2>
173177

_versions/main/guides/security-authorize-web-endpoints-reference.adoc

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ public class CustomNamedHttpSecPolicy implements HttpSecurityPolicy {
123123
public Uni<CheckResult> checkPermission(RoutingContext event, Uni<SecurityIdentity> identity,
124124
AuthorizationRequestContext requestContext) {
125125
if (customRequestAuthorization(event)) {
126-
return Uni.createFrom().item(CheckResult.PERMIT);
126+
return CheckResult.permit();
127127
}
128-
return Uni.createFrom().item(CheckResult.DENY);
128+
return CheckResult.deny();
129129
}
130130
131131
@Override
@@ -182,6 +182,17 @@ You can also create global `HttpSecurityPolicy` invoked on every request.
182182
Just do not implement the `io.quarkus.vertx.http.runtime.security.HttpSecurityPolicy.name` method and leave the policy nameless.
183183
====
184184

185+
[[policy-active-cdi-request-context]]
186+
=== Inject `@RequestScoped` beans into `HttpSecurityPolicy`
187+
188+
`@RequestScoped` beans can only be injected when the xref:cdi-reference.adoc#request-context-lifecycle[CDI request context] is active.
189+
The context can be activated by users, for example with the `@ActivateRequestContext`, however authorization happens before Quarkus prepares some `@RequestScoped` beans.
190+
We recommend to let Quarkus activate and prepare CDI request context for you.
191+
For example, consider a situation where you want to inject a bean from the Jakarta REST context, such as the `jakarta.ws.rs.core.UriInfo` bean.
192+
In this case, you must apply the `HttpSecurityPolicy` to Jakarta REST endpoints. This can be achieved in one of the following ways:
193+
* Use the `@AuthorizationPolicy` security annotation.
194+
* Set the `quarkus.http.auth.permission.custom1.applies-to=jaxrs` configuration property.
195+
185196
=== Matching on paths and methods
186197

187198
Permission sets can also specify paths and methods as a comma-separated list.
@@ -494,7 +505,7 @@ s| `@PermitAll` | Specifies that all security roles are allowed to invoke the sp
494505
s| `@RolesAllowed` | Specifies the list of security roles allowed to access methods in an application.
495506
s| `@Authenticated` | {project-name} provides the `io.quarkus.security.Authenticated` annotation that permits any authenticated user to access the resource. It's equivalent to `@RolesAllowed("**")`.
496507
s| `@PermissionsAllowed` | Specifies the list of permissions that are allowed to invoke the specified methods.
497-
s| `@AuthorizationPolicy` | Specifies named `io.quarkus.vertx.http.runtime.security.HttpSecurityPolicy` that should authorize access to the specified endpoints.HttpSecurityPolicy.
508+
s| `@AuthorizationPolicy` | Specifies named `io.quarkus.vertx.http.runtime.security.HttpSecurityPolicy` that should authorize access to the specified Jakarta REST endpoints.
498509
Named HttpSecurityPolicy can be used for general authorization checks as demonstrated by <<authorization-policy-example>>.
499510
|===
500511

_versions/main/guides/security-customization.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ You can enforce the order by implementing a default `SecurityIdentityAugmentor#p
242242
By default, the request context is not activated when augmenting the security identity, this means that if you want to use for example Hibernate
243243
that mandates a request context, you will have a `jakarta.enterprise.context.ContextNotActiveException`.
244244

245+
IMPORTANT: Please also review the xref:security-proactive-authentication.adoc#cdi-request-context-activation[Activating the CDI request context] section of the "Proactive authentication" guide.
246+
245247
The solution is to activate the request context, the following example shows how to get the roles from an Hibernate with Panache `UserRoleEntity`.
246248

247249
[source,java]

_versions/main/guides/security-proactive-authentication.adoc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Gain practical insights and strategies for various application scenarios.
1818
Proactive authentication is enabled in Quarkus by default.
1919
It ensures that all incoming requests with credentials are authenticated, even if the target page does not require authentication.
2020
As a result, requests with invalid credentials are rejected, even if the target page is public.
21+
Requests without credentials are not rejected, because anonymous requests are allowed.
2122

2223
You can turn off this default behavior if you want to authenticate only when the target page requires it.
2324
To turn off proactive authentication so that authentication occurs only when the target page requires it, modify the `application.properties` configuration file as follows:
@@ -30,7 +31,7 @@ quarkus.http.auth.proactive=false
3031
If you turn off proactive authentication, the authentication process runs only when an identity is requested.
3132
An identity can be requested because of security rules that require the user to authenticate or because programmatic access to the current identity is required.
3233

33-
If proactive authentication is used, accessing `SecurityIdentity` is a blocking operation.
34+
If proactive authentication is not used, accessing `SecurityIdentity` is a blocking operation.
3435
This is because authentication might have yet to happen, and accessing `SecurityIdentity` might require calls to external systems, such as databases, that might block the operation.
3536
For blocking applications, this is not an issue.
3637
However, if you have disabled authentication in a reactive application, this fails because you cannot do blocking operations on the I/O thread.
@@ -96,6 +97,19 @@ public class HelloService {
9697
}
9798
----
9899

100+
[[cdi-request-context-activation]]
101+
== Activating the CDI request context
102+
103+
You may need to inject `@RequestScoped` beans during authentication and authorization.
104+
A good example of this is accessing a database during a `SecurityIdentity` augmentation,
105+
which is described in the xref:security-customization.adoc#security-identity-customization[Security Identity Customization] section of the "Security Tips and Tricks" guide.
106+
If authentication or authorization fails with the `jakarta.enterprise.context.ContextNotActiveException`, disabling proactive authentication is most often the best solution.
107+
Users can also activate xref:cdi-reference.adoc#request-context-lifecycle[CDI request context], for example, by using the `@ActivateRequestContext` annotation.
108+
However, some CDI beans may not be ready for use.
109+
110+
One exception to this solution is a situation when application endpoints are secured with the xref:security-authorize-web-endpoints-reference.adoc#authorization-using-configuration[Authorization using configuration].
111+
For more information, see the xref:security-authorize-web-endpoints-reference.adoc#policy-active-cdi-request-context[Inject RequestScoped beans into HttpSecurityPolicy] section of the "Authorization of Web endpoints" guide for more information.
112+
99113
[[customize-auth-exception-responses]]
100114
== Customize authentication exception responses
101115

0 commit comments

Comments
 (0)