You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quarkus provides mutual TLS (mTLS) authentication so that you can authenticate users based on their X.509 certificates.
182
182
183
183
To use this authentication method, you must first enable SSL/TLS for your application.
184
-
For more information, see the xref:http-reference.adoc#ssl[Supporting secure connections with SSL/TLS] section of the Quarkus "HTTP reference" guide.
184
+
For more information, see the xref:http-reference.adoc#ssl[Supporting secure connections with SSL/TLS] section of the Quarkus "HTTP reference" guide.
185
185
186
186
After your application accepts secure connections, the next step is to configure the `quarkus.http.ssl.certificate.trust-store-file` property with the name of that file that holds all the certificates your application trusts. The specified file also includes information about how your application asks for certificates when a client, such as a browser or other service, tries to access one of its protected resources.
<1> The keystore where the server's private key is located.
200
200
<2> The truststore from which the trusted certificates are loaded.
201
-
<3> With this value set to `required`, the server requires certificates from clients.
202
-
To relax this requirement so that the server accepts requests without a certificate, set the value to `REQUEST`.
203
-
This option is useful when you are also supporting authentication methods other than mTLS.
201
+
<3> With the value set to `required`, the server demands client certificates.
202
+
Set the value to `REQUEST` to allow the server to accept requests without a certificate.
203
+
This setting is beneficial when supporting authentication methods besides mTLS.
204
204
<4> Defines a policy where only authenticated users should have access to resources from your application.
205
-
<5> Optionally,explicitly disable the plain HTTP protocol, and consequently require all requests to be made over HTTPS. If `quarkus.http.ssl.client-auth` is set to `required`, the `quarkus.http.insecure-requests` property is automatically set to `disabled`.
205
+
<5> You can explicitly disable the plain HTTP protocol, thus requiring all requests to use HTTPS.
206
+
When you set `quarkus.http.ssl.client-auth` to `required`, the system automatically sets `quarkus.http.insecure-requests` to `disabled`.
206
207
207
208
When the incoming request matches a valid certificate in the truststore, your application can obtain the subject by injecting a `SecurityIdentity` as follows:
208
209
@@ -263,6 +264,7 @@ OIDC enables client applications to verify the identity of a user based on the a
263
264
264
265
The Quarkus `quarkus-oidc` extension provides a reactive, interoperable, multitenant-enabled OIDC adapter that supports Bearer token and Authorization Code Flow authentication mechanisms.
265
266
The Bearer token authentication mechanism extracts the token from the HTTP Authorization header.
267
+
266
268
The Authorization Code Flow mechanism redirects the user to an OIDC provider to authenticate the user's identity.
267
269
After the user is redirected back to Quarkus, the mechanism completes the authentication process by exchanging the provided code that was granted for the ID, access, and refresh tokens.
268
270
@@ -285,7 +287,7 @@ For more information about OIDC authentication and authorization methods that yo
|OIDC and SAML Identity broker|xref:security-oidc-code-flow-authentication.adoc#oidc-saml-broker[OpenID Connect (OIDC) Authorization Code Flow and SAML Identity broker]
287
289
|Multiple tenants that can support the Bearer token authentication or Authorization Code Flow mechanisms|xref:security-openid-connect-multitenancy.adoc[Using OpenID Connect (OIDC) multi-tenancy]
|Using Keycloak to centralize authorization |xref:security-keycloak-authorization.adoc[Using OpenID Connect (OIDC) and Keycloak to centralize authorization]
290
292
|Configuring Keycloak programmatically |xref:security-keycloak-admin-client.adoc[Using the Keycloak admin client]
291
293
|====
@@ -339,6 +341,7 @@ For more information, see the xref:security-jwt.adoc[Using JWT RBAC] guide.
339
341
340
342
`quarkus-elytron-security-oauth2` provides an alternative to the Quarkus `quarkus-oidc` Bearer token authentication mechanism extension.
341
343
`quarkus-elytron-security-oauth2` is based on `Elytron` and is primarily intended for introspecting opaque tokens remotely.
344
+
342
345
For more information, see the Quarkus xref:security-oauth2.adoc[Using OAuth2] guide.
Permissions are defined in the Quarkus configuration using permission sets, each specifying a policy for access control.
31
+
Permissions are defined in the Quarkus configuration by permission sets, each specifying a policy for access control.
30
32
31
33
.{project-name} policies summary
32
34
[options="header"]
@@ -68,7 +70,11 @@ It is an exact path match because it does not end with `*`.
68
70
<3> This permission set references the previously defined policy.
69
71
`roles1` is an example name; you can call the permission sets whatever you want.
70
72
71
-
WARNING: The `/forbidden` exact path in the example above will not secure the `/forbidden/` path. Don't forget to add new exact path for the `/forbidden/` path.
73
+
[WARNING]
74
+
====
75
+
The exact path `/forbidden` in the example will not secure the `/forbidden/` path.
76
+
It is necessary to add a new exact path for the `/forbidden/` path to ensure proper security coverage.
77
+
====
72
78
73
79
=== Custom HttpSecurityPolicy
74
80
@@ -141,8 +147,11 @@ For that reason, a path like `/public-info` is not matched by this pattern.
141
147
142
148
The request is rejected if it matches one or more permission sets based on the path but none of the required methods.
143
149
144
-
TIP: Given the preceding permission set, `GET /public/foo` would match both the path and method and therefore be allowed.
150
+
[TIP]
151
+
====
152
+
Given the preceding permission set, `GET /public/foo` would match both the path and method and therefore be allowed.
145
153
In contrast, `POST /public/foo` would match the path but not the method, and, therefore, be rejected.
TIP: Given the preceding permission set, `GET /public/forbidden-folder/foo` would match both permission sets' paths.
172
+
[TIP]
173
+
====
174
+
Given the preceding permission set, `GET /public/forbidden-folder/foo` would match both permission sets' paths.
164
175
However, because the longer path matches the path of the `deny1` permission set, `deny1` is chosen, and the request is rejected.
176
+
====
165
177
166
178
[NOTE]
167
179
====
168
-
Subpath permissions always win against the root path permissions, as explained in the preceding `deny1` versus `permit1` permission example.
169
-
Here is another example showing subpath permission allowing a public resource access with the root path permission requiring the authorization:
180
+
Subpath permissions precede root path permissions, as the `deny1` versus `permit1` permission example previously illustrated.
181
+
182
+
This rule is further exemplified by a scenario where subpath permission allows access to a public resource while the root path permission necessitates authorization.
=== Matching multiple sub-paths: longest path to the `*` wildcard wins
183
196
184
-
Previous examples shown how you can match all sub-paths when a path ends with the `$$*$$` wildcard.
185
-
The `$$*$$` wildcard can also be used in the middle of the path, in which case it represents exactly one path segment.
186
-
You can't combine this wildcard with any other path segment character, therefore the `$$*$$` wildcard will always be
187
-
enclosed with path separators as in the `/public/$$*$$/about-us` path.
197
+
Previous examples demonstrated matching all sub-paths when a path concludes with the `$$*$$`
198
+
wildcard.
188
199
189
-
What happens if multiple path patterns matches same request path?
190
-
Matching is always done on the "longest sub-path to the `$$*$$` wildcard wins" basis.
191
-
Every path segment character is considered more specific than the `$$*$$` wildcard.
200
+
This wildcard also applies in the middle of a path, representing a single path segment.
201
+
It cannot be mixed with other path segment characters; thus, path separators always enclose the `$$*$$` wildcard, as seen in the `/public/`$$*$$`/about-us` path.
202
+
203
+
When several path patterns correspond to the same request path, the system selects the longest sub-path leading to the `$$*$$` wildcard.
204
+
In this context, every path segment character is more specific than the `$$*$$`
Given the preceding permission set, `GET /public/foo` would match the paths of both permission sets, but because it fits the explicit method of the `permit1` permission set, `permit1` is chosen, and the request is accepted.
266
+
The preceding permission set shows that `GET /public/foo` matches the paths of both permission sets.However, it specifically aligns with the explicit method of the `permit1` permission set.Therefore, `permit1` is selected, and the request is accepted.
267
+
268
+
253
269
254
-
Conversely, `PUT /public/foo` would not match the method permissions of `permit1`, so `deny1` would be activated and reject the request.
270
+
In contrast, `PUT /public/foo` does not match the method permissions of `permit1`. As a result, `deny1` is activated, leading to the rejection of the request.
@@ -343,8 +359,8 @@ For more information, see link:https://quarkus.io/blog/path-resolution-in-quarku
343
359
[[map-security-identity-roles]]
344
360
=== Map `SecurityIdentity` roles
345
361
346
-
Winning role-based policy can map the `SecurityIdentity` roles to the deploymentspecific roles.
347
-
These roles can later be used for endpoint authorization with the `@RolesAllowed` annotation.
362
+
Winning role-based policy can map the `SecurityIdentity` roles to the deployment-specific roles.
363
+
These roles are then applicable for endpoint authorization by using the @RolesAllowed annotation.
348
364
349
365
[source,properties]
350
366
----
@@ -368,7 +384,7 @@ s| @DenyAll | Specifies that no security roles are allowed to invoke the specifi
368
384
s| @PermitAll | Specifies that all security roles are allowed to invoke the specified methods.
369
385
370
386
`@PermitAll` lets everybody in, even without authentication.
371
-
s| @RolesAllowed | Specifies the list of security roles permitted to access methods in an application.
387
+
s| @RolesAllowed | Specifies the list of security roles allowed to access methods in an application.
372
388
373
389
As an equivalent to `@RolesAllowed("**")`, {project-name} also provides the `io.quarkus.security.Authenticated` annotation that permits any authenticated user to access the resource.
374
390
|===
@@ -518,7 +534,7 @@ It is possible to use multiple expressions in the role definition.
518
534
<3> This `/subject/user` endpoint requires an authenticated user that has been granted the role "User" through the use of the `@RolesAllowed("${customer:User}")` annotation because we did not set the configuration property `customer`.
519
535
<4> In production, this `/subject/secured` endpoint requires an authenticated user with the `User` role.
520
536
In development mode, it allows any authenticated user.
521
-
<5> Property expression `all-roles` will be treated as a collection type `List`, therefore the endpoint will be accessible for roles `Administrator`, `Software`, `Tester` and `User`.
537
+
<5> Property expression `all-roles` will be treated as a collection type `List`, therefore, the endpoint will be accessible for roles `Administrator`, `Software`, `Tester` and `User`.
522
538
523
539
[[permission-annotation]]
524
540
=== Permission annotation
@@ -802,8 +818,8 @@ Because `MediaLibrary` is the `TvLibrary` class parent, a user with the `admin`
802
818
TIP: The `/library/*` path can be tested from a Keycloak provider Dev UI page, because the user `alice` which is created
803
819
automatically by the xref:security-openid-connect-dev-services.adoc[Dev Services for Keycloak] has an `admin` role.
804
820
805
-
The examples provided so far use role-to-permission mapping.
806
-
You can also add permissions to the `SecurityIdentity` instance programmatically.
821
+
The examples provided so far demonstrate role-to-permission mapping.
822
+
It is also possible to programmatically add permissions to the `SecurityIdentity` instance.
807
823
In the following example, xref:security-customization.adoc#security-identity-customization[`SecurityIdentity` is customized] to add the same permission that was previously granted with the HTTP role-based policy.
808
824
809
825
.Example of adding the `LibraryPermission` programmatically to `SecurityIdentity`
HTTP Basic authentication is one of the least resource-demanding techniques that enforce access controls to web resources.
15
-
You can secure your Quarkus application endpoints with HTTP Basic authentication.
16
-
Quarkus provides a built-in authentication mechanism for Basic authentication.
15
+
You can secure your Quarkus application endpoints by using HTTP Basic authentication.
16
+
Quarkus includes a built-in authentication mechanism for Basic authentication.
17
17
18
-
Basic authentication uses fields in the HTTP header and does not require HTTP cookies, session identifiers, or login pages.
18
+
Basic authentication uses fields in the HTTP header and does not rely on HTTP cookies, session identifiers, or login pages.
19
19
20
20
== Authorization header
21
21
22
-
An HTTP user agent, for example, a web browser, uses an `Authorization` header to provide a username and password in each HTTP request.
23
-
The header is specified as `Authorization: Basic <credentials>`, where credentials are the Base64 encoding of the user ID and password joined by a colon, as shown in the following example.
24
-
25
-
====
26
-
.Example
22
+
An HTTP user agent, like a web browser, uses an `Authorization` header to provide a username and password in each HTTP request.
23
+
The header is specified as `Authorization: Basic <credentials>`, where credentials are the Base64 encoding of the user ID and password, joined by a colon.
27
24
25
+
.Example:
28
26
If the user name is `Alice` and the password is `secret`, the HTTP authorization header would be `Authorization: Basic QWxjZTpzZWNyZXQ=`, where `QWxjZTpzZWNyZXQ=` is a Base64 encoded representation of the `Alice:secret` string.
29
-
====
27
+
30
28
31
29
The Basic authentication mechanism does not provide confidentiality protection for the transmitted credentials.
32
30
The credentials are merely encoded with Base64 when in transit, and not encrypted or hashed in any way.
0 commit comments