Skip to content

Commit 3a01294

Browse files
committed
Credentials: topic - update
1 parent e54b803 commit 3a01294

File tree

1 file changed

+148
-71
lines changed

1 file changed

+148
-71
lines changed

doc/book/admin/access_control.rst

Lines changed: 148 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ at the start of the transaction using :doc:`/reference/reference_lua/box_session
213213

214214
.. _access_control_users:
215215

216-
Users
217-
-----
216+
Managing users
217+
--------------
218218

219219
.. _access_control_user_creating:
220220

@@ -286,29 +286,6 @@ Learn more about granting privileges to different types of objects from :ref:`ac
286286

287287

288288

289-
.. _access_control_user_revoking_privileges:
290-
291-
Revoking user's privileges
292-
~~~~~~~~~~~~~~~~~~~~~~~~~~
293-
294-
To revoke the specified privileges, use the :ref:`box.schema.user.revoke() <box_schema-user_revoke>` function.
295-
In the example below, write access to the ``books`` space is revoked:
296-
297-
.. literalinclude:: /code_snippets/test/access_control/grant_user_privileges_test.lua
298-
:language: lua
299-
:start-after: Revoke space reading
300-
:end-before: End: Revoke space reading
301-
:dedent:
302-
303-
Revoking the 'session' privilege from 'universe' can be used to disallow a user to connect to a Tarantool instance:
304-
305-
.. literalinclude:: /code_snippets/test/access_control/grant_user_privileges_test.lua
306-
:language: lua
307-
:start-after: Revoke session
308-
:end-before: End: Revoke session
309-
:dedent:
310-
311-
312289
.. _access_control_user_info:
313290

