Skip to content

Commit

Permalink
Merge pull request #854 from neo4j-labs/feature/rbac_feature_updates
Browse files Browse the repository at this point in the history
Update role selector menu + more robust user updates
  • Loading branch information
mariusconjeaud authored Apr 18, 2024
2 parents 0bd87b8 + ec61cb1 commit 85f4e4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/extensions/rbac/RBACManagementMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const RBACManagementMenu = ({ anchorEl, MenuOpen, handleClose, createNoti
onClose={handleClose}
size='small'
>
<MenuItems>
<MenuItems className='n-overflow-y-scroll n-h-44'>
{roles.map((role) => (
<MenuItem key={role} onClick={() => handleRoleClicked(role)} icon={<UserIconOutline />} title={role} />
))}
Expand Down
6 changes: 4 additions & 2 deletions src/extensions/rbac/RBACUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,11 @@ export function retrieveDatabaseList(driver, setDatabases: React.Dispatch<React.
export async function updateUsers(driver, currentRole, allUsers, selectedUsers, onSuccess, onFail) {
// 1. Build the query that removes all users from the role.
let globalStatus = -1;
const escapedAllUsers = allUsers.map((user) => `\`${user}\``).join(',');
await runCypherQuery(
driver,
'system',
`REVOKE ROLE ${currentRole} FROM ${allUsers.join(',')}`,
`REVOKE ROLE ${currentRole} FROM ${escapedAllUsers}`,
{},
1000,
(status) => {
Expand All @@ -277,10 +278,11 @@ export async function updateUsers(driver, currentRole, allUsers, selectedUsers,
// TODO: Neo4j is very slow in updating after the previous query, even though it is technically a finished query.
// We build in an artificial delay...
if (selectedUsers.length > 0) {
const escapedSelectedUsers = selectedUsers.map((user) => `\`${user}\``).join(',');
await runCypherQuery(
driver,
'system',
`GRANT ROLE ${currentRole} TO ${selectedUsers.join(',')}`,
`GRANT ROLE ${currentRole} TO ${escapedSelectedUsers}`,
{},
1000,
(status) => {
Expand Down

0 comments on commit 85f4e4f

Please sign in to comment.