From d140a845f1a53247a507cc248035d77e6cb730fe Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Thu, 2 Feb 2023 14:34:50 +0100 Subject: [PATCH] image/issuer customization --- onboard.lua | 18 ++++++++++++------ readme.md | 5 +++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/onboard.lua b/onboard.lua index bf3e2f6..1f4cc78 100644 --- a/onboard.lua +++ b/onboard.lua @@ -16,13 +16,19 @@ minetest.register_chatcommand("otp_enable", { description = "Enable the otp verification", func = function(name) -- issuer name - local issuer = "Minetest" - if minetest.settings:get("server_name") ~= "" then - issuer = minetest.settings:get("server_name") - elseif minetest.settings:get("server_address") ~= "" then - issuer = minetest.settings:get("server_address") + local issuer = minetest.settings:get("otp.issuer") or "Minetest" + local server_name = minetest.settings:get("server_name") + local server_address = minetest.settings:get("server_address") + if server_name and server_name ~= "" then + issuer = server_name + elseif server_address and server_address ~= "" then + issuer = server_address end + -- authenticator image + local image = minetest.settings:get("otp.authenticator_image") or + "https://raw.githubusercontent.com/minetest/minetest/master/misc/minetest-xorg-icon-128.png" + local secret_b32 = otp.get_player_secret_b32(name) -- url for the qr code @@ -31,7 +37,7 @@ minetest.register_chatcommand("otp_enable", { "&issuer=" .. issuer .. "&period=30" .. "&secret=" .. secret_b32 .. - "&image=https://raw.githubusercontent.com/minetest/minetest/master/misc/minetest-xorg-icon-128.png" + "&image=" .. image local ok, code = otp.qrcode(url) if not ok then diff --git a/readme.md b/readme.md index 6b65dc6..89fbe25 100644 --- a/readme.md +++ b/readme.md @@ -37,6 +37,11 @@ minetest.register_privilege("my_super_important_priv", { }) ``` +# Settings + +* `otp.authenticator_image` The image to use in the QR code for the otp app (defaults to "https://raw.githubusercontent.com/minetest/minetest/master/misc/minetest-xorg-icon-128.png") +* `otp.issuer` The issuer name, defaults to server name, address or just "Minetest" + # Links / References * https://en.wikipedia.org/wiki/Time-based_one-time_password