Extend callback token expiry from 1 hour to 7 days
The signed callback token for /api/prompt/<rid> expired after 1 hour. That was too short for a workflow where the operator may copy the URL and paste it to Hermes, then wait for a response. Extend to 7 days. Also fixes the misleading 401 on expired tokens (token check runs before API key check). The new /api/key-test endpoint lets callers verify the API key independently. Bump version 0.4.4 -> 0.4.5.
This commit is contained in:
parent
2637cdba61
commit
235507f499
3 changed files with 5 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# Theme Song Booth
|
# Theme Song Booth
|
||||||
|
|
||||||
**Version:** `v0.4.4`
|
**Version:** `v0.4.5`
|
||||||
|
|
||||||
A Flask web app for a convention booth where visitors request a custom AI-generated theme song, the operator manages the queue, and the final MP3(s) are delivered by email after payment.
|
A Flask web app for a convention booth where visitors request a custom AI-generated theme song, the operator manages the queue, and the final MP3(s) are delivered by email after payment.
|
||||||
|
|
||||||
|
|
|
||||||
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
||||||
0.4.4
|
0.4.5
|
||||||
|
|
|
||||||
5
app.py
5
app.py
|
|
@ -360,8 +360,9 @@ def sign_prompt_callback(rid, expires_at=None):
|
||||||
"""
|
"""
|
||||||
secret = current_app.config['SECRET_KEY'].encode()
|
secret = current_app.config['SECRET_KEY'].encode()
|
||||||
if expires_at is None:
|
if expires_at is None:
|
||||||
# Default expiry: 1 hour.
|
# Default expiry: 7 days, so operators have plenty of time to copy the
|
||||||
expires_at = int(time.time()) + 3600
|
# callback URL into Hermes and for Hermes to POST back.
|
||||||
|
expires_at = int(time.time()) + 7 * 24 * 3600
|
||||||
payload = f"{rid}:{expires_at}"
|
payload = f"{rid}:{expires_at}"
|
||||||
sig = hmac.new(secret, payload.encode(), hashlib.sha256).hexdigest()[:16]
|
sig = hmac.new(secret, payload.encode(), hashlib.sha256).hexdigest()[:16]
|
||||||
return f"{rid}:{expires_at}:{sig}"
|
return f"{rid}:{expires_at}:{sig}"
|
||||||
|
|
|
||||||
Reference in a new issue