Implement some authentication

This commit is contained in:
2022-09-25 23:57:17 +02:00
parent 1a46cf7ef3
commit fb44bc2178
15 changed files with 373 additions and 206 deletions

View File

@@ -0,0 +1,5 @@
return {
id = "{{ id }}",
token = "{{ token }}",
server = "{{ server }}"
}

View File

@@ -1,5 +1,22 @@
local args = { ... }
local token = args[1]
local existing = fs.exists("auth.lua")
if not token and not existing then
error("A token is required.")
end
local path = "{{ deploy_path }}"
files = { "main.lua", "json.lua", "framebuffer.lua", "ringbuffer.lua", "socket.lua" }
if existing then
print("Found auth.lua, skipping")
elseif token then
print("Using token...")
shell.run(("wget %s/api/issue-id/%s auth.lua"):format(path, token))
if not fs.exists("auth.lua") then
error("Token failed!")
end
end
local files = { "main.lua", "json.lua", "framebuffer.lua", "ringbuffer.lua", "socket.lua" }
for _, file in ipairs(files) do
fs.delete(file)
shell.run(("wget %s/lua/%s"):format(path, file))