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 composite metadata bearer auth example #286

Merged
merged 3 commits into from
Oct 15, 2024

Conversation

viglucci
Copy link
Member

Motivation:

Provides a basic example for communicating authentication contexts, such as a Bearer auth tokens via composite metadata.

Modifications:

  • Adds new example
  • Adds NPM scripts in example folder for running example
cd packages/rsocket-examples
npm run start-client-server-composite-metadata-auth-example-server
npm run start-client-server-composite-metadata-auth-example-client

Result:

Server logs:

[2024-10-14 01:29:59] Server bound...
[2024-10-14 01:30:00] Handling EchoService.echo
[2024-10-14 01:30:01] Handling UnknownService.unknown
[2024-10-14 01:30:01] Auth error: Error: Invalid Bearer token provided.
[2024-10-14 01:30:01] Auth error: Error: Missing authentication context.
[2024-10-14 01:30:01] Handling AuthService.whoAmI

Client logs:

[2024-10-14 01:30:01] payload[data: Echo: Hello World; metadata: null]|true
[2024-10-14 01:30:01] EchoService.echo response: Echo: Hello World
[2024-10-14 01:30:01] Expected error: Error: The encoded route was unknown by the server.
[2024-10-14 01:30:01] Expected error: Error: Composite metadata did not include routing information.
[2024-10-14 01:30:01] Expected error: Error: Invalid Bearer token provided.
[2024-10-14 01:30:01] Expected error: Error: Missing authentication context.
[2024-10-14 01:30:01] payload[data: {"firstName":"bob","lastName":"builder"}; metadata: null]|true
[2024-10-14 01:30:01] AuthService.whoAmI response: {"firstName":"bob","lastName":"builder"}

@viglucci viglucci merged commit ee00386 into 1.0.x-alpha Oct 15, 2024
4 checks passed
@viglucci viglucci added documentation 1.0 Pullrequests & issues related to the Typescript rewrite and 1.0 release labels Oct 15, 2024
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