1
0
mirror of https://github.com/kepler155c/opus synced 2025-11-26 12:04:52 +00:00

Add a one-time password system (#47)

This commit adds a one-time password system. Users can generate
passwords by using the `genotp` command (or manually queuing a set_otp
event with the SHA-256 hash of the one-time password they want to set)
and these passwords will be valid, along with the normal password,
either until the computer shuts down (or the net daemon is killed), a
new one-time password is generated, or the one-time password is used.
This commit is contained in:
Kan18
2020-08-24 01:20:42 -04:00
committed by GitHub
parent 01d8d65178
commit a77deb72ec
2 changed files with 53 additions and 9 deletions

14
sys/apps/genotp.lua Normal file
View File

@@ -0,0 +1,14 @@
local SHA = require("opus.crypto.sha2")
local acceptableCharacters = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
local acceptableCharactersLen = #acceptableCharacters
local password = ""
for _i = 1, 8 do
password = password .. acceptableCharacters[math.random(acceptableCharactersLen)]
end
os.queueEvent("set_otp", SHA.compute(password))
print("Your one-time password is: " .. password)