314291
Getting a user's information
@@ -348,7 +325,7 @@ To get information about privileges granted to a user, call :ref:`box.schema.use
348325
349326
In the example above, 'testuser' has the following privileges:
350327

351-
* The 'execute' privilege to the 'public' role means that this role is assigned to a user.
328+
* The 'execute' privilege to the 'public' role means that this role is :ref:`assigned to a user <access_control_roles_granting_user>`.
352329

353330
* The 'read' privilege to the ``writers`` space means that a user can read data from this space.
354331

@@ -361,17 +338,28 @@ In the example above, 'testuser' has the following privileges:
361338

362339
* The 'alter' privilege lets 'testuser' modify its own settings, for example, a password.
363340

364-
.. _access_control_users_dropping:
365341

366-
Dropping users
367-
~~~~~~~~~~~~~~
368342

369-
To drop the specified user, call :ref:`box.schema.user.drop() <box_schema-user_drop>`:
343+
.. _access_control_user_revoking_privileges:
344+
345+
Revoking user's privileges
346+
~~~~~~~~~~~~~~~~~~~~~~~~~~
347+
348+
To revoke the specified privileges, use the :ref:`box.schema.user.revoke() <box_schema-user_revoke>` function.
349+
In the example below, write access to the ``books`` space is revoked:
370350

371351
.. literalinclude:: /code_snippets/test/access_control/grant_user_privileges_test.lua
372352
:language: lua
373-
:start-after: Drop a user
374-
:end-before: End: Drop a user
353+
:start-after: Revoke space reading
354+
:end-before: End: Revoke space reading
355+
:dedent:
356+
357+
Revoking the 'session' privilege from 'universe' can be used to disallow a user to connect to a Tarantool instance:
358+
359+
.. literalinclude:: /code_snippets/test/access_control/grant_user_privileges_test.lua
360+
:language: lua
361+
:start-after: Revoke session
362+
:end-before: End: Revoke session
375363
:dedent:
376364

377365

@@ -412,22 +400,41 @@ The current user can be changed:
412400

413401

414402

403+
.. _access_control_users_dropping:
404+
405+
Dropping users
406+
~~~~~~~~~~~~~~
407+
408+
To drop the specified user, call :ref:`box.schema.user.drop() <box_schema-user_drop>`:
409+
410+
.. literalinclude:: /code_snippets/test/access_control/grant_user_privileges_test.lua
411+
:language: lua
412+
:start-after: Drop a user
413+
:end-before: End: Drop a user
414+
:dedent:
415+
416+
417+
418+
415419
.. _authentication-roles:
416420
.. _access_control_roles:
417421

418-
Roles
419-
-----
422+
Managing roles
423+
--------------
420424

421425
.. _access_control_roles_creating:
422426

423427
Creating a role
424428
~~~~~~~~~~~~~~~
425429

426-
To create a new role, call :ref:`box.schema.role.create() <box_schema-role_create>`:
427-
428-
.. code-block:: lua
430+
To create a new role, call :ref:`box.schema.role.create() <box_schema-role_create>`.
431+
In the example below, two roles are created:
429432

430-
box.schema.role.create('books_space_reader')
433+
.. literalinclude:: /code_snippets/test/access_control/grant_roles_test.lua
434+
:language: lua
435+
:start-after: Create roles
436+
:end-before: End: Create roles
437+
:dedent:
431438

432439

433440
.. _access_control_roles_granting_privileges:
@@ -436,11 +443,21 @@ Granting privileges to a role
436443
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
437444

438445
To grant the specified privileges to a role, use the ``box.schema.role.grant()`` function.
439-
In the example below, the 'books_space_reader' role gets read privileges to the ``books`` space:
446+
In the example below, the 'books_space_manager' role gets read and write privileges to the ``books`` space:
440447

441-
.. code-block:: lua
448+
.. literalinclude:: /code_snippets/test/access_control/grant_roles_test.lua
449+
:language: lua
450+
:start-after: Grant read/write privileges to a role
451+
:end-before: Grant write privileges to a role
452+
:dedent:
453+
454+
The 'writers_space_reader' role gets read privileges to the ``books`` space:
442455

443-
box.schema.role.grant('books_space_reader','read','space','books')
456+
.. literalinclude:: /code_snippets/test/access_control/grant_roles_test.lua
457+
:language: lua
458+
:start-after: Grant write privileges to a role
459+
:end-before: End: Grant privileges to roles
460+
:dedent:
444461

445462
Learn more about granting privileges to different types of objects from :ref:`access_control_granting_privileges`.
446463

@@ -456,25 +473,28 @@ Granting a role to a role
456473
~~~~~~~~~~~~~~~~~~~~~~~~~
457474

458475
Roles can be assigned to other roles.
459-
In the example below, the 'books_space_manager' role gets all privileges granted to 'books_space_reader':
476+
In the example below, the newly created 'all_spaces_manager' role gets all privileges granted to 'books_space_manager' and 'writers_space_reader':
460477

461-
.. code-block:: lua
462-
463-
box.schema.role.create('books_space_manager')
464-
box.schema.role.grant('books_space_manager', 'books_space_reader')
478+
.. literalinclude:: /code_snippets/test/access_control/grant_roles_test.lua
479+
:language: lua
480+
:start-after: Grant a role to a role
481+
:end-before: End: Grant a role to a role
482+
:dedent:
465483

466484

467485
.. _access_control_roles_granting_user:
468486

469487
Granting a role to a user
470488
~~~~~~~~~~~~~~~~~~~~~~~~~
471489

472-
To grant the specified role to a user, use the ``box.schema.user.grant()`` function.
473-
In the example below, 'testuser' gets privileges granted to the 'books_space_reader' role:
490+
To grant the specified role to a :ref:`user <access_control_users>`, use the ``box.schema.user.grant()`` function.
491+
In the example below, 'testuser' gets privileges granted to the 'books_space_manager' and 'writers_space_reader' roles:
474492

475-
.. code-block:: lua
476-
477-
box.schema.user.grant('testuser','books_space_reader')
493+
.. literalinclude:: /code_snippets/test/access_control/grant_roles_test.lua
494+
:language: lua
495+
:start-after: Grant a role to a user
496+
:end-before: End: Grant a role to a user
497+
:dedent:
478498

479499

480500
.. _access_control_roles_info:
@@ -486,7 +506,7 @@ To check whether the specified role exists, call :ref:`box.schema.role.exists()
486506

