Skip to content

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"}

Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
Signed-off-by: Kevin Viglucci <kviglucci@gmail.com>
@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
viglucci added a commit that referenced this pull request Dec 31, 2024
* chore: add composite metadata bearer auth example

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

* chore: apply linting

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

* chore: update license header at top of example

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