Neo4j Java Driver connect to db as application user instead of service account

Copied from initial slack discussion to keep track of the outcome:

Currently I have a database with multiple sub graphs (disconnected from each other). This seems like a perfect fit to create a database for each sub graph.
I understand I can supply the databasename in the driver.session() call to query the right database/subgraph.
What I am wondering about is how to use the RBAC features in addition to this. If I created multiple roles with different privileges and connect users to those roles, then I need to also login to the database with those users instead of the generic neo4j user from our API.
Does the neo4j java driver have options for this?

1 Like
try (Session session = driver.session(SessionConfig.builder().withDatabase("someDatabase").build())) {
            session.run("MATCH (m:Movie) RETURN m ORDER BY m.name ASC").stream()
                .map(r -> r.get("m").asNode())
                .map(n -> n.get("title").asString())
                .forEach(LOGGER::info);
        }

to choose the database is possible. But I think we also need something like this:

try (Session session = driver.session(SessionConfig.builder().withDatabase("someDatabase").assumeRole("reader").build())) {
            session.run("MATCH (m:Movie) RETURN m ORDER BY m.name ASC").stream()
                .map(r -> r.get("m").asNode())
                .map(n -> n.get("title").asString())
                .forEach(LOGGER::info);
        }

Max Demarzi responded: You brought up a good point btw, now were talking about ways to pass the user in the session.

https://rocksolutions.blog/2010/03/23/proxy-authentication-in-oracle-jdbc/

Is how oracle enables using a proxy user. This seems like a possible feature for the neo4j driver and db