Overview
A database user has access to the database system and can perform various querying or administering operations based on their assigned privileges.
Showing Users
To list all database users:
show().user()
Or retrieves a specific user, such as the one named root
:
show().user("root")
Or retrieves the current logged-in user:
show().self()
It returns a table _user
with the following fields:
Field |
Description |
---|---|
username |
Name of the user. |
create |
The date and time when the user was created. |
graphPrivileges |
Graph privileges granted to the user. |
systemPrivileges |
System privileges granted to the user. |
propertyPrivileges |
Property privileges granted to the user. |
policies |
Policies granted to the user. |
Creating a User
The create().user().params()
statement creates a database user.
Syntax
create().user("<username>", "<password>").params({
graph_privileges: {
"<graph>": ["<graphPriv>", "<graphPriv>", ...],
...
},
system_privileges: ["<systemPriv>", "<systemPriv>", ...],
property_privileges: {
"node": {
"<propertyPriv>": [
["<graph>", "<schema>", "<property>"],
...
],
...
},
"edge": {
"<propertyPriv>": [
["<graph>", "<schema>", "<property>"],
...
],
...
}
},
policies: ["<policyName>", "<policyName>", ...]
})
Method | Param | Description |
---|---|---|
user() |
<name> |
The unique name of the user. Naming conventions are:
|
<password> |
The password of the user, which must be between 6 to 64 characters in length. | |
params() |
graph_privileges |
Specifies graph privileges for each graphset granted to the user; uses "*" to specify all graphsets. |
system_privileges |
Specifies system privileges granted to the user. | |
property_privileges |
Specifies node and edge property privileges granted to the user; uses ["*", "*", "*"] to specify all graphsets, all schemas, or all properties. |
|
policies |
Specifies policies granted to the user. |
Examples
To create a user called admin
that has all graph and system privileges, along with write
privilege for all properties, without having any other policies:
create().user("admin", "U7MRDBFXd2Ab").params({
graph_privileges: {"*":["READ","INSERT","UPSERT","UPDATE","DELETE","CREATE_SCHEMA","DROP_SCHEMA","ALTER_SCHEMA","SHOW_SCHEMA","RELOAD_SCHEMA","CREATE_PROPERTY","DROP_PROPERTY","ALTER_PROPERTY","SHOW_PROPERTY","CREATE_FULLTEXT","DROP_FULLTEXT","SHOW_FULLTEXT","CREATE_INDEX","DROP_INDEX","SHOW_INDEX","LTE","UFE","CLEAR_JOB","STOP_JOB","SHOW_JOB","ALGO","CREATE_PROJECT","SHOW_PROJECT","DROP_PROJECT","CREATE_HDC_GRAPH","SHOW_HDC_GRAPH","DROP_HDC_GRAPH","COMPACT_HDC_GRAPH"]},
system_privileges: ["TRUNCATE","COMPACT","CREATE_GRAPH","SHOW_GRAPH","DROP_GRAPH","ALTER_GRAPH","TOP","KILL","STAT","SHOW_POLICY","CREATE_POLICY","DROP_POLICY","ALTER_POLICY","SHOW_USER","CREATE_USER","DROP_USER","ALTER_USER","SHOW_PRIVILEGE","SHOW_META","SHOW_SHARD","ADD_SHARD","DELETE_SHARD","SHOW_HDC_SERVER","ADD_HDC_SERVER","DELETE_HDC_SERVER","LICENSE_UPDATE","LICENSE_DUMP"],
property_privileges: {
"node": {"write": [["*", "*", "*"]]},
"edge": {"write": [["*", "*", "*"]]}
}
})
To create a user called johndoe
that has:
- Graph privileges:
UPDATE
for all graphsets - System privileges:
SHOW_POLICY
,ALTER_GRAPH
- Property privileges:
read
all node properties for all schemas in all graphsetswrite
edge propertiesvalue
andtime
for all schemas in the graphsetTax
deny
(Do not allowread
andwrite
) edge propertyscore
for the schemarate
in the graphsetminiCircle
- Policies:
manager
create().user("johndoe", "mHMUUjQWG46z").params({
graph_privileges: {"*": ["UPDATE"]},
system_privileges: ["SHOW_POLICY", "ALTER_GRAPH"],
property_privileges: {
"node": {
"read": [
["*", "*", "*"]
]
},
"edge": {
"write": [
["Tax", "*", "value"],
["Tax", "*", "time"]
],
"deny": [
["miniCircle", "rates", "score"]
]
}
},
policies: ["manager"]
})
Altering an User
You can alter the password, and the privileges and policies a user has using the alter().user().set()
statement.
Syntax
alter().user("<username>").set({
password: "<password>",
graph_privileges: {
"<graph>": ["<graphPriv>", "<graphPriv>", ...],
...
},
system_privileges: ["<systemPriv>", "<systemPriv>", ...],
property_privileges: {
"node": {
"<propertyPriv>": [
["<graph>", "<schema>", "<property>"],
...
],
...
},
"edge": {
"<propertyPriv>": [
["<graph>", "<schema>", "<property>"],
...
],
...
}
},
policies: ["<policyName>", "<policyName>", ...]
})
Method | Param | Description |
---|---|---|
user() |
<username> |
Name of the user. |
set() |
<password> |
The new password of the user, which must be between 6 to 64 characters in length. |
graph_privileges |
Specifies new graph privileges for each graphset granted to the user; uses "*" to specify all graphsets. |
|
system_privileges |
Specifies new system privileges granted to the user. | |
property_privileges |
Specifies new node and edge property privileges granted to the user; uses ["*", "*", "*"] to specify all graphsets, all schemas, or all properties. |
|
policies |
Specifies new policies granted to the user. |
Examples
To modify user admin
's password while keeping his privileges and policies unchanged:
alter().user("admin").set({password: "zdcsQ7QFaCCE"})
To modify user johndoe
's graph and property privileges, and policies, while keeping his password and system privileges unchanged:
alter().user("johndoe").set({
graph_privileges: {"*": ["UPDATE", "DELETE"]},
property_privileges: {
"node": {
"write": [["miniCircle","*","*"]]
},
"edge": {
"write": [["miniCircle","*","*"]]
}
},
policies: ["sales"]
})
Dropping a User
You can drop a user using the drop().user()
statement.
To drop the user johndoe
:
drop().user("johndoe")