487507
.. code-block:: lua
488508
489-
box.schema.role.exists('books_space_reader')
509+
box.schema.role.exists('books_space_manager')
490510
--[[
491511
- true
492512
--]]
@@ -495,14 +515,45 @@ To get information about privileges granted to a role, call :ref:`box.schema.rol
495515

496516
.. code-block:: lua
497517
498-
box.schema.role.info('books_space_reader')
518+
box.schema.role.info('books_space_manager')
499519
--[[
500-
- - read
520+
- - - read,write
501521
- space
502522
- books
503523
--]]
504524
505-
In the example above, the 'read' privilege to the ``books`` space means that a user with the 'books_space_reader' role can read data from this space.
525+
If a role has the 'execute' privilege to other roles, this means that these roles are :ref:`granted to this parent role <access_control_roles_granting_role>`:
526+
527+
.. code-block:: lua
528+
529+
box.schema.role.info('all_spaces_manager')
530+
--[[
531+
- - - execute
532+
- role
533+
- books_space_manager
534+
- - execute
535+
- role
536+
- writers_space_reader
537+
--]]
538+
539+
540+
541+
542+
.. _access_control_roles_revoking_role:
543+
544+
Revoking a role from a user
545+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
546+
547+
To revoke the specified role from a user, revoke the 'execute' privilege for this role using the :ref:`box.schema.user.revoke() <box_schema-user_revoke>` function.
548+
In the example below, the 'books_space_reader' role is revoked from 'testuser':
549+
550+
.. literalinclude:: /code_snippets/test/access_control/grant_roles_test.lua
551+
:language: lua
552+
:start-after: Revoking a role from a user
553+
:end-before: End: Revoking a role from a user
554+
:dedent:
555+
556+
To revoke role's privileges, use :ref:`box.schema.role.revoke() <box_schema-role_revoke>`.
506557

507558

508559
.. _access_control_roles_dropping:
@@ -512,9 +563,11 @@ Dropping roles
512563

513564
To drop the specified role, call :ref:`box.schema.role.drop() <box_schema-role_drop>`:
514565

515-
.. code-block:: lua
516-
517-
box.schema.role.drop('books_space_reader')
566+
.. literalinclude:: /code_snippets/test/access_control/grant_roles_test.lua
567+
:language: lua
568+
:start-after: Dropping a role
569+
:end-before: End: Dropping a role
570+
:dedent:
518571

519572

520573

@@ -655,58 +708,82 @@ In this example, 'testuser' is allowed to read and modify data in the 'books' sp
655708
Sequences
656709
~~~~~~~~~
657710

711+
.. _access_control_grant_sequences_create_drop:
712+
713+
Creating and dropping sequences
714+
*******************************
715+
658716
In this example, 'testuser' gets privileges to create :ref:`sequence <index-box_sequence>` generators:
659717

660718
.. code-block:: lua
661719
662720
box.schema.user.grant('testuser','create','sequence')
663721
box.schema.user.grant('testuser', 'read,write', 'space', '_sequence')
664722
665-
In the next example, 'testuser' is allowed to use the ``id_seq:next()`` function with a sequence named 'id_seq':
723+
To let 'testuser' drop a sequence, grant them the following privileges:
666724

667725
.. code-block:: lua
668726
669-
box.schema.user.grant('testuser','read,write','sequence','id_seq')
727+
box.schema.user.grant('testuser','drop','sequence')
728+
box.schema.user.grant('testuser','write','space','_sequence_data')
729+
box.schema.user.grant('testuser','write','space','_sequence')
670730
671-
In this example, 'testuser' is allowed to use the ``id_seq:set()`` or ``id_seq:reset()`` functions with a sequence named 'id_seq':
731+
.. _access_control_grant_sequences_functions:
732+
733+
Using sequence functions
734+
************************
735+
736+
In this example, 'testuser' is allowed to use the ``id_seq:next()`` function with a sequence named 'id_seq':
672737

673738
.. code-block:: lua
674739
675-
box.schema.user.grant('testuser','write','sequence','S')
740+
box.schema.user.grant('testuser','read,write','sequence','id_seq')
676741
677-
To let 'testuser' drop a sequence, grant them the following privileges:
742+
In the next example, 'testuser' is allowed to use the ``id_seq:set()`` or ``id_seq:reset()`` functions with a sequence named 'id_seq':
678743

679744
.. code-block:: lua
680745
681-
box.schema.user.grant('testuser','drop','sequence')
682-
box.schema.user.grant('testuser','write','space','_sequence_data')
683-
box.schema.user.grant('testuser','write','space','_sequence')
746+
box.schema.user.grant('testuser','write','sequence','id_seq')
747+
684748
685749
686750
.. _access_control_grant_functions:
687751

688752
Functions
689753
~~~~~~~~~
690754

755+
.. _access_control_grant_functions_create_drop:
756+
757+
Creating and dropping functions
758+
*******************************
759+
691760
In this example, 'testuser' gets privileges to create :ref:`functions <box_schema-func_create>`:
692761

693762
.. code-block:: lua
694763
695764
box.schema.user.grant('testuser','create','function')
696765
box.schema.user.grant('testuser','read,write','space','_func')
697766
698-
To give the ability to execute a function named 'sum', grant the following privileges:
767+
To let 'testuser' drop a function, grant them the following privileges:
699768

700769
.. code-block:: lua
701770
702-
box.schema.user.grant('testuser','execute','function','sum')
771+
box.schema.user.grant('testuser','drop','function')
772+
box.schema.user.grant('testuser','write','space','_func')
703773
704-
To let 'testuser' drop a function, grant them the following privileges:
774+
775+
.. _access_control_grant_functions_execute:
776+
777+
Executing functions
778+
*******************
779+
780+
To give the ability to execute a function named 'sum', grant the following privileges:
705781

706782
.. code-block:: lua
707783
708-
box.schema.user.grant('testuser','drop','function')
709-
box.schema.user.grant('testuser','write','space','_func')
784+
box.schema.user.grant('testuser','execute','function','sum')
785+
786+
710787
711788
712789

0 commit comments

Comments
 (0)