-
Notifications
You must be signed in to change notification settings - Fork 43
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
Conversation
00722e9
to
39e6b0d
Compare
4ec60c0
to
c67366a
Compare
2733ee4
to
4530623
Compare
There was a problem hiding this 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
|
||
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>`. |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
425c886
to
f3e510e
Compare
f3e510e
to
c99cdfa
Compare
There was a problem hiding this 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
Outdated
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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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/book/admin/access_control.rst
Outdated
: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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
doc/book/admin/access_control.rst
Outdated
The current user can be changed: | ||
There are two built-in users in Tarantool: | ||
|
||
* 'admin' is a user with all available administrative permissions. |
There was a problem hiding this comment.
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.
doc/book/admin/access_control.rst
Outdated
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. |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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).
doc/book/admin/access_control.rst
Outdated
Creating and altering spaces | ||
**************************** | ||
|
||
In the example below, 'testuser' gets privileges allowing them to create :ref:`spaces <index-box_space>`: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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:
- This text is too far from the section where this question came up. Hardly somebody will read the whole page of this size.
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.
There was a problem hiding this comment.
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.
doc/book/admin/access_control.rst
Outdated
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') |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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' }) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
7220146
to
0ddf76b
Compare
0ddf76b
to
32a1c25
Compare
There was a problem hiding this 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 | ||
================================================================================ | ||
============== |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
doc/book/admin/access_control.rst
Outdated
|
||
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. |
There was a problem hiding this comment.
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.
doc/book/admin/access_control.rst
Outdated
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. |
There was a problem hiding this comment.
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?
doc/book/admin/access_control.rst
Outdated
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
doc/book/admin/access_control.rst
Outdated
Example | ||
~~~~~~~ | ||
|
||
In the example below, the created Lua function is executed under the user ID of its |
There was a problem hiding this comment.
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}) |
There was a problem hiding this comment.
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
- new and unknown to readers
- key - it is what sets the user for function execution
There was a problem hiding this comment.
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``) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
f825a30
to
b2f3d67
Compare
b2f3d67
to
f28b61b
Compare
Reworked the Access control topic:
Next step: #4035.