Skip to content

Add 'GRANT DATABASE' to rbac #988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: Role-based access control
description: Learn how to set up role-based access control.
---

import { Callout } from 'nextra/components'

# Role-based access control (Enterprise)

Role-Based access control (RBAC) simplifies data security by grouping users into
Expand All @@ -16,7 +18,7 @@ role, enhancing security and minimizing risks.
With role-based access control, a database administrator can assign various
privileges to roles, but for even more control over who can access certain
data, Memgraph Enterprise offers [fine-grained access
control](/database-management/authentication-and-authorization/role-based-access-control#fine-grained-access-control).
control](#fine-grained-access-control).

## User roles

Expand Down Expand Up @@ -81,6 +83,7 @@ of the following commands:

| Privilege description | Clause |
| --------------------- | ------ |
| Privilege to [interact with a database](/database-management/multi-tenancy). | `DATABASE` |
| Privilege to [access data](/querying/read-and-modify-data). | `MATCH` |
| Privilege to [modify data](/querying/read-and-modify-data). | `MERGE`, `SET`|
| Privilege to [create](/querying/create-graph-objects) and [delete]](/querying/read-and-modify-data) data. | `CREATE`, `DELETE`, `REMOVE` |
Expand Down Expand Up @@ -193,6 +196,17 @@ DENY ALL PRIVILEGES TO <user>;
REVOKE ALL PRIVILEGES FROM <user>;
```

<Callout type="warning">
The user needs to reconnect to the database for the changes to take effect.
</Callout>

<Callout type="info">
If you get an error: `Vertex not created due to not having enough permission!` you probably need to grant the fine-grained access control to the user.
The [fine-grained access control](#fine-grained-access-control) section provides more details.
</Callout>



#### Show privileges

To check privilege for a certain user or role, run the following query:
Expand Down Expand Up @@ -310,6 +324,7 @@ To grant all privileges to a superuser (admin):

```
GRANT ALL PRIVILEGES TO admin;
GRANT DATABASE * to admin;
GRANT CREATE_DELETE ON LABELS * TO admin;
GRANT CREATE_DELETE ON EDGE_TYPES * TO admin;
```
Expand Down Expand Up @@ -346,6 +361,7 @@ label. Alice has already created a data analyst role as well as Bob's account in
CREATE ROLE analyst;
CREATE USER Bob IDENTIFIED BY 'test';
SET ROLE FOR Bob TO analyst;
GRANT DATABASE exampledb TO Bob;
```

Unfortunately, when he writes:
Expand Down Expand Up @@ -426,6 +442,7 @@ The administrator has already set up his account with the following commands:
CREATE ROLE tester;
CREATE USER Charlie IDENTIFIED BY 'test';
SET ROLE FOR Charlie TO tester;
GRANT DATABASE exampledb TO Charlie;

GRANT MATCH, SET TO tester;

Expand Down Expand Up @@ -463,6 +480,7 @@ following commands:
CREATE ROLE dataEngineer;
CREATE USER David IDENTIFIED BY 'test';
SET ROLE FOR David TO dataEngineer;
GRANT DATABASE exampledb TO David;

GRANT MATCH, DELETE TO dataEngineer;

Expand Down Expand Up @@ -505,6 +523,7 @@ database administrator therefore sets Eve's role as:
CREATE ROLE seniorEngineer;
CREATE USER Eve IDENTIFIED BY 'test';
SET ROLE FOR Eve TO seniorEngineer;
GRANT DATABASE exampledb TO Eve;

GRANT MATCH, DELETE TO seniorEngineer;

Expand Down