-
Notifications
You must be signed in to change notification settings - Fork 208
added realtime jwt support #1612
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -208,7 +208,14 @@ export class Realtime { | |
| } | ||
|
|
||
| // URL carries only the project; channels/queries are sent via the subscribe message. | ||
| const queryParams = `project=${projectId}`; | ||
| let queryParams = `project=${projectId}`; | ||
|
|
||
| const jwt = this.client.config.jwt; | ||
| {% if language.name != 'ReactNative' %} | ||
| if (jwt) { | ||
| queryParams += `&jwt=${encodeURIComponent(jwt)}`; | ||
| } | ||
| {% endif %} | ||
|
|
||
| const endpoint = | ||
| this.client.config.endpointRealtime !== '' | ||
|
|
@@ -243,10 +250,11 @@ export class Realtime { | |
| {% if language.name == 'ReactNative' %} | ||
| const WebSocketCtor: any = WebSocket; | ||
| const socket = (this.socket = Platform.OS === 'web' | ||
| ? new WebSocketCtor(url) | ||
| ? new WebSocketCtor(jwt ? `${url}&jwt=${encodeURIComponent(jwt)}` : url) | ||
| : new WebSocketCtor(url, undefined, { | ||
| headers: { | ||
| Origin: `{{ spec.title | caseLower }}-${Platform.OS}://${this.client.config.platform}` | ||
| Origin: `{{ spec.title | caseLower }}-${Platform.OS}://${this.client.config.platform}`, | ||
| ...(jwt ? { 'x-{{ spec.title | caseLower }}-jwt': jwt } : {}) | ||
| } | ||
| })); | ||
|
Comment on lines
250
to
259
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new Consider either: (a) storing the JWT used at connection time and forcing a reconnect in |
||
| {% else %} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all non-ReactNative (browser) targets the JWT is appended to the WebSocket upgrade URL as
?jwt=<token>. Because the HTTP Upgrade request is a standard HTTP GET, the full URL — including the JWT — will appear in server-side access logs, reverse-proxy logs, and load-balancer logs. Anyone with read access to those logs can extract a valid bearer token.The same limitation applies to the browser and flutter-browser templates. If log-based token exposure is a concern, consider rotating short-lived JWTs and ensuring log-scrubbing is in place on the server side.