Implement some authentication
This commit is contained in:
5
server/templates/auth.lua
Normal file
5
server/templates/auth.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
return {
|
||||
id = "{{ id }}",
|
||||
token = "{{ token }}",
|
||||
server = "{{ server }}"
|
||||
}
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user