forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
box: add auth_history and last_modified fields to _user space
See the doc bot request for the description of the new fields. Note that we only store the value of the 'last_modified' field in struct user_def, because 'auth_history' will be used only in Lua code. Needed for tarantool/tarantool-ee#298 Needed for tarantool/tarantool-ee#299 NO_CHANGELOG=no user-visible effects in CE; will be added to EE @TarantoolBot document Title: Document auth_history and last_modified _user space fields Field name: auth_history. Field no: 6. Type: array. Description: The field stores an array of previous authentication data: when a user password is changed, the last value of the 'auth' field is appended to 'auth_history'. The length of the history is configured by the `box.cfg.password_history_length` option, which is available only in Tarantool EE, where it's used to prevent users from reusing old passwords. In Tarantool CE, the array is always empty. Field name: last_modified. Field no: 7. Type: unsigned. Description: The field stores the timestamp (seconds since Unix epoch) of the last user password update. It's never used in Tarantool CE. In Tarantool EE, it's used to disable users that haven't changed the password for more than `box.cfg.password_lifetime_days`. `box.schema.upgrade()` sets the new field values to an empty array and 0 for users that haven't updated them yet.
- Loading branch information
Showing
15 changed files
with
327 additions
and
88 deletions.
There are no files selected for viewing
This file contains 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
Binary file not shown.
This file contains 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 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 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 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 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
Binary file not shown.
99 changes: 99 additions & 0 deletions
99
test/box-luatest/user_auth_history_last_modified_upgrade_test.lua
This file contains 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,99 @@ | ||
local server = require('luatest.server') | ||
local t = require('luatest') | ||
|
||
local g = t.group() | ||
|
||
g.before_all(function(cg) | ||
t.tarantool.skip_if_not_debug() | ||
cg.server = server:new({ | ||
alias = 'master', | ||
datadir = 'test/box-luatest/upgrade/2.10.4', | ||
env = {ERRINJ_AUTO_UPGRADE = 'true'}, | ||
}) | ||
cg.server:start() | ||
end) | ||
|
||
g.after_all(function(cg) | ||
cg.server:drop() | ||
end) | ||
|
||
g.test_upgrade = function(cg) | ||
cg.server:exec(function() | ||
local t = require('luatest') | ||
local fiber = require('fiber') | ||
t.assert_equals(box.space._user:select(), { | ||
{0, 1, 'guest', 'user', | ||
{['chap-sha1'] = 'vhvewKp0tNyweZQ+cFKAlsyphfg='}}, | ||
{1, 1, 'admin', 'user', {}}, | ||
{2, 1, 'public', 'role', {}}, | ||
{3, 1, 'replication', 'role', {}}, | ||
{31, 1, 'super', 'role', {}}, | ||
{32, 1, 'eve', 'user', {}}, | ||
{33, 1, 'bob', 'user', | ||
{['chap-sha1'] = 'FOZVZ6vbUTXQz9mnCzAywXmknuc='}}, | ||
{34, 1, 'test', 'role', {}}, | ||
}) | ||
box.schema.user.create('alice') | ||
box.schema.user.create('sarah', {password = 'SARAH'}) | ||
box.schema.user.passwd('bob', 'BOB') | ||
box.schema.role.create('dev') | ||
t.assert_equals(box.space._user:select(), { | ||
{0, 1, 'guest', 'user', | ||
{['chap-sha1'] = 'vhvewKp0tNyweZQ+cFKAlsyphfg='}}, | ||
{1, 1, 'admin', 'user', {}}, | ||
{2, 1, 'public', 'role', {}}, | ||
{3, 1, 'replication', 'role', {}}, | ||
{31, 1, 'super', 'role', {}}, | ||
{32, 1, 'eve', 'user', {}}, | ||
{33, 1, 'bob', 'user', | ||
{['chap-sha1'] = 'Ll5w6uuDmXlEaz2b8kmjHZu1SLg='}, {}, | ||
box.space._user:get(33)[7]}, | ||
{34, 1, 'test', 'role', {}}, | ||
{35, 0, 'alice', 'user', {}, {}, | ||
box.space._user:get(35)[7]}, | ||
{36, 0, 'sarah', 'user', | ||
{['chap-sha1'] = '973rCIFsYhe7gupdgOPCSJoPRNU='}, {}, | ||
box.space._user:get(36)[7]}, | ||
{37, 0, 'dev', 'role', {}, {}, | ||
box.space._user:get(37)[7]}, | ||
}) | ||
local time = fiber.time() | ||
local margin = 60 | ||
t.assert_almost_equals(box.space._user:get(33)[7], time, margin) | ||
t.assert_almost_equals(box.space._user:get(35)[7], time, margin) | ||
t.assert_almost_equals(box.space._user:get(36)[7], time, margin) | ||
t.assert_almost_equals(box.space._user:get(37)[7], time, margin) | ||
box.schema.upgrade() | ||
local format = { | ||
{name = "id", type = "unsigned"}, | ||
{name = "owner", type = "unsigned"}, | ||
{name = "name", type = "string"}, | ||
{name = "type", type = "string"}, | ||
{name = "auth", type = "map"}, | ||
{name = "auth_history", type = "array"}, | ||
{name = "last_modified", type = "unsigned"}, | ||
} | ||
t.assert_equals(box.space._user:format(), format) | ||
t.assert_equals(box.space._vuser:format(), format) | ||
t.assert_equals(box.space._user:select(), { | ||
{0, 1, 'guest', 'user', | ||
{['chap-sha1'] = 'vhvewKp0tNyweZQ+cFKAlsyphfg='}, {}, 0}, | ||
{1, 1, 'admin', 'user', {}, {}, 0}, | ||
{2, 1, 'public', 'role', {}, {}, 0}, | ||
{3, 1, 'replication', 'role', {}, {}, 0}, | ||
{31, 1, 'super', 'role', {}, {}, 0}, | ||
{32, 1, 'eve', 'user', {}, {}, 0}, | ||
{33, 1, 'bob', 'user', | ||
{['chap-sha1'] = 'Ll5w6uuDmXlEaz2b8kmjHZu1SLg='}, {}, | ||
box.space._user:get(33)[7]}, | ||
{34, 1, 'test', 'role', {}, {}, 0}, | ||
{35, 0, 'alice', 'user', {}, {}, | ||
box.space._user:get(35)[7]}, | ||
{36, 0, 'sarah', 'user', | ||
{['chap-sha1'] = '973rCIFsYhe7gupdgOPCSJoPRNU='}, {}, | ||
box.space._user:get(36)[7]}, | ||
{37, 0, 'dev', 'role', {}, {}, | ||
box.space._user:get(37)[7]}, | ||
}) | ||
end) | ||
end |
This file contains 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
Oops, something went wrong.