Hi All,
Have got 100 users that i would like to setup on a minetest server, its all so i can whitelist the server to stop them setting up another account if they get banned (Cannot IP Ban).
Is there a way of setting up bulk users with passwords?
The auth file is obviously encrypted.
Many thanks.
Precreate users with password. Possible?
- Linuxdirk
- Member
- Posts: 3219
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: Precreate users with password. Possible?
You could either use a custom auth handler and decouple the auth system from Minetest using your own handler or manually create the file. According to quick research the password has is a base64 encoded sha1 hash.
According to the bad documentation on custom auth handlers creating the file and use the built-in auth handler would be easier.
https://github.com/minetest/minetest/bl ... 2894-L2896
https://github.com/minetest/minetest/bl ... 2934-L2950
According to the bad documentation on custom auth handlers creating the file and use the built-in auth handler would be easier.
https://github.com/minetest/minetest/bl ... 2894-L2896
https://github.com/minetest/minetest/bl ... 2934-L2950
- rubenwardy
- Moderator
- Posts: 6978
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: Precreate users with password. Possible?
You can use the /setpassword command to create an account with a password, like so: /setpassword username password
All commands are implemented in Lua, which means that anything that is possible by a command is possible by a mod
Turns out that the /setpassword command uses the following code:
Which can create an account called "name" with password "password".
So you can read a list in and iterate through it, and create a user for each entry.
This is much easier than writing your own auth handler or your own parser/creator for the auth file. And more versatile too
If you create a csv file called defaultusers.csv in the world directory, you can use the following code to create all the users in it:
All commands are implemented in Lua, which means that anything that is possible by a command is possible by a mod
Turns out that the /setpassword command uses the following code:
Code: Select all
minetest.set_player_password(name, minetest.get_password_hash(name, password))
So you can read a list in and iterate through it, and create a user for each entry.
This is much easier than writing your own auth handler or your own parser/creator for the auth file. And more versatile too
If you create a csv file called defaultusers.csv in the world directory, you can use the following code to create all the users in it:
Code: Select all
local filepath = minetest.get_worldpath() .. "/defaultusers.csv"
for line in io.lines(filepath) do
local arr = line:split(",")
if #arr == 2 then
local name = arr[1]:trim()
local password = arr[2]:trim()
if not minetest.player_exists(name) then
minetest.set_player_password(name, minetest.get_password_hash(name, password))
end
end
end
Re: Precreate users with password. Possible?
That looks awesome! Wish i had coding skills like that these days, can read it but would take me ages to write.
So if i create a new mod, give it a name, create a Lua file and wrap your code with
Then just run that command in chat it should work?
So if i create a new mod, give it a name, create a Lua file and wrap your code with
Code: Select all
minetest.register_chatcommand("usercreate", {
privs = {server = true},
}
- rubenwardy
- Moderator
- Posts: 6978
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: Precreate users with password. Possible?
You're missing the func, it would be
Code: Select all
minetest.register_chatcommand("usercreate", {
privs = {server = true},
func = function (name)
local filepath = minetest.get_worldpath() .. "/defaultusers.csv"
for line in io.lines(filepath) do
local arr = line:split(",")
if #arr == 2 then
local name = arr[1]:trim()
local password = arr[2]:trim()
if not minetest.player_exists(name) then
minetest.set_player_password(name, minetest.get_password_hash(name, password))
end
end
end
end
}
- Linuxdirk
- Member
- Posts: 3219
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: Precreate users with password. Possible?
Depends on use case. For registering users on command line or for allowing users to register/reset password via web interface with additional authentication it's useless.rubenwardy wrote:And more versatile too
But the idea with the CSV file and the mod is nice.
- Blockhead
- Member
- Posts: 1697
- Joined: Wed Jul 17, 2019 10:14
- GitHub: Montandalar
- IRC: Blockhead256
- In-game: Blockhead Blockhead256
- Location: Land Down Under
- Contact:
Re: Precreate users with password. Possible?
Hello.. sorry for a 6 year necro but this is still a search result for "minetest password reuse" in 2024.rubenwardy wrote: ↑Mon Mar 26, 2018 13:15You can use the /setpassword command to create an account with a password, like so: /setpassword username password
Please: Don't use this chat command unless you know what you know what you are doing.. Read more below
It's important to note that Minetest is an unencrypted protocol, meaning it's susceptible to eavesdropping. Pull request #13049 added a note to the help for /setpassword to remind admins that it is insecure.
If you are going to use /setpassword, please only ever use it on a singleplayer world or on the same node/device as the server is running on - or perhaps on a LAN, if you can trust every device on your LAN (so basically not unless you have a free-software router and no IoT devices on the LAN). But you definitely can't trust the internet, so don't go telling it a user's password.
The correct and secure method for setting a password is for the user is to provide it on registration or from the game menu. This is how most people should be doing it. OP's question is specifically about a managed environment where users have their accounts pre-created instead of open registration. This is fine with the function rubenwardy provided, but please do not come here in a hurry looking for how to do a password reset for a user and then fall into the trap of using /setpassword for them. Ask them to change their own password. It's an option in the pause menu. Minetest uses cryptography (SRP protocol) to make sure that even over an unencrypted connection, the client can set a password without the server or an eavesdropper knowing the actual password, only its hash.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂
- rubenwardy
- Moderator
- Posts: 6978
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: Precreate users with password. Possible?
Here's a mod to precreate users with passwords https://content.minetest.net/packages/r ... ccountmgr/
Who is online
Users browsing this forum: No registered users and 37 guests