/token should provide JSON

This commit is contained in:
Ryan Cavicchioni 2025-05-09 10:49:24 -05:00
parent 66c2c3b6a2
commit 3c2e0cdcb8
Signed by: ryanc
SSH Key Fingerprint: SHA256:KbXiwUnZnHFwFtt3Bytd+F3FN9pPHn1Z1cxMIE1TPbg

3
app.rb
View File

@ -380,14 +380,13 @@ get "/pid", provides: "json" do
jsonify({ppid: ppid, pid: Process.pid}, pretty:) jsonify({ppid: ppid, pid: Process.pid}, pretty:)
end end
get "/token" do get "/token", provides: "json" do
exp = Time.now.to_i + SECONDS_PER_MINUTE * 2 exp = Time.now.to_i + SECONDS_PER_MINUTE * 2
payload = {name: "anonymous", exp: exp, jti: Random.uuid} payload = {name: "anonymous", exp: exp, jti: Random.uuid}
expires_at = Time.at(exp).to_datetime expires_at = Time.at(exp).to_datetime
token = JWT.encode payload, config.jwt_secret.unwrap, "HS256" token = JWT.encode payload, config.jwt_secret.unwrap, "HS256"
x = {token: token, expires_at: expires_at} x = {token: token, expires_at: expires_at}
jsonify x
end end
get "/token/validate" do get "/token/validate" do