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

hibernate-reactive combined with plain jdbc connection for quarkus security jdbc #14986

Open
heyplusyou opened this issue Feb 10, 2021 · 4 comments
Labels
area/security kind/enhancement New feature or request

Comments

@heyplusyou
Copy link

Describe the bug
Defining a reactive datasource and a non-reactive jdbc datasource causes issues during startup. This happens if reactive and non-reactive data source share "default" and as well if the datasources are defined separately.

Expected behavior
hibernate-reactive orm uses reactive datasource, quarkus-security-jdbc uses non-reactive jdbc datasource

Actual behavior
Issues during startup e.g. with desperately defined data sources:

Caused by: io.quarkus.runtime.configuration.ConfigurationException: The datasource 'vcereactive' is not configured but the persistence unit 'vcereactive' uses it.
        at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.lambda$producePersistenceUnitDescriptorFromConfig$4(HibernateOrmProcessor.java:740)
        at java.base/java.util.Optional.orElseThrow(Optional.java:408)
        at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.producePersistenceUnitDescriptorFromConfig(HibernateOrmProcessor.java:739)
        at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.handleHibernateORMWithNoPersistenceXml(HibernateOrmProcessor.java:703)
        at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.configurationDescriptorBuilding(HibernateOrmProcessor.java:310)

To Reproduce

Link to a small reproducer (preferably a Maven project if the issue is not Gradle-specific).
https://github.com/heyplusyou/code-with-quarkus

Steps to reproduce the behavior:

  1. add hibernate-reactive
  2. add quarkus-security
  3. configure datasources

Configuration

quarkus.datasource.jdbc=true
quarkus.datasource.reactive=false
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=postgres
quarkus.datasource.password=postgres
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/quarkus_test

quarkus.datasource.vcereactive.jdbc=false
quarkus.datasource.vcereactive.reactive=true
quarkus.datasource.vcereactive.db-kind=postgresql
quarkus.datasource.vcereactive.username=postgres
quarkus.datasource.vcereactive.password=postgres
quarkus.datasource.vcereactive.reactive.url=vertx-reactive:postgresql://localhost/quarkus_test

quarkus.hibernate-orm.vcereactive.datasource=vcereactive
quarkus.hibernate-orm.vcereactive.database.generation=drop-and-create
quarkus.hibernate-orm.vcereactive.packages=org.acme
# quarkus.hibernate-orm.vcereactive.log.sql=true

# AUTHENTIFICATION
quarkus.security.jdbc.enabled=true
quarkus.security.jdbc.principal-query.sql=SELECT u.password FROM person u WHERE u.name=?
quarkus.security.jdbc.principal-query.clear-password-mapper.enabled=true
quarkus.security.jdbc.principal-query.clear-password-mapper.password-index=1

Screenshots
(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

  • Output of uname -a or ver:
    Linux pop-os 5.8.0-7642-generic Migrate Logging to Gizmo #47161228899020.10~b8113e7-Ubuntu SMP Wed Feb 3 02:27:26 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

  • Output of java -version:
    openjdk version "11.0.9" 2020-10-20
    OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11)
    OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9+11, mixed mode)

  • GraalVM version (if different from Java):

  • Quarkus version or git rev: 1.11.2

  • Build tool (ie. output of mvnw --version or gradlew --version): Gradle 6.5.1

@heyplusyou heyplusyou added the kind/bug Something isn't working label Feb 10, 2021
@ghost ghost added the area/security label Feb 10, 2021
@ghost
Copy link

ghost commented Feb 10, 2021

/cc @sberyozkin

@heyplusyou heyplusyou changed the title hibernate-reactive combined with plain jdbc connectionfor quarkus security jdbc hibernate-reactive combined with plain jdbc connection for quarkus security jdbc Feb 10, 2021
@sberyozkin
Copy link
Member

CC @stuartwdouglas @FroMage

@gsmet
Copy link
Member

gsmet commented Feb 15, 2021

Hibernate Reactive does not support named datasources at the moment.

Unfortunately, I don't think you can make your setup work at the moment.

That being said, if you're using JDBC and thus a blocking implementation for security, I really don't see the point in trying Hibernate Reactive. I would stay on plain Hibernate ORM.

@gsmet gsmet added kind/enhancement New feature or request and removed kind/bug Something isn't working labels Feb 15, 2021
@LoweloDev
Copy link

LoweloDev commented Dec 17, 2021

Hibernate Reactive does not support named datasources at the moment.

Unfortunately, I don't think you can make your setup work at the moment.

That being said, if you're using JDBC and thus a blocking implementation for security, I really don't see the point in trying Hibernate Reactive. I would stay on plain Hibernate ORM.

I came here because I had the same issue but now have a little off-topic design question as a student:
Would you generally suggest to rather use a seperate application for security stuff (seperate from reactive stuff)? Cause It would make sense to me. You don't really need reactive behaviour in terms of user management I think. Also I could just fetch necessary account information to my reactive part of the backend and basically keep that synced. And I could make sure with another authentication layer that only my app connects to that security app and nobody else.

Nevermind. I forgot that you can just create a new project via the quarkus.io tool and import it as a new module. I forgot that java & intellij have this module thing. Silly me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/security kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants