@@ -213,8 +213,8 @@ at the start of the transaction using :doc:`/reference/reference_lua/box_session
213
213
214
214
.. _access_control_users :
215
215
216
- Users
217
- -----
216
+ Managing users
217
+ --------------
218
218
219
219
.. _access_control_user_creating :
220
220
@@ -286,29 +286,6 @@ Learn more about granting privileges to different types of objects from :ref:`ac
286
286
287
287
288
288
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
-
312
289
.. _access_control_user_info :
313
290
314
291
Getting a user's information
@@ -348,7 +325,7 @@ To get information about privileges granted to a user, call :ref:`box.schema.use
348
325
349
326
In the example above, 'testuser' has the following privileges:
350
327
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 >` .
352
329
353
330
* The 'read' privilege to the ``writers `` space means that a user can read data from this space.
354
331
@@ -361,17 +338,28 @@ In the example above, 'testuser' has the following privileges:
361
338
362
339
* The 'alter' privilege lets 'testuser' modify its own settings, for example, a password.
363
340
364
- .. _access_control_users_dropping :
365
341
366
- Dropping users
367
- ~~~~~~~~~~~~~~
368
342
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:
370
350
371
351
.. literalinclude :: /code_snippets/test/access_control/grant_user_privileges_test.lua
372
352
: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
375
363
:dedent:
376
364
377
365
@@ -412,22 +400,41 @@ The current user can be changed:
412
400
413
401
414
402
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
+
415
419
.. _authentication-roles :
416
420
.. _access_control_roles :
417
421
418
- Roles
419
- -----
422
+ Managing roles
423
+ --------------
420
424
421
425
.. _access_control_roles_creating :
422
426
423
427
Creating a role
424
428
~~~~~~~~~~~~~~~
425
429
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:
429
432
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:
431
438
432
439
433
440
.. _access_control_roles_granting_privileges :
@@ -436,11 +443,21 @@ Granting privileges to a role
436
443
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
437
444
438
445
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:
440
447
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:
442
455
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:
444
461
445
462
Learn more about granting privileges to different types of objects from :ref: `access_control_granting_privileges `.
446
463
@@ -456,25 +473,28 @@ Granting a role to a role
456
473
~~~~~~~~~~~~~~~~~~~~~~~~~
457
474
458
475
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 ':
460
477
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:
465
483
466
484
467
485
.. _access_control_roles_granting_user :
468
486
469
487
Granting a role to a user
470
488
~~~~~~~~~~~~~~~~~~~~~~~~~
471
489
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 :
474
492
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:
478
498
479
499
480
500
.. _access_control_roles_info :
@@ -486,7 +506,7 @@ To check whether the specified role exists, call :ref:`box.schema.role.exists()
486
506
487
507
.. code-block :: lua
488
508
489
- box.schema.role.exists('books_space_reader ')
509
+ box.schema.role.exists('books_space_manager ')
490
510
--[[
491
511
- true
492
512
--]]
@@ -495,14 +515,45 @@ To get information about privileges granted to a role, call :ref:`box.schema.rol
495
515
496
516
.. code-block :: lua
497
517
498
- box.schema.role.info('books_space_reader ')
518
+ box.schema.role.info('books_space_manager ')
499
519
--[[
500
- - - read
520
+ - - - read,write
501
521
- space
502
522
- books
503
523
--]]
504
524
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 >`.
506
557
507
558
508
559
.. _access_control_roles_dropping :
@@ -512,9 +563,11 @@ Dropping roles
512
563
513
564
To drop the specified role, call :ref: `box.schema.role.drop() <box_schema-role_drop >`:
514
565
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:
518
571
519
572
520
573
@@ -655,58 +708,82 @@ In this example, 'testuser' is allowed to read and modify data in the 'books' sp
655
708
Sequences
656
709
~~~~~~~~~
657
710
711
+ .. _access_control_grant_sequences_create_drop :
712
+
713
+ Creating and dropping sequences
714
+ *******************************
715
+
658
716
In this example, 'testuser' gets privileges to create :ref: `sequence <index-box_sequence >` generators:
659
717
660
718
.. code-block :: lua
661
719
662
720
box.schema.user.grant('testuser','create','sequence')
663
721
box.schema.user.grant('testuser', 'read,write', 'space', '_sequence')
664
722
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 :
666
724
667
725
.. code-block :: lua
668
726
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')
670
730
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':
672
737
673
738
.. code-block :: lua
674
739
675
- box.schema.user.grant('testuser','write','sequence','S ')
740
+ box.schema.user.grant('testuser','read, write','sequence','id_seq ')
676
741
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' :
678
743
679
744
.. code-block :: lua
680
745
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
+
684
748
685
749
686
750
.. _access_control_grant_functions :
687
751
688
752
Functions
689
753
~~~~~~~~~
690
754
755
+ .. _access_control_grant_functions_create_drop :
756
+
757
+ Creating and dropping functions
758
+ *******************************
759
+
691
760
In this example, 'testuser' gets privileges to create :ref: `functions <box_schema-func_create >`:
692
761
693
762
.. code-block :: lua
694
763
695
764
box.schema.user.grant('testuser','create','function')
696
765
box.schema.user.grant('testuser','read,write','space','_func')
697
766
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:
699
768
700
769
.. code-block :: lua
701
770
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')
703
773
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:
705
781
706
782
.. code-block :: lua
707
783
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
+
710
787
711
788
712
789
0 commit comments