Compare commits

..

No commits in common. "15143fd58fae3de7269d35521c1ccf020b84e829" and "b79404f7fa1eeb63e408c4164f6652353e8ff699" have entirely different histories.

2 changed files with 17 additions and 41 deletions

View File

@ -10,12 +10,12 @@
-----------------------------------------------------
local is_46 = minetest.has_feature("add_entity_with_staticdata")
function get_minetest_config( key )
if is_46 then
return minetest.settings:get( key )
else
return core.setting_get( key ) -- backwards compatibility
if is_46 then
get_minetest_config = function( key )
minetest.settings:get( key )
end
else
get_minetest_config = core.setting_get -- backwards compatibility
end
function convert_ipv4( str )

View File

@ -24,7 +24,7 @@ local auth_filter = AuthFilter( world_path, "greenlist.mt" )
local auth_db = AuthDatabase( world_path, "auth.db" )
local auth_watchdog = AuthWatchdog( )
local is_50 = minetest.has_feature("object_use_texture_alpha")
local is_54 = minetest.has_feature("direct_velocity_on_players")
local is_54 = minetest.has_feature("object_use_texture_alpha")
if is_50 then
if minetest.register_on_auth_fail then
@ -128,15 +128,15 @@ end )
minetest.register_authentication_handler( {
-- translate old auth hooks to new database backend
get_auth = function( username )
minetest.log( "verbose" , "[auth_rx] get_auth handler access to some resource for " .. username )
local rec = auth_db.select_record( username )
if rec then
local assigned_privs = rec.assigned_privs
if get_minetest_config( "name" ) == username then
-- grant server operator all privileges
-- (TODO: implement as function that honors give_to_admin flag)
assigned_privs = { }
for priv in pairs( minetest.registered_privileges ) do
for priv in pairs( core.registered_privileges ) do
table.insert( assigned_privs, priv )
end
end
@ -145,52 +145,28 @@ minetest.register_authentication_handler( {
end
end,
create_auth = function( username, password )
minetest.log( "verbose" , "[auth_rx] create_auth handler new user over server for " .. username )
local rec = auth_db.create_record( username, password )
if rec then
local assigned_privs = get_default_privs( )
if get_minetest_config( "name" ) == username then
-- grant server operator all privileges
assigned_privs = { }
for priv in pairs( minetest.registered_privileges ) do
table.insert( assigned_privs, priv )
end
end
auth_db.set_assigned_privs( username, assigned_privs )
if auth_db.create_record( username, password ) then
auth_db.set_assigned_privs( username, get_default_privs( ) )
minetest.log( "info", "Created player '" .. username .. "' in authentication database" )
end
end,
delete_auth = function( username )
minetest.log( "verbose" , "[auth_rx] delete_auth handler for " .. username )
-- server operator's privileges are immutable
if get_minetest_config( "name" ) ~= username then
local rec = auth_db.delete_record( username )
if rec then
minetest.log( "info", "Deleted player '" .. username .. "' in authenatication database" )
end
if auth_db.delete_record( username ) then
minetest.log( "info", "Deleted player '" .. username .. "' in authenatication database" )
end
end,
set_password = function ( username, password )
minetest.log( "verbose" , "[auth_rx] set_password handler for " .. username )
local rec = auth_db.set_password( username, password )
if rec then
if auth_db.set_password( username, password ) then
minetest.log( "info", "Reset password of player '" .. username .. "' in authentication database" )
end
end,
set_privileges = function ( username, privileges )
minetest.log( "verbose" , "[auth_rx] set_privileges handler grants for " .. username )
local assigned_privs = pack_privileges( privileges )
-- server operator's privileges are immutable
if get_minetest_config( "name" ) == username then
assigned_privs = { }
for priv in pairs( minetest.registered_privileges ) do
table.insert( assigned_privs, priv )
end
end
if get_minetest_config( "name" ) == username then return end
if auth_db.set_assigned_privs( username, assigned_privs ) then
if auth_db.set_assigned_privs( username, pack_privileges( privileges ) ) then
minetest.notify_authentication_modified( username )
minetest.log( "info", "Reset privileges of player '" .. username .. "' in authentication database" )
end
end,
record_login = function ( ) end,