tomcatneo4jjdbcrealm

Setup Neo4j with Apache Tomcat's JDBCRealm


We are trying to use the JDBCRealm to authenticate users with the neo4j database. We followed all the steps in the JDBCRealm documentation and we think that neo4j is not supported.

When trying to authenticate a user it sends queries that aren't in the cypher language. For example, we get:

Caused by: java.lang.RuntimeException: Error executing cypher statement(s) [{code=Neo.ClientError.Statement.InvalidSyntax, message=Invalid input 'L': expected 't/T' (line 1, column 3 (offset: 2)) "SELECT user_pass FROM users WHERE user_name = {1}" ^}]

The error occurs when filling the HTTP BASIC authentication form and submitting.

Details:

  1. We added the JDBCRealm to the tomcat server.xml

  2. We added user authentication to all our web apps pages in the web.xml file

  3. We use BASIC authentication

Might neo4j not even be supported for JDBCRealm?

Thanks.


Solution

  • You cannot use JDBCRealm with Neo4j. The reason is that JDBCRealm builds an SQL statement under the hoods depending on your config (tablename, columns, etc.).

    The JDBC driver for Neo4j is "just" a transport layer for Cypher, therefore you cannot send SQL.

    I can think of creating a CypherRealm for tomcat that emits then something like MATCH (u:User{name:{name}}) RETURN u.