Trading a license for short-lived tokens
A signed license is the right object to prove what a customer bought and the wrong object to hand a downstream service on every request. It is large. It carries the whole purchase — seats, editions, renewal terms — when the service checking it only wants to know one thing. And if every service verifies it by asking the license server, that server is suddenly on the hot path of every request in…
The article discusses an alternative approach to handling licensing in software systems. Traditionally, licensing information is large and carried with every request, causing performance issues and revocation challenges. To address these issues, a solution is proposed that involves using a short-lived, narrowly-scoped capability token.
This capability token is minted by a token-exchange endpoint and is verified offline using a small, pinned public key. The token contains only the necessary scopes, audience, expiration time, and a unique identifier. The license server is no longer required in the request path, reducing latency and revocation concerns.
The capability token is represented as a compact JSON Web Signature (JWS) using the ES256 algorithm, which stands for ECDSA over the NIST P-256 curve with SHA-256. This algorithm is chosen because it is readily available in the .NET base class library. The signature format used in the token is the raw fixed-width r‖s concatenation, which is different from the standard DER-encoded ECDSA signature.
The minting process involves verifying the presented license, deriving the scopes required by the specific service, and signing the token with the private key held by the token-exchange endpoint. The generated token is then returned to the client. The verification process is performed offline and includes signature verification, audience check, and expiration time validation.
By implementing this licensing approach, systems can avoid the performance and revocation problems associated with carrying large licensing information with every request. The capability token provides a lightweight and efficient solution, while ensuring that each service verifies the token's validity offline.
Rewritten by urgent.news; may contain errors — check the original. How we use AI.
Source: dev.to