Skip to content

Adds box.schema.user.enable and box.schema.user.disable methods #5123

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

Open
wants to merge 10 commits into
base: latest
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions doc/reference/reference_lua/box_schema.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ Below is a list of all ``box.schema`` functions.
* - :doc:`./box_schema/user_revoke`
- Revoke privileges from a user or a role

* - :doc:`./box_schema/user_enable`
- Grant ``usage`` and ``session`` permissions

* - :doc:`./box_schema/user_disable`
- Revoke ``usage`` and ``session`` permissions

* - :doc:`./box_schema/user_password`
- Get a hash of a user's password

Expand Down Expand Up @@ -105,6 +111,8 @@ Below is a list of all ``box.schema`` functions.
box_schema/user_exists
box_schema/user_grant
box_schema/user_revoke
box_schema/user_enable
box_schema/user_disable
box_schema/user_password
box_schema/user_passwd
box_schema/user_info
Expand Down
29 changes: 29 additions & 0 deletions doc/reference/reference_lua/box_schema/user_disable.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. _box_schema-user_disable:

===============================================================================
box.schema.user.disable()
===============================================================================

.. module:: box.schema

.. function:: box.schema.user.disable(username)

Revokes ``usage`` and ``session`` permissions from the subject user. Equivalent to the following call:

.. code-block:: lua

box.schema.user.revoke('{username}','usage,session','universe',nil,{if_not_exists=true})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits:

  • I would replace '{username}' with just username (like a variable), because we mention it is this form in the arguments list above.

  • I would split function arguments with whitespaces (and also surround = with them):

    box.schema.user.revoke(username,'usage,session','universe',nil,{if_not_exists=true})

    =>

    box.schema.user.revoke(username, 'usage,session', 'universe', nil, {if_not_exists = true})

    This is the usual code style for Lua within the server team (see also https://www.tarantool.io/en/doc/latest/contributing/lua_style_guide/).

  • Trailing whitespaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found how to fix them in vscode))


.. NOTE::

* ``session`` - (cannot be granted to a role) if is not granted, ``IPROTO_AUTH`` always fails connection to the user, so does ``box.session.su()``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Connection to the user' is a bit unclear for me and also it is not clear what is meant about box.session.su(). I propose to reword it to something simple:

allows the binary protocol layer (iproto) to authenticate the user


* ``usage`` - (cannot be granted to a role) lets user use their privileges on database objects (e.g. read, write and alter space)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


For more information about revoking permissions see section :ref:`box.schema.user.revoke <box_schema-user_revoke>`.

:param string username: the name of the subject user

:return: (if success) nothing

(if failure) The error is raised ``- error: User 'username' is not found``
29 changes: 29 additions & 0 deletions doc/reference/reference_lua/box_schema/user_enable.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. _box_schema-user_enable:

===============================================================================
box.schema.user.enable()
===============================================================================

.. module:: box.schema

.. function:: box.schema.user.enable(username)

Grants ``usage`` and ``session`` permissions to the subject user. Equivalent to the following call:

.. code-block:: lua

box.schema.user.grant('{username}','usage,session','universe',nil,{if_not_exists=true})

.. NOTE::

* ``session`` - (cannot be granted to a role) if is not granted, ``IPROTO_AUTH`` always fails connection to the user, so does ``box.session.su()``

* ``usage`` - (cannot be granted to a role) lets user use their privileges on database objects (e.g. read, write and alter space)

For more information about granting permissions see section :ref:`box.schema.user.grant <box_schema-user_grant>`.

:param string username: the name of the subject user

:return: (if success) nothing

(if failure) The error is raised ``- error: User 'username' is not found``
2 changes: 1 addition & 1 deletion doc/reference/reference_lua/box_schema/user_grant.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ box.schema.user.grant()

**Variation:** instead of
:samp:`box.schema.user.grant('{username}','usage,session','universe',nil,` :code:`{if_not_exists=true})`
say :samp:`box.schema.user.enable('{username}')`.
say :samp:`box.schema.user.enable('{username}')` (see section :ref:`box.schema.user.enable <box_schema-user_enable>`).

The possible options are:

Expand Down
2 changes: 1 addition & 1 deletion doc/reference/reference_lua/box_schema/user_revoke.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ box.schema.user.revoke()

**Variation:** instead of
:samp:`box.schema.user.revoke('{username}','usage,session','universe',nil,` :code:`{if_exists=true})`
say :samp:`box.schema.user.disable('{username}')`.
say :samp:`box.schema.user.disable('{username}')` (see section :ref:`box.schema.user.disable <box_schema-user_disable>`).

**Example:**

Expand Down