neo4j / neo4j-javascript-driver

Neo4j Bolt driver for JavaScript

Home Page:https://neo4j.com/docs/javascript-manual/current/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] grant acces to role not working for first query

wasap opened this issue · comments

commented

i have admin user and regular_user
when regular_user tries to execute query, i start session for admin and grant regular user role for this label:

const driver = neo4j.driver(config.url, neo4j.auth.basic(admin, config.password));
const session = driver.session({ database: config.database }); 
await session.run(`GRANT CREATE ON GRAPH NEO NODE LABEL TO regular_user`);
await session.close();
await driver.close(); 

then i start session for regular user and try to execute simple create query:

const driver = neo4j.driver(config.url, neo4j.auth.basic(regular_user, config.regular_password));
const session = driver.session({ database: config.database }); 
await session.run(`create (n:LABEL)`);
await session.close();
await driver.close(); 

here i get an error for first time:
Create node with labels 'LABEL' is not allowed for user 'regular_user'
but if i run this query once more, i get success responce.
if i run show user privileges after grant and before executing regular_user query, it responds that LABEL access is granted, but hen it fails

cound it be some function that i need to trigger to apply granted role?

You should probably get the bookmark from the first session and pass it along to the second one.

Note: this kind of question is better asked in community.neo4j.com. GitHub issues are first and foremost about reporting bugs with the driver.
Note 2: the conventional case for labels is PascalCase, not UPPERCASE (upper case is usually used for relationship types)

commented

Yep, that's a neo isuue, thanks. I tried in neo browser and have the same error

@wasap have you tried using bookmarks?

commented

I tried to grant access in neo browser and then connect via nodejs driver and got the same error. So the issue is with db, creating node with label works fine after retry