diff --git a/security-jpa-quickstart/README.md b/security-jpa-quickstart/README.md index b8a9f74434..e1def8d68d 100644 --- a/security-jpa-quickstart/README.md +++ b/security-jpa-quickstart/README.md @@ -1,29 +1,40 @@ -Quarkus Elytron Security with JPA +Quarkus Security with JPA ======================== This guide demonstrates how your Quarkus application can use a database and JPA to store your user identities. -## Start the database +## Run quickstart in developer mode -You need a database to store the user identities/roles. Here, we are using [PostgreSQL](https://www.postgresql.org). -To ease the setup, we have provided a `docker-compose.yml` file which start a PostgreSQL container, bind the network ports -and finally creates the users and their credentials by importing the `import.sql` file. +Quarkus provides developer mode, in which you can try this example. Just try: -The database can be started using: - ```bash - docker-compose up - ``` +```bash +mvn quarkus:dev +``` -Once the database is up you can start your Quarkus application. +Now the application will listen on `localhost:8080`. +In developer mode quarkus will also start its own postgres database. -Note you do not need to start the database when running your application in dev mode or testing. It will be started automatically as a Dev Service. +## Run quickstart in JVM mode -## Start the application +### Start the database -The application can be started using: +Now we need to start a [PostgreSQL](https://www.postgresql.org) database on our own. +To set it up with docker: ```bash -mvn compile quarkus:dev +docker run -it --rm=true --name quarkus_test -e POSTGRES_USER=quarkus -e POSTGRES_PASSWORD=quarkus -e POSTGRES_DB=quarkus -p 5432:5432 postgres:15.3 +``` + +Once the database is up, you can start your Quarkus application. +Application will fill in the users and their credentials on `StartupEvent`. + +### Start the application + +The application can be build & started using: + +```bash +mvn clean package +java -jar target/quarkus-app/quarkus-run.jar ``` ## Test the application @@ -34,7 +45,7 @@ The application exposes 3 endpoints: * `/api/admin` * `/api/users/me` -You can try these endpoints with an http client (`curl`, `HTTPie`, etc). +You can try these endpoints with a http client (`curl`, `HTTPie`, etc). Here you have some examples to check the security configuration: ```bash @@ -45,8 +56,6 @@ curl -i -X GET http://localhost:8080/api/users/me # 'unauthorized' curl -i -X GET -u user:user http://localhost:8080/api/users/me # 'user' ``` -_NOTE:_ Stop the database using: `docker-compose down; docker-compose rm` - ### Integration testing We have provided integration tests based on [Dev Services for PostgreSQL](https://quarkus.io/guides/dev-services#databases) to verify the security configuration in JVM and native modes. The test and dev modes containers will be launched automatically because all the PostgreSQL configuration properties are only enabled in production (`prod`) mode. diff --git a/security-jpa-quickstart/docker-compose.yml b/security-jpa-quickstart/docker-compose.yml deleted file mode 100644 index b2f799e403..0000000000 --- a/security-jpa-quickstart/docker-compose.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: "3" -services: - database: - image: "postgres:10.5" - container_name: "elytron-security-jpa-database" - ports: - - "5432:5432" - volumes: - - ./init.sql:/docker-entrypoint-initdb.d/init.sql diff --git a/security-jpa-quickstart/init.sql b/security-jpa-quickstart/init.sql deleted file mode 100644 index 4abdfc76fa..0000000000 --- a/security-jpa-quickstart/init.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE ROLE quarkus WITH LOGIN PASSWORD 'quarkus'; -CREATE DATABASE elytron_security_jpa; -GRANT ALL PRIVILEGES ON DATABASE elytron_security_jpa TO quarkus; -\c elytron_security_jpa - diff --git a/security-jpa-quickstart/pom.xml b/security-jpa-quickstart/pom.xml index b75728c1b7..db121b6568 100644 --- a/security-jpa-quickstart/pom.xml +++ b/security-jpa-quickstart/pom.xml @@ -9,8 +9,8 @@ quarkus-bom io.quarkus 999-SNAPSHOT - 3.8.1 - 3.0.0-M7 + 3.11.0 + 3.1.2 11 11 true diff --git a/security-jpa-quickstart/src/main/resources/application.properties b/security-jpa-quickstart/src/main/resources/application.properties index 0ef9880c6b..b4f6cf262b 100644 --- a/security-jpa-quickstart/src/main/resources/application.properties +++ b/security-jpa-quickstart/src/main/resources/application.properties @@ -1,6 +1,6 @@ %prod.quarkus.datasource.db-kind=postgresql %prod.quarkus.datasource.username=quarkus %prod.quarkus.datasource.password=quarkus -%prod.quarkus.datasource.jdbc.url=jdbc:postgresql:elytron_security_jpa +%prod.quarkus.datasource.jdbc.url=jdbc:postgresql://localhost/quarkus quarkus.hibernate-orm.database.generation=drop-and-create