-
Notifications
You must be signed in to change notification settings - Fork 43
Clarify info in the box.session
module
#5065
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
xuniq
wants to merge
1
commit into
latest
Choose a base branch
from
gh-5062-clarify-box.session.su
base: latest
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+115
−58
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
doc/reference/reference_lua/box_session/effective_user.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.. _box_session-effective_user: | ||
|
||
box.session.effective_user() | ||
============================ | ||
|
||
.. module:: box.session | ||
|
||
.. function:: effective_user() | ||
|
||
Return the name of the effective user - the . | ||
If the :ref:`current user <authentication-users>` is changed temporarily using the :ref:`box.session.su() <box_session-su>` method, | ||
`box.session.effective_user()` shows this change. | ||
|
||
See also: :ref:`box.session.euid() <box_session-euid>` | ||
|
||
:return: the current effective user's name | ||
|
||
:rtype: string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,75 @@ | ||
.. _box_session-su: | ||
|
||
.. _box_session-su: | ||
|
||
================================================================================ | ||
box.session.su() | ||
================================================================================ | ||
================ | ||
|
||
.. module:: box.session | ||
.. module:: box.session | ||
|
||
.. function:: su(user-name [, function-to-execute]) | ||
.. function:: su(user-name [, function-to-execute]) | ||
|
||
Change Tarantool's :ref:`current user <authentication-users>` -- | ||
this is analogous to the Unix command ``su``. | ||
|
||
Or, if function-to-execute is specified, | ||
change Tarantool's :ref:`current user <authentication-users>` | ||
temporarily while executing the function -- | ||
Or, if the ``function-to-execute`` option is specified, | ||
change Tarantool's current user temporarily while executing the function -- | ||
this is analogous to the Unix command ``sudo``. | ||
If the user is changed temporarily: | ||
|
||
- :ref:`box.session.user() <box_session-user>` ignores this change. | ||
- :ref:`box.session.effective_user() <box_session-effective_user>` shows this change. | ||
|
||
|
||
:param string user-name: name of a target user | ||
:param function-to-execute: name of a function, or definition of a function. | ||
:param function-to-execute: a function object. | ||
Additional parameters may be passed to | ||
``box.session.su``, they will be interpreted | ||
as parameters of function-to-execute. | ||
``box.session.su()``, they will be interpreted | ||
as parameters of ``function-to-execute``. | ||
|
||
**Example 1** | ||
|
||
Change Tarantool's current user to ``guest``: | ||
|
||
.. code-block:: tarantoolsession | ||
|
||
app:instance001> box.session.su('guest') | ||
--- | ||
... | ||
|
||
**Example 2** | ||
|
||
Change Tarantool's current user to ``temporary_user`` temporarily: | ||
|
||
**Example:** | ||
.. code-block:: tarantoolsession | ||
|
||
.. code-block:: tarantoolsession | ||
app:instance001> function get_current_user() return box.session.user() end | ||
--- | ||
... | ||
|
||
app:instance001> function get_effective_user() return box.session.effective_user() end | ||
--- | ||
... | ||
|
||
app:instance001> get_current_user() | ||
--- | ||
- admin | ||
... | ||
|
||
app:instance001> box.session.su('temporary_user', get_current_user) | ||
--- | ||
- admin | ||
... | ||
|
||
tarantool> function f(a) return box.session.user() .. a end | ||
app:instance001> box.session.su('temporary_user', get_effective_user) | ||
--- | ||
- temporary_user | ||
... | ||
|
||
tarantool> box.session.su('guest', f, '-xxx') | ||
app:instance001> box.session.su('temporary_user', get_effective_user, '-xxx') | ||
--- | ||
- guest-xxx | ||
- temporary_user-xxx | ||
... | ||
|
||
tarantool> box.session.su('guest',function(...) return ... end,1,2) | ||
app:instance001> box.session.su('temporary_user', function(...) return box.session.user() end) | ||
--- | ||
- 1 | ||
- 2 | ||
- admin | ||
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.