Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add example of passing bearer auth token with setup frame #287

Merged

Conversation

viglucci
Copy link
Member

Provides an example of passing authentication context via a bearer token with the setup frame via composite metadata.

Motivation:

Demonstrate how to pass a bearer token or other metdata during connection/setup.

Modifications:

Added new examples and npm scripts.

start-client-server-composite-metadata-auth-setup-frame-example-client
start-client-server-composite-metadata-auth-setup-frame-example-server

Result:

Server logs:

[2024-10-15 02:38:17] Server bound...
[2024-10-15 02:38:23] Auth error during setup. Peer will be closed. Caused by: Error: Missing authentication context.
[2024-10-15 02:38:23] User connected... {"firstName":"bob","lastName":"builder"}
[2024-10-15 02:38:23] Handling EchoService.echo
[2024-10-15 02:38:24] Handling UnknownService.unknown
[2024-10-15 02:38:24] Handling AuthService.whoAmI
[2024-10-15 02:38:24] User disconnected... {"firstName":"bob","lastName":"builder"}

Client logs:

[2024-10-15 02:38:23] Rejecting once socket closes...
[2024-10-15 02:38:23] Expected error: Error: TcpDuplexConnection: Socket closed unexpectedly.
[2024-10-15 02:38:24] onNext payload[data: Echo: Hello World; metadata: null]|true
[2024-10-15 02:38:24] EchoService.echo response: Echo: Hello World
[2024-10-15 02:38:24] Expected error: Error: The encoded route was unknown by the server.
[2024-10-15 02:38:24] Expected error: Error: Composite metadata did not include routing information.
[2024-10-15 02:38:24] onNext payload[data: {"firstName":"bob","lastName":"builder"}; metadata: null]|true
[2024-10-15 02:38:24] AuthService.whoAmI response: {"firstName":"bob","lastName":"builder"}

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
@viglucci viglucci added documentation 1.0 Pullrequests & issues related to the Typescript rewrite and 1.0 release labels Oct 15, 2024
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
@viglucci viglucci merged commit 93dbba2 into 1.0.x-alpha Oct 15, 2024
4 checks passed
viglucci added a commit that referenced this pull request Dec 31, 2024
* chore: add example of passing bearer auth token with setup frame

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>

* chore: apply linting

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>

---------

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.0 Pullrequests & issues related to the Typescript rewrite and 1.0 release documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant