chore: warning overrided when restart authn

This commit is contained in:
zhongwencool 2024-06-26 17:34:16 +08:00
parent 24d2534641
commit 9594b6df32
2 changed files with 23 additions and 5 deletions

View File

@ -339,8 +339,24 @@ run_fuzzy_filter(
%%------------------------------------------------------------------------------
insert_user(UserGroup, UserID, PasswordHash, Salt, IsSuperuser) ->
UserInfoRecord = user_info_record(UserGroup, UserID, PasswordHash, Salt, IsSuperuser),
insert_user(UserInfoRecord).
UserInfoRecord =
#user_info{user_id = DBUserID} =
user_info_record(UserGroup, UserID, PasswordHash, Salt, IsSuperuser),
case mnesia:read(?TAB, DBUserID, write) of
[] ->
insert_user(UserInfoRecord);
[UserInfoRecord] ->
ok;
[_] ->
?SLOG(warning, #{
msg => "bootstrap_authentication_overridden_in_the_built_in_database",
user_id => UserID,
group_id => UserGroup,
suggestion =>
"If you have made changes in other way, remove the user_id from the bootstrap file."
}),
insert_user(UserInfoRecord)
end.
insert_user(#user_info{} = UserInfoRecord) ->
mnesia:write(?TAB, UserInfoRecord, write).

View File

@ -11,14 +11,16 @@ user_id_type.label:
bootstrap_file.desc:
"""The bootstrap file imports users into the built-in database.
the file content format is determined by `bootstrap_type`."""
The file content format is determined by `bootstrap_type`.
Remove the item from the bootstrap file when you have made changes in other way,
otherwise, after restarting, the bootstrap item will be overridden again."""
bootstrap_file.label:
"""Bootstrap File Path"""
bootstrap_type.desc:
"""plain: bootstrap_file.cvs should have lines of format `{user_id},{password},{is_superuser}` where `user_id` can be either clientid or username depending on `user_id_type`.
hash: bootstrap_file.cvs should have line of format `{user_id},{password_hash},{salt},{is_superuser}.`
"""`plain`: bootstrap_file.csv should have lines of format `{user_id},{password},{is_superuser}` where `user_id` can be either clientid or username depending on `user_id_type`.
`hash`: bootstrap_file.csv should have line of format `{user_id},{password_hash},{salt},{is_superuser}.`
All file format support is the same as `authentication/password_based:built_in_database/import_users` API."""
}