LF-5416 Add a 30-second single-use dashboard ticket endpoint - #4304
Merged
Conversation
POST /login/dashboard/ticket mints a 30-second signed ticket naming the caller's own user and, optionally, one farm they are an Active member of. The Analytics Dashboard trades the ticket server-to-server for that identity, so no identity travels in a browser-visible URL. Each ticket carries a randomUUID jti for the replay table added in a follow-up. JWT_DASHBOARD_SECRET is a sixth signing secret, so a leaked ticket can never be presented as a login token. return_to must match an entry of DASHBOARD_ALLOWED_RETURN_TO exactly. Without that check, an attacker could send a user to a sign-in URL bearing their own return address and be handed a valid ticket. Empty entries are filtered out of the parsed list, so an unset or blank variable rejects every address rather than matching an empty return_to. checkJwt is attached to the route directly, because the login router is mounted before the global checkJwt in server.ts. user_id is read from req.auth only; a user_id in the request body is ignored. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
kathyavini
commented
Aug 5, 2026
|
|
||
| # Comma-separated exact addresses an Analytics Dashboard ticket may be returned to. | ||
| # Contact the Analytics Dashboard team for the value for your environment. | ||
| DASHBOARD_ALLOWED_RETURN_TO=? |
Collaborator
Author
There was a problem hiding this comment.
This being an .env variable was taken from the spec so I maintained it, but these are public URLs and to consider them secrets is a bit of a stretch. Still it will give us some flexibility to adjust without a full release.
SayakaOno
deleted the
LF-5416-add-a-30-second-single-use-dashboard-ticket-issued-only-to-an-allowlisted-return-address
branch
August 6, 2026 22:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This change adds the LiteFarm half of a ticket exchange with the Analytics Dashboard at
https://data.litefarm.org.POST /login/dashboard/ticketmints a 30-second signed string naming the caller's user and, optionally, one farm they are anActivemember of. The Dashboard's server will later redeem it against LiteFarm for that identity — that endpoint is a follow-up. Tickets are signed with a sixth secret,JWT_DASHBOARD_SECRET, so a leaked ticket can never be presented as a login token for the LiteFarm API.Using the endpoint
The web app calls this with a normal
Authorization: Bearerlogin token. Request body:{ "return_to": "https://dashboard.example/auth/finish", "farm_id": "8fd0a3c2-…" }Response body:
{ "ticket": "eyJhbGciOiJIUzI1NiIs…", "return_to": "https://dashboard.example/auth/finish" }return_tois where the web app will send the browser next, carrying the ticket, and must be one of the addresses inDASHBOARD_ALLOWED_RETURN_TO.farm_idnames the farm the user is currently viewing. It is sent when the user clicks through from Insights, and omitted when the user came from the Dashboard and has not chosen a farm yet, in which case the ticket'sfarm_idclaim isnull.Before this reaches beta or production
JWT_DASHBOARD_SECRETandDASHBOARD_ALLOWED_RETURN_TOboth have to be added by hand topackages/api/.envon each host, the secret being a different long random string per environment. Nothing calls the endpoint yet.Jira link: https://lite-farm.atlassian.net/browse/LF-5416
Type of change
How Has This Been Tested?
Checklist:
pnpm i18nto help with this)