API authentication¶
The API authenticates its clients with a Bearer token: a JWT the API signs at login and the client sends with every
request. The API keeps no session: what it needs to know is in the token, signed with MUSEFLOW_JWT_SIGNING_KEY. The
Bearer token is also what ties an OAuth flow to the user who started it.
Call between programs
Action of the user
Refused
Login, then every request¶
POST /api/v1/users/register ends like the login (steps 5 to 7): it returns a token straight away.
What the token holds¶
A JWT is three base64 parts joined by dots: a header, the claims, a signature. Anyone can read the claims; only the
signature needs MUSEFLOW_JWT_SIGNING_KEY.
{"alg": "HS256", "typ": "JWT"}
{"sub": "3f2c…-the-user-id", "iat": 1795300000, "exp": 1795301800}
HMAC-SHA256(header.claims, MUSEFLOW_JWT_SIGNING_KEY)
- Nothing is stored on the server. The API keeps no session nor list of tokens: it checks the signature and the
expiry, then reads the user from
sub. Each client keeps its own token on its own device. - The signature prevents forgery. Changing
subto become someone else breaks the signature, and computing a new one needs the signing key. That is why an attacker can't make another user's Bearer token (see the #101 attack). - Current limits (#282). A token is valid until its
exp(MUSEFLOW_JWT_EXPIRE_MINUTES, 30 by default): no revocation before it, and no refresh token, so the user logs in again. Changing the signing key ends every token at once.