Skip to content
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

Rework the Access control topic #4024

Merged
merged 10 commits into from
Feb 12, 2024
Merged

Rework the Access control topic #4024

merged 10 commits into from
Feb 12, 2024

Conversation

andreyaksenov
Copy link
Contributor

@andreyaksenov andreyaksenov commented Jan 26, 2024

Reworked the Access control topic:

Next step: #4035.

@andreyaksenov andreyaksenov force-pushed the config-credentials branch 2 times, most recently from 00722e9 to 39e6b0d Compare February 1, 2024 13:54
@andreyaksenov andreyaksenov linked an issue Feb 2, 2024 that may be closed by this pull request
@andreyaksenov andreyaksenov force-pushed the config-credentials branch 27 times, most recently from 4ec60c0 to c67366a Compare February 5, 2024 12:05
@andreyaksenov andreyaksenov force-pushed the config-credentials branch 2 times, most recently from 2733ee4 to 4530623 Compare February 8, 2024 08:00
Copy link

@Lord-KA Lord-KA left a comment

Choose a reason for hiding this comment

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

Thank you for the patchset! Now access control documentation looks much better overall. See my minor comments below

doc/book/admin/access_control.rst Outdated Show resolved Hide resolved
doc/book/admin/access_control.rst Outdated Show resolved Hide resolved
doc/book/admin/access_control.rst Show resolved Hide resolved
doc/book/admin/access_control.rst Outdated Show resolved Hide resolved
doc/book/admin/access_control.rst Outdated Show resolved Hide resolved
doc/book/admin/access_control.rst Show resolved Hide resolved

In the example above, 'testuser' has the following privileges:

* The 'execute' privilege to the 'public' role means that this role is :ref:`assigned to a user <access_control_roles_granting_user>`.
Copy link

Choose a reason for hiding this comment

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

Nit:

assigned to the user

(We are talking about 'testuser' here, or some other specific user that has this grant)

Copy link

Choose a reason for hiding this comment

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

Maybe note here, that 'public' is granted to all users on creation?
(I know, that this is stated in the Roles section, but it could be helpful in describing a users privileges too)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

assigned to the user

Exactly! Thanks for the catch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe note here, that 'public' is granted to all users on creation?
(I know, that this is stated in the Roles section, but it could be helpful in describing a users privileges too)

I'd keep it as is because it is a how-to section and maintaining such info in several places might be hard if some privileges/roles change for the default user.

Copy link

Choose a reason for hiding this comment

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

Exactly! Thanks for the catch

It seems like there is the same issue in other bullet-points below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems like there is the same issue in other bullet-points below

Thanks, fixed

doc/book/admin/access_control.rst Show resolved Hide resolved
doc/book/admin/access_control.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@p7nov p7nov left a comment

Choose a reason for hiding this comment

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

Please see my comments

doc/book/admin/access_control.rst Show resolved Hide resolved
the current user is '**admin**'.
When executing a :ref:`Lua initialization script <index-init_label>`,
the current user is also ‘**admin**’.
A user is a person or program that interacts with a Tarantool instance.
Copy link
Contributor

Choose a reason for hiding this comment

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

This definition looks too broad and vague without details.
I'd provide a more detailed explanation:

  • Technically, a user we talk about is an entity in Tarantool, not a person or external program.
  • But it corresponds (== can be used by) either to a person, or to a program, enabling them to do something

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 feel that identify should work better here:

A user identifies a person or program that interacts with a Tarantool instance.

And this is eliminates the need of using the entity word that might add some confusion :)

:doc:`/reference/reference_lua/box_session/user`.
* A database administrator is responsible for the overall management and administration of a database.
An administrator can create other users and grant them specified privileges.
* A regular user has limited access to certain data and stored functions. For example, such users can be used to let :ref:`connectors <index-box_connectors>` communicate to a database.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that regular user is definitive enough. Maybe write a more specific example?

Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally, this example confused me: from the start, I expected this to be a person that works on data in specific spaces, but then it turned out that it's about connectors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Removed information about connectors because this is a specific case. Both admin and regular user might work directly or using a connector.
Also, added info that users can get privileges from dbadmin.

