Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added necessary basic auth option to examples #42812

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions docs/src/main/asciidoc/security-properties.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
and pull requests should be submitted there:
https://github.com/quarkusio/quarkus/tree/main/docs/src/main/asciidoc
////
= Using Security with .properties File

Check warning on line 6 in docs/src/main/asciidoc/security-properties.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Headings] Use sentence-style capitalization in 'Using Security with .properties File'. Raw Output: {"message": "[Quarkus.Headings] Use sentence-style capitalization in 'Using Security with .properties File'.", "location": {"path": "docs/src/main/asciidoc/security-properties.adoc", "range": {"start": {"line": 6, "column": 3}}}, "severity": "INFO"}

include::_attributes.adoc[]
:categories: security
:summary: This guide demonstrates how your Quarkus application can use a .properties file to store your user identities.
Expand Down Expand Up @@ -37,9 +38,14 @@

The following sections detail the specific configuration properties.

include::{generated-dir}/config/quarkus-elytron-security-properties-file.adoc[opts=optional, leveloffset=+2]
[NOTE]
====
Basic authentication must be explicitly enabled with `quarkus.http.auth.basic=true`, if more than one authentication mechanism is used.
====

include::{generated-dir}/config/quarkus-elytron-security-properties-file.adoc[opts=optional,leveloffset=+2]

=== Properties Files Realm Configuration

Check warning on line 48 in docs/src/main/asciidoc/security-properties.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Headings] Use sentence-style capitalization in 'Properties Files Realm Configuration'. Raw Output: {"message": "[Quarkus.Headings] Use sentence-style capitalization in 'Properties Files Realm Configuration'.", "location": {"path": "docs/src/main/asciidoc/security-properties.adoc", "range": {"start": {"line": 48, "column": 5}}}, "severity": "INFO"}

The properties files realm supports the mapping of users to passwords and users to roles with a combination of properties files.
They are configured with properties starting with
Expand Down Expand Up @@ -70,10 +76,12 @@
stuart=test
noadmin=n0Adm1n
----

<1> User `scott` has password defined as `jb0ss`

Check warning on line 80 in docs/src/main/asciidoc/security-properties.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using 'because' or 'while' rather than 'as'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using 'because' or 'while' rather than 'as'.", "location": {"path": "docs/src/main/asciidoc/security-properties.adoc", "range": {"start": {"line": 80, "column": 28}}}, "severity": "INFO"}
<2> User `jdoe` has password defined as `p4ssw0rd`

Check warning on line 81 in docs/src/main/asciidoc/security-properties.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using 'because' or 'while' rather than 'as'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using 'because' or 'while' rather than 'as'.", "location": {"path": "docs/src/main/asciidoc/security-properties.adoc", "range": {"start": {"line": 81, "column": 27}}}, "severity": "INFO"}

This file has usernames and passwords stored in plain text, which is not recommended. If plain text is set to false (or omitted) in the config, then passwords must be stored in the form `MD5 ( username : realm : password )`.
This file has usernames and passwords stored in plain text, which is not recommended.
If plain text is set to false (or omitted) in the config, then passwords must be stored in the form `MD5 ( username : realm : password )`.
This can be generated for the first example above by running the command `echo -n scott:MyRealm:jb0ss | md5` from the command line.

==== Roles.properties
Expand All @@ -86,13 +94,15 @@
stuart=admin,user <3>
noadmin=user
----

<1> User `scott` has been assigned the roles `Admin`, `admin`, `Tester` and `user`
<2> User `jdoe` has been assigned the role `NoRolesUser`
<3> User `stuart` has been assigned the roles `admin` and `user`.

Check warning on line 100 in docs/src/main/asciidoc/security-properties.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Headings] Use sentence-style capitalization in 'Embedded Realm Configuration'. Raw Output: {"message": "[Quarkus.Headings] Use sentence-style capitalization in 'Embedded Realm Configuration'.", "location": {"path": "docs/src/main/asciidoc/security-properties.adoc", "range": {"start": {"line": 100, "column": 61}}}, "severity": "INFO"}

=== Embedded Realm Configuration

The embedded realm also supports the mapping of users to passwords and users to roles. It uses the main `application.properties` Quarkus configuration file to embed this information.
The embedded realm also supports the mapping of users to passwords and users to roles.
It uses the main `application.properties` Quarkus configuration file to embed this information.
They are configured with properties starting with `quarkus.security.users.embedded`.

The following is an example application.properties file section illustrating the embedded realm configuration:
Expand All @@ -112,11 +122,11 @@
quarkus.security.users.embedded.roles.noadmin=user
----

As with the first example, this file has usernames and passwords stored in plain text, which is not recommended. If plain text is set to false (or omitted) in the config, then passwords must be stored in the form `MD5 ( username : realm : password )`.
As with the first example, this file has usernames and passwords stored in plain text, which is not recommended.
If plain text is set to false (or omitted) in the config, then passwords must be stored in the form `MD5 ( username : realm : password )`.
This can be generated for the first example above by running the command `echo -n scott:MyRealm:jb0ss | md5` from the command line.


==== Embedded Users

Check warning on line 129 in docs/src/main/asciidoc/security-properties.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Headings] Use sentence-style capitalization in 'Embedded Users'. Raw Output: {"message": "[Quarkus.Headings] Use sentence-style capitalization in 'Embedded Users'.", "location": {"path": "docs/src/main/asciidoc/security-properties.adoc", "range": {"start": {"line": 129, "column": 6}}}, "severity": "INFO"}

The user to password mappings are specified in the `application.properties` file by properties keys of the form `quarkus.security.users.embedded.users.<user>=<password>`.
The following <<password-example>> illustrates the syntax with 4 user-to-password mappings:
Expand All @@ -130,6 +140,7 @@
quarkus.security.users.embedded.users.jdoe=p4ssw0rd
quarkus.security.users.embedded.users.noadmin=n0Adm1n
----

<1> User `scott` has password `jb0ss`
<2> User `stuart` has password `test`

Expand All @@ -147,6 +158,7 @@
quarkus.security.users.embedded.roles.jdoe=NoRolesUser
quarkus.security.users.embedded.roles.noadmin=user
----

<1> User `scott` has roles `Admin`, `admin`, `Tester`, and `user`
<2> User `stuart` has roles `admin` and `user`

Expand Down