authentication.lua 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. ---@meta
  2. ---Authentication
  3. -----------------
  4. ---@alias mt.PrivsSet { [string]: boolean|nil }
  5. ---Converts string representation of privs into table form
  6. ---@param str string String to convert.
  7. ---@param delim? string String separating the privs. Defaults to `","`.
  8. ---@return mt.PrivsSet # `{ priv1 = true, ... }`
  9. function minetest.string_to_privs(str, delim) end
  10. ---Returns the string representation of `privs`
  11. ---@param privs mt.PrivsSet `{ priv1 = true, ... }`
  12. ---@param delim? string String to delimit privs. Defaults to `","`.
  13. ---@return string
  14. function minetest.privs_to_string(privs, delim) end
  15. ---@param name string
  16. ---@return mt.PrivsSet # `{ priv1 = true, ... }`
  17. ---Calls the authentication handler.
  18. ---@see mt.AuthHandlerDef
  19. function minetest.get_player_privs(name) end
  20. ---A quickhand for checking privileges.
  21. ---`player_or_name`: Either a Player object or the name of a player.
  22. ---`...` is either a list of strings, e.g. `"priva", "privb"` or
  23. ---a table, e.g. `{ priva = true, privb = true }`.
  24. ---@param player_or_name mt.PlayerObjectRef|string
  25. ---@param ... string
  26. ---@return boolean
  27. ---@return string[]?
  28. ---@overload fun(player_or_name: mt.PlayerObjectRef|string, privs: mt.PrivsSet): boolean?, string[]?
  29. function minetest.check_player_privs(player_or_name, ...) end
  30. ---Returns true if the "password entry" for a player with name matches given
  31. ---password, false otherwise.
  32. ---The "password entry" is the password representation generated by the
  33. ---engine as returned as part of a `get_auth()` call on the auth handler.
  34. ---Only use this function for making it possible to log in via password from
  35. ---external protocols such as IRC, other uses are frowned upon.
  36. ---@param name string
  37. ---@param entry string
  38. ---@param password string
  39. ---@return boolean
  40. function minetest.check_password_entry(name, entry, password) end
  41. ---Convert a name-password pair to a password hash that Minetest can use.
  42. ---The returned value alone is not a good basis for password checks based
  43. ---on comparing the password hash in the database with the password hash
  44. ---from the function, with an externally provided password, as the hash
  45. ---in the db might use the new SRP verifier format.
  46. ---For this purpose, use `minetest.check_password_entry` instead.
  47. ---@see minetest.check_password_entry
  48. ---@param name string
  49. ---@param raw_password string
  50. ---@return string
  51. function minetest.get_password_hash(name, raw_password) end
  52. ---@param name string player name
  53. ---@return string # An IP address string for the player.
  54. ---The player needs to be online for this to be successful.
  55. function minetest.get_player_ip(name) end
  56. ---@return mt.AuthHandlerDef # currently active auth handler
  57. ---* Must be called *after* load time, to ensure that any custom auth handler was
  58. --- already registered.
  59. ---* Use this to e.g. get the authentication data for a player:
  60. --- `local auth_data = minetest.get_auth_handler().get_auth(playername)`
  61. function minetest.get_auth_handler() end
  62. ---@param name string; if omitted, all auth data should be considered modified
  63. ---Must be called by the authentication handler for privilege changes.
  64. ---@see mt.AuthHandlerDef
  65. function minetest.notify_authentication_modified(name) end
  66. ---Set password hash of player `name`.
  67. ---@param name string
  68. ---@param password_hash string
  69. ---Calls the authentication handler.
  70. ---@see mt.AuthHandlerDef
  71. function minetest.set_player_password(name, password_hash) end
  72. ---Set privileges of player `name`.
  73. ---@param name string
  74. ---@param privs mt.PrivsSet
  75. ---Calls the authentication handler.
  76. ---@see mt.AuthHandlerDef
  77. function minetest.set_player_privs(name, privs) end
  78. ---* See `reload()` in authentication handler definition
  79. ---Calls the authentication handler.
  80. ---@see mt.AuthHandlerDef
  81. function minetest.auth_reload() end