* A database administrator is responsible for the overall management and administration of a database.
An administrator can create other users and grant them specified privileges.
* A regular user has limited access to certain data and stored functions. For example, such users can be used to let :ref:`connectors <index-box_connectors>` communicate to a database.
* Users used in communications between Tarantool instances. For example, such users can be created to maintain replication and sharding in a Tarantool cluster.
Copy link
Contributor

Choose a reason for hiding this comment

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

These users: are they people or programs? I think a deeper explanation is needed here.

The current user can be changed:
There are two built-in users in Tarantool:

* 'admin' is a user with all available administrative permissions.
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use the code style (double backticks) for all user, role, privilege, etc. names on this page.

Here a Lua function is created that will be executed under the user ID of its
box.schema.user.grant(user-name, privileges, object-type, object-name[, {options}])

* ``user-name``: the name of the user that gets the specified privileges.
Copy link
Contributor

Choose a reason for hiding this comment

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

Hyphenated user-name looks grammatically incorrect (although I get why it is used here). Let's maybe change to either user or username?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm.. In this case we need to fix this in all reference pages related to privileges (because I just copy-pasted this from the box.schema.user.grant page).

Creating and altering spaces
****************************

In the example below, 'testuser' gets privileges allowing them to create :ref:`spaces <index-box_space>`:
Copy link
Contributor

Choose a reason for hiding this comment

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

The need to grant privileges to implicitly connected system objects is really hardcore. Can we maybe find a place to explain this in general before showing these lists of calls?

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 hope, this should be enough:

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but I have two concerns:

  1. This text is too far from the section where this question came up. Hardly somebody will read the whole page of this size.
  2. Note that some looks like some rare or specific thing. To me, this whole point seems like a general concept of the Tarantool access model. I'd explain it in a stronger and more exact wording. Just a personal opinion, you decide.

Copy link
Contributor Author

@andreyaksenov andreyaksenov Feb 12, 2024

Choose a reason for hiding this comment

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

This text is too far from the section where this question came up. Hardly somebody will read the whole page of this size.

Will add a note after the first example to remind a reader about this concept.

Example
~~~~~~~

In the example below, the created Lua function is executed under the user ID of its
creator, even if called by another user.

First, the two spaces ('u' and 'i') are created, and a no-password user ('internal')
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use more self-explanatory and realistic entity names than u, i, and internal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay :) just copy-pasted this example from old docs as is and was a bit lazy to fix this.

:header-rows: 1
:widths: 15 85

* - Object type
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this look better in a three-column table?

Copy link
Contributor Author

@andreyaksenov andreyaksenov Feb 9, 2024

Choose a reason for hiding this comment

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

Hmm.. Thought about this but cell merging in the first column is required for better readability. Does Sphinx support this?

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIR, no: tables in Sphinx/RST are a bit limited.

g.test_user_with_password_created = function(cg)
cg.server:exec(function()
-- Create a user with a password --
box.schema.user.create('testuser', { password = 'foobar' })
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: most style guides recommend avoiding foo/bar anywhere in examples.

Copy link

Choose a reason for hiding this comment

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

Usually password is "secret", or something similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Usually password is "secret", or something similar.

Thanks for your suggestion. Honestly, I try not to use meaningful words as password examples in docs because they make a reader think about the word meaning. IMO, passwords should look like some gibberish, well-known weak passwords (123456), or smth like P@$$word) to allow a reader quickly scan it und understand it is a password, not smth else. Not sure I'm right here :)

@andreyaksenov andreyaksenov force-pushed the config-credentials branch 2 times, most recently from 7220146 to 0ddf76b Compare February 9, 2024 14:37
@andreyaksenov andreyaksenov requested a review from p7nov February 9, 2024 14:50
Copy link
Contributor

@p7nov p7nov left a comment

Choose a reason for hiding this comment

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

LGTM in general, just some more ideas and qeustion.

Access control
================================================================================
==============
Copy link
Contributor

Choose a reason for hiding this comment

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

