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

feat(pubsub): v5 - AppSync realtime - pass authToken via subprotocol #13726

Merged
merged 2 commits into from
Aug 27, 2024

Conversation

iartemiev
Copy link
Member

@iartemiev iartemiev commented Aug 19, 2024

Description of changes

AppSync Realtime is changing the way it accepts auth tokens when establishing subscription connections.

Today auth tokens are passed in the connection url as a query string param, e.g. wss://api.example.com/graphql?header=<base64_encoded_token>

Going forward, the service expects the client to pass the auth token through as a WS subprotocol:

const url = 'wss://api.example.com/graphql'
const protocols = ['graphql-ws', 'base64url_encoded_token']

new WebSocket(url, protocols)

This change is an implementation detail that does not affect the behavior of the AppSyncRealtime client. AppSync will continue to accept the auth token in query params for existing APIs, so older versions of the Amplify library will work as expected.

Note

The WebSocket Web API prohibits separator characters in subprotocol values, e.g. /, =, which are part of the standard base64 char set. With this change, the auth token is encoded as base64url, which lacks any prohibited characters in its alphabet. AppSync now supports this encoding for auth headers.

Description of how you validated changes

  • manual testing
  • updated unit tests

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@iartemiev iartemiev changed the title feat(pubsub): AppSync realtime - pass authToken via subprotocol feat(pubsub): v5 - AppSync realtime - pass authToken via subprotocol Aug 22, 2024
@iartemiev iartemiev marked this pull request as ready for review August 27, 2024 14:24
@iartemiev iartemiev requested review from a team as code owners August 27, 2024 14:24
@iartemiev iartemiev merged commit 774c242 into aws-amplify:v5-stable Aug 27, 2024
28 checks passed
@iartemiev iartemiev deleted the v5-wss-header-auth branch August 27, 2024 19:05
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