/token should provide pretty-printing
All checks were successful
Ruby Test / test (push) Successful in 18s
Ruby Lint / lint (push) Successful in 24s

This commit is contained in:
Ryan Cavicchioni 2025-05-09 10:50:26 -05:00
parent 3c2e0cdcb8
commit 2d1c9f7418
Signed by: ryanc
SSH Key Fingerprint: SHA256:KbXiwUnZnHFwFtt3Bytd+F3FN9pPHn1Z1cxMIE1TPbg

3
app.rb
View File

@ -381,12 +381,15 @@ get "/pid", provides: "json" do
end end
get "/token", provides: "json" do get "/token", provides: "json" do
pretty = params.key? :pretty
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, pretty:
end end
get "/token/validate" do get "/token/validate" do