Search code examples
apachejdbcneo4jshiro

Configuring Apache Shiro to work with Neo4j


I am trying to configure Apache Shiro to work with Neo4j using the shiro.ini file.

This is my shiro.ini part of the file responsible for authentication:

...
ds = org.apache.shiro.jndi.JndiObjectFactory
ds.resourceName = java:comp/env/jdbc/Neo4jDb
# What type do I set here
ds.requiredType = 

jdbcRealm = org.apache.shiro.realm.jdbc.JdbcRealm
jdbcRealm.permissionsLookupEnabled = true
jdbcRealm.authenticationQuery = <Cypher Query>
jdbcRealm.userRolesQuery = <Cypher Query>
jdbcRealm.permissionsQuery = <Cypher Query>
jdbcRealm.credentialsMatcher = $passwordMatcher
jdbcRealm.dataSource=$ds
securityManager.realms = $jdbcRealm
...

And in my context.xml

...
<Resource auth="Container" driverClassName="org.neo4j" maxIdle="30" maxTotal="50" maxWaitMillis="10000" 
        name="jdbc/Neo4jDb" password="p4ssw0rd" type="" url="jdbc:neo4j:bolt://localhost/" username="neo4j"/>

My question is, what type do I set in shiro.ini and context.xml <Resource ... type=" " ...>

If this doesn't work, I'm interested in alternative solutions on how to make shiro work with neo4j, or even better if neo4j has a good built in authentification and authorization, I'm willing to use that as a solution.


Solution

  • You should not need to set it, are you running into an existing problem?

    Here are a couple of examples: http://shiro-user.582556.n2.nabble.com/How-to-use-a-DataSource-from-JNDI-td7566161.html

    https://github.com/danielmt/shiro-primefaces-example/blob/master/src/main/webapp/WEB-INF/shiro.ini

    Are you using the correct driver class in your context.xml ?