Skip to content

docs: client authentication, connect uid and Japa testing#44

Merged
thetutlage merged 1 commit into
adonisjs:3.xfrom
LeCoupa:patch-2
Jun 3, 2026
Merged

docs: client authentication, connect uid and Japa testing#44
thetutlage merged 1 commit into
adonisjs:3.xfrom
LeCoupa:patch-2

Conversation

@LeCoupa
Copy link
Copy Markdown
Contributor

@LeCoupa LeCoupa commented Jun 3, 2026

What

Extends the README with the three areas that were missing:

  • Channel Authorization — explains that __transmit/subscribe / __transmit/unsubscribe are public by default, so ctx.auth.user is undefined unless those routes go through your auth middleware. Adds a transmit.registerRoutes snippet to protect them.
  • Client (new section) — installing @adonisjs/transmit-client, creating the client, and using the beforeSubscribe hook to attach an Authorization: Bearer <token> header on every subscription request, plus subscribing and listening for messages.
  • Events — adds a note clarifying that the connect / disconnect events expose the client uid, which can be mapped to the authenticated user.
  • Testing (new section) — shows how to assert on broadcasts in Japa by collecting them through transmit.on('broadcast', ...) (which returns a stop function), and how to test that an unauthenticated subscription is rejected with a 401.
  • Updates the Table of Contents (Client, Testing).

Why

The docs only covered server-side transmit.authorize, with no guidance on authenticating the client, on the lifecycle uid, or on testing broadcasts. These are common needs when securing private channels.

Notes

  • beforeSubscribe receives a single Request argument, so headers are mutated via request.headers.set(...).
  • The subscribe route is a POST, so the auth test posts to /__transmit/subscribe.

@thetutlage thetutlage merged commit e541abf into adonisjs:3.x Jun 3, 2026
8 checks passed
@thetutlage
Copy link
Copy Markdown
Member

Thanks 👍🏽

@RomainLanz
Copy link
Copy Markdown
Member

Could you also provide a PR for the documentation here https://github.com/adonisjs/v7-docs ?

@LeCoupa
Copy link
Copy Markdown
Contributor Author

LeCoupa commented Jun 6, 2026

yes i will do it on monday :)

@LeCoupa LeCoupa deleted the patch-2 branch June 6, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants