Yubico / java-webauthn-server

Server-side Web Authentication library for Java https://www.w3.org/TR/webauthn/#rp-operations
Other
443 stars 139 forks source link

Postgres Database Incompatibility #251

Closed aasemani closed 1 year ago

aasemani commented 1 year ago

I am trying to use a Postgres instead of the H2 DB for my application. When switching to Postgres DB I get errors relating to column type. I have tried multiple different types such as OID, VARCHAR, BIGINT,... . Is the application compatible with Postgres? What are the databases I can use other than H2 for the passkey to work?

java.lang.IllegalArgumentException: Parameter value [ByteArray(0b1a119b1c68f9756e3b0046d49bb46c06ec99759153439a3c40a7ee9075dbb1)] did not match expected type [[B (n/a)] at org.hibernate.query.spi.QueryParameterBindingValidator.validate(QueryParameterBindingValidator.java:54) ~[hibernate-core-5.6.12.Final.jar:5.6.12.Final] at org.hibernate.query.spi.QueryParameterBindingValidator.validate(QueryParameterBindingValidator.java:27) ~[hibernate-core-5.6.12.Final.jar:5.6.12.Final] at org.hibernate.query.internal.QueryParameterBindingImpl.validate(QueryParameterBindingImpl.java:90) ~[hibernate-core-5.6.12.Final.jar:5.6.12.Final]

emlun commented 1 year ago

Hi! The library is completely database-agnostic, so any database should work. In particular, I don't think the library nor its tests or the demo application has ever had a dependency on H2.

It looks like you might be trying to directly persist a RegisteredCredential instance, which isn't working because you have no ORM mapping for how to persist a com.yubico.webauthn.data.ByteArray. You might need to convert the RegisteredCredential to your own ORM type for storage and then re-assemble it in your CredentialRepository method implementations, or alternatively define type mappings so your ORM can persist a RegisteredCredential directly if you prefer that.

See also #173.

aasemani commented 1 year ago

@emlun thank you for the help. I was able to get it working by converting all the ByteArray variables to string and saving them as varchar in database. Also needed to remove @lob annotation.