@@ -197,6 +197,7 @@ The node currently exposes the following APIs:
197197- ` /postassetmedia ` (POST)
198198- ` /refreshtransfers ` (POST)
199199- ` /restore ` (POST)
200+ - ` /revoketoken ` (POST)
200201- ` /rgbinvoice ` (POST)
201202- ` /sendasset ` (POST)
202203- ` /sendbtc ` (POST)
@@ -223,6 +224,95 @@ given above, you can even call the APIs directly from the Swagger UI.
223224
224225To stop the daemon, exit with the ` /shutdown ` API (or press ` Ctrl+C ` ).
225226
227+ ### Authentication
228+
229+ RLN provides API authentication via [ Biscuit tokens] .
230+
231+ #### One-time setup
232+
233+ First, generate a root keypair. This keypair is your issuer key: the private
234+ half signs new tokens, and the public half is shared with your node so it can
235+ verify them.
236+
237+ ``` sh
238+ # install the biscuit CLI (or download a prebuilt binary from the Biscuit releases page
239+ cargo install biscuit-cli
240+
241+ # generate a root keypair (prints both keys)
242+ biscuit keypair
243+
244+ # alternatively, you can export just the private key
245+ biscuit keypair --only-private-key > private-key-file
246+ # and later derive the public key from it
247+ biscuit keypair --from-private-key-file private-key-file --only-public-key
248+ ```
249+
250+ Save the private key in a secure way (e.g. in a secret manager).
251+
252+ When starting the node, pass the public key with:
253+ ``` sh
254+ --root-public-key < public_key>
255+ ```
256+ To ** disable** authentication provide the explicit ` --disable-authentication `
257+ arg and do not provide any key.
258+
259+ #### Minting tokens
260+
261+ You can now create Biscuit tokens that will allow calling the authenticated
262+ APIs.
263+
264+ Tokens must carry a ** role** , these are the available roles:
265+
266+ - ** admin** token (full access):
267+ ``` sh
268+ echo ' role("admin");' \
269+ | biscuit generate --private-key-file private-key-file -
270+ ```
271+
272+ - ** read-only** token (allows access only to endpoints that do not make any
273+ write operations):
274+ ` ` ` sh
275+ echo ' role("read-only");' \
276+ | biscuit generate --private-key-file private-key-file -
277+ ` ` `
278+ - ** custom** token (allows access only to the specified API paths), for
279+ example:
280+ ` ` ` sh
281+ echo ' role("custom");
282+ right("api", "/nodeinfo");
283+ right("api", "/networkinfo");' \
284+ | biscuit generate --private-key-file private-key-file -
285+ ` ` `
286+
287+ Tokens can also carry an ** expiry** date. Add a ` check` clause to enforce
288+ expiration, for example:
289+ ` ` ` sh
290+ echo ' role("admin");
291+ check if time($t), $t <= 2025-08-30T00:00:00Z;' \
292+ | biscuit generate --private-key-file private-key-file -
293+ ` ` `
294+
295+ # ### Using tokens
296+
297+ All authenticated requests must include the Biscuit token in the
298+ ` Authorization` header:
299+
300+ ` ` ` sh
301+ curl -H " Authorization: Bearer <token>" [...] http://< node-address> /networkinfo
302+ ` ` `
303+
304+ In the Swagger UI you can add the token by clicking the Authorize button (lock
305+ icon) at the top right, pasting the token and clicking Authorize.
306+
307+ # ### Revoking tokens
308+
309+ A token can be revoked before its expiration.
310+ When you revoke a token, the node will reject any future request carrying that
311+ token.
312+ The node exposes a ` /revoketoken` endpoint for this purpose.
313+ Internally, the node extracts the token’s revocation identifiers and adds them
314+ to its revocation list. Every request checks this list before authenticating.
315+
226316# # Test
227317
228318Tests for a few scenarios using the regtest network are included. The same
@@ -244,6 +334,7 @@ Here is a list of projects using RLN, in alphabetical order:
244334- [Thunderstack]
245335
246336
337+ [Biscuit tokens]: https://www.biscuitsec.org/
247338[RGB proxy server]: https://github.com/RGB-Tools/rgb-proxy-server
248339[ldk-sample]: https://github.com/lightningdevkit/ldk-sample
249340[OpenAPI specification]: /openapi.yaml
0 commit comments