Enable Basic authentication
Enable Basic authentication for your Quarkus project and allow users to authenticate with a username and password.
Prerequisites
-
You have installed at least one extension that provides an
IdentityProvider
based on username and password, such as Elytron JDBC.
Procedure
-
Enable Basic authentication by setting the value of
quarkus.http.auth.basic
property totrue
.quarkus.http.auth.basic=true
An easy way to configure the required user credentials for Basic authentication to work is to configure the user name, secret, and roles directly in the application.properties
file.
quarkus.http.auth.basic=true
quarkus.security.users.embedded.plain-text=true
quarkus.security.users.embedded.users.alice=alice
quarkus.security.users.embedded.users.bob=bob
quarkus.security.users.embedded.roles.alice=admin
quarkus.security.users.embedded.roles.bob=user
In this configuration the credentials for users alice
and bob
are configured: alice
has a password alice
and an admin
role, bob
has a password bob
and a user
role.
For more information, see Configuring User Information in the "Security Testing" guide.
Configuring user names, secrets, and roles in the |
To walk through how to configure Basic authentication together with Jakarta Persistence for storing user credentials in a database, see the Secure a Quarkus application with Basic authentication tutorial.