Idea: use the words role-based access control system/model explicitly somewhere in the intro paragraph. This is a familiar term, it helps readers understand general concepts easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Privileges can be assigned directly to a user. So, role-based access control doesn't cover all possible capabilities of Tarantool access control system.


Briefly:
* A *user* is a person or program that interacts with a Tarantool instance.
* An *object* is an entity to which access can be granted, for example, spaces, indexes, or functions.
Copy link
Contributor

Choose a reason for hiding this comment

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

Singular a space, an index, a function would be more precise, since we grant permissions per object, not for all spaces (functions) at once.

Briefly:
* A *user* is a person or program that interacts with a Tarantool instance.
* An *object* is an entity to which access can be granted, for example, spaces, indexes, or functions.
* *Privileges* allow a user to perform certain operations on specific objects, for example, creating spaces, reading or updating data.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe A privilege for consistency with other list items?

the minimal privileges necessary for particular operations,
to user 'U'.
* ``super`` has all available administrative permissions.
* ``public`` is automatically granted to new users when they are created.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we say anything specific or give a usage advice about this role? The current definition gives me no idea why is it needed and how to use it...

* ``super`` has all available administrative permissions.
* ``public`` is automatically granted to new users when they are created.
* ``replication`` can be granted to a user used to maintain :ref:`replication <replication_overview>` in a cluster.
* ``sharding`` can be granted to a user used to maintain :ref:`sharding <sharding>` in a cluster.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still confused about the two last roles.
Are they purely internal/technical by purpose? Should a person ever use them manually or change their privileges?
I mean, if I need to administer a cluster, do I connect to an instance using these role and call some functions by hand? Or Tarantool only uses them under the hood?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are they purely internal/technical by purpose?

AFAIU, yes. They are granted to corresponding service users in a cluster config.

Should a person ever use them manually or change their privileges?

No, they designed only for specific internal operations.

Example
~~~~~~~

In the example below, the created Lua function is executed under the user ID of its
Copy link
Contributor

Choose a reason for hiding this comment

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

on behalf of sounds more natural than than under the user ID.

end

box.session.su('private_user')
box.schema.func.create('read_and_modify', {setuid= true})
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe, this is what should be explained explicitly: setuid = true.
Most other code is pretty obvious, but this option is

  1. new and unknown to readers
  2. key - it is what sets the user for function execution

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a link to the box.schema.func.create page where setuid is described in details.

In the example below, the created Lua function is executed under the user ID of its
creator, even if called by another user.

First, the two spaces (``space1`` and ``space2``) are created, and a no-password user (``private_user``)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: no-password user sounds weird, especially when used three times in a row as a user's identifier in text. If it's really important, let's say it once and not repeat. Although I'd rephrase this completely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced no-password user with private_user in the next sentences.

box.schema.func.create('read_and_modify', {setuid= true})
box.session.su('admin')
box.schema.user.create('public_user', {password = 'secret'})
box.schema.user.grant('public_user', 'execute', 'function', 'read_and_modify')
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's maybe write a conclusion sentence, smth like: now whenever public_user calls the function, it is executed on behalf of its creator, private_user

@@ -21,7 +21,7 @@ box.schema.user.create()
* ``password`` (default = '') - string; the ``password`` = *password*
specification is good because in a :ref:`URI <index-uri>`
(Uniform Resource Identifier) it is usually illegal to include a
user-name without a password.
username without a password.

.. NOTE::
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow, this surprised me a lot!
Isn't it important enough to mention in the Users section of Access control?

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also described in Limitations: https://www.tarantool.io/en/doc/latest/book/box/limitations/.
I'd keep it as is because it might be hard to maintain such reference information is multiple places.

@andreyaksenov andreyaksenov force-pushed the config-credentials branch 2 times, most recently from f825a30 to b2f3d67 Compare February 12, 2024 09:37
@andreyaksenov andreyaksenov merged commit 693828c into latest Feb 12, 2024
1 check passed
@andreyaksenov andreyaksenov deleted the config-credentials branch February 12, 2024 09:59
@andreyaksenov andreyaksenov changed the title Document config credentials Rework the Access control topic Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Config] Document the 'credentials' option
3 participants