-
Notifications
You must be signed in to change notification settings - Fork 387
Privileges and Access Control explained
Gleb Kashkin edited this page Oct 26, 2023
·
2 revisions
- We can grant/revoke one or several permissions to an object of obj_type:
box.schema.user.grant('alice', 'read,write', 'space', 'myspace')
- Note that the permissions have to be divided by ‘,’ without a space.
- We can grant/revoke one or several permissions to all objects of some type, including universe:
box.schema.user.grant('alice', 'execute', 'function')
box.schema.user.grant('alice', 'read,write', 'space')
box.schema.user.grant('alice', 'read', 'sequence')
- For some privileges, the
object_name
has to be specialized, otherwise, the grant doesn't have an effect:box.schema.user.grant('alice', 'execute', 'role', 'rolename')
box.schema.user.grant('alice', 'alter', 'user', 'username')
- On the contrary, the following privileges ignore object_name specialization:
box.schema.user.grant('alice', <any_perm>, 'universe')
box.schema.user.grant('alice', 'create'/'drop', 'user'/'role'/'space'/'function'/'sequence')
box.schema.user.grant('alice', 'execute', 'lua_eval'/'lua_call'/'sql')
- If empty string (
””
) is provided instead of object name, means the same as nil,— grant/revoke for all objects of the object type.
object_types:
- 'user'
- 'role'
- 'space'
- 'function'
- 'sequence'
- 'universe'
- 'lua_eval'
- 'lua_call'
- 'sql'
object_names:
- mostly user defined strings, provided by config or box
- special value
''
ornil
, when there is no object_name, e.g. for 'universe' object_type or for granting permission for all objects of a type.
priv_names:
- 'read'
- 'write'
- 'execute' - allowed only for ‘role’, ‘universe’, ‘function’, ‘lua_eval’, ‘lua_call’, ‘sql’
- 'session' - allowed only to users (not roles) for ‘universe’
- 'usage' - allowed only to users (not roles) for ‘universe’
- 'create'
- 'drop'
- 'alter'
- 'reference' - not implemented
- 'trigger' - not implemented
- 'insert' - not implemented
- 'update' - not implemented
- 'delete' - not implemented
box.schema.{role,user}.info()
has the grants in the following format:
- - - <priv_name>[,<priv_name>]...
- <object_type>
- <object_name> or <role_name> or <empty (if all objects of type)>
-
example
tarantool> box.schema.user.info('gleb') --- - - - execute - role - public - - read,write - space - my-space - - read - space - my-space2 - - session,usage - universe - - - alter - user - gleb ...
- read+write for my-space
- read for my-space2
- Has role
'public'
(by default for every user) - Has privileges
'session'
and'usage'
for'universe'
(by default for every user) - Modify (
’alter’
) index that describes the user (by default for every user)
box.space._priv
has the grants in the following format:
_priv
is a system space where privileges are stored.
Tuples in this space contain the following fields:
- the numeric id of the user who gave the privilege (“grantor_id”),
- the numeric id of the user who received the privilege (“grantee_id”),
- the type of object: ‘space’, ‘index’, ‘function’, ‘sequence’, ‘user’, ‘role’, ‘universe’, ‘lua_eval’, ‘lua_call’, ‘sql’
- the numeric id of the object,
- the type of operation: “read” = 1, “write” = 2, “execute” = 4, “create” = 32, “drop” = 64, “alter” = 128, or a combination such as “read,write,execute”.
Object types:
-
"universe"
-
"read"
- read everything, including allspace
orsequence
objects without specified grant -
"write"
- write to everything, including allspace
orsequence
objects without specified grant, alter stuff -
"execute"
- executefunction
(both inside_func
and_G
), Lua or SQL code includingIPROTO
calls -
"session"
- (cannot be granted to a role) if is not grated,IPROTO_AUTH
always fails for connection to the user, so doesbox.session.su()
-
"usage"
- (cannot be granted to a role) let user use their privileges on database objects (e.g. read, write and alter space) -
"create"
- create a user, role, function, space, sequence (requires"read,write"
for an according system space, it is to be grated explicitly) -
"drop"
- drop/delete a user, role, function, space, sequence (requires"read,write"
for an according system space) -
"alter"
- alter user settings or a space object -
"reference"
- not implemented (according tosrc/box/user_def.h:63
) -
"trigger"
- not implemented (according tosrc/box/user_def.h:65
) -
"insert"
- not implemented (according tosrc/box/user_def.h:67
) -
"update"
- not implemented (according tosrc/box/user_def.h:69
) -
"delete"
- not implemented (according tosrc/box/user_def.h71
)
-
-
"user"
-
"alter"
- modify users description, e.g. change the password -
"create"
- allowbox.schema.user.create()
(needs"read,write"
for space"_user"
) -
"drop"
- allowbox.schema.user.drop()
(needs"read,write"
for space"_user"
)
-
-
"role"
-
"execute"
- have the role assigned -
"create"
- allowbox.schema.role.create()
(needs"read,write"
for space"_role"
) -
"drop"
- allowbox.schema.role.drop()
(needs"read,write"
for space"_role"
)
-
-
"space"
-
"read"
- e.g. allow select from a space -
"write"
- e.g. allow update on a space -
"create"
- e.g. allowbox.schema.space.create
(needs"read,write"
for space"_space"
) -
"drop"
- e.g. allowbox.sequence.x:drop
(needs"read,write"
for space"_space"
) -
"alter"
- e.g. allowbox.space.x.index.y:alter
(needs"read,write"
for space"_space"
). If a space is created by a user, they can read/write it without explicit privilege -
"trigger"
- not implemented (according tosrc/box/user_def.h:67
) -
"insert"
- not implemented, doesn’t affectspace_obj:insert()
-
"update"
- not implemented (according tosrc/box/user_def.h:69
) -
"delete"
- not- implemented, doesn’t affectspace_obj:delete()
-
-
"function"
-
"execute"
- allow calls for functions registered in_func
(could be specified by"lua_eval"
,"lua_call"
,"sql"
). Note that it is different from"execute"
for“universe”
, as the latter performs lookup inside_G
too. -
"create"
- allowbox.schema.func.create()
(needs"read,write"
for space"_func"
). If a function is created by a user, they can execute it without explicit privilege -
"drop"
- allowbox.schema.func.drop()
(needs"read,write"
for space"_func"
)
-
-
"sequence"
-
"read"
- isn’t required for any sequence object operations, includingseq_obj:current()
, but when specifying a sequence inspace_obj:create_index()
"read"
is required -
"write"
- allow all sequence object operations, note thatseq_obj:drop()
requires write privilege to space_priv
-
"create"
- allowbox.schema.sequence.create()
(needs"read,write"
for space"_sequence"
). If a sequence is created by a user, they can read/write it without explicit privilege -
"drop"
- allowbox.schema.sequence.drop()
(needs"read,write"
for space"_sequence"
) -
"alter"
- does not have an effect,seq_obj:alter()
requires"write"
as do all the other methods
-
-
"lua_eval"
-
"execute"
- execute arbitrary Lua code with theIPROTO_EVAL
request (no obj_name specialization allowed)
-
-
"lua_call"
-
"execute"
- call any user-defined function accessible via the_G
Lua table with theIPROTO_CALL
request. .It does not permit the user to call built-in Lua functions, e.g.loadstring()
orbox.session.su()
nor the functions inside_func.
(no function-name specialization allowed)
-
-
"sql"
-
"execute"
- execute arbitrary SQL expression with theIPROTO_PREPARE
andIPROTO_EXECUTE
requests. Without"execute"
to"universe"
the user is not permitted to execute SQL expressions overIPROTO
anymore. (no obj_name specialization allowed)
-
- C coding guidelines ↗
- Lua coding guidelines ↗
- Python coding guidelines ↗
- Maintainer's guide
- Debugging
Architecture
- Server architecture
- R tree index quick start and usage
- LuaJIT
- Vinyl
- Vinyl Architecture
- Vinyl Disk Layout
- Vinyl math
- Vinyl Cookbook
- Bullet1
- SQL
- Appserver modules
- Testing
- Performance
- Privileges and Access control
How To ...?
- ... configure build system
- ... add new fuzzers
- ... build RPM or Deb package using packpack
- ... calculate memory size
- ... debug core dump of stripped tarantool
- ... debug core from different OS
- ... debug fuzzer
- ... generate new bootstrap snapshot
- ... use Address Sanitizer
- ... collect a coredump
- ... generate luacov report for builtin module
- ... verify modified lua files via luacheck
- ... verify Lua files in third_party?
- ... rerun failed jobs
- ... update a third party repository
- Fix wrong decimal indexing after upgrade to 2.10.1
- Caveats when upgrading a cluster on Tarantool 1.6
- Fix illegal field type in a space format when upgrading to 2.10.4
Useful links