-
Notifications
You must be signed in to change notification settings - Fork 97
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
Authentication with v1.0.0.alpha #285
Comments
Hi @saleweaver -- I've added a basic example which shows how you can accomplish authentication at request time using composite metadata. Apologies this wasn't more straight forward / discoverable on your own. This is pretty close to your example above, and I haven't tried testing this against spring so there may still be some nuance there. Notable differences are that I didn't add my metadata to the setup payload, but provided it on each request, I'll likely add an example of providing it in the setup payload soon as that seems more relevant. Please see #286. Note that in my example I used a Yours: private getCompositeMetadata(token: string | Signal<string> | (() => (string | Signal<string>)) | undefined, route: string) {
const resolvedToken = this.resolveProvidedToken(token);
const metadataPairs: [WellKnownMimeType, Buffer][] = [
[MESSAGE_RSOCKET_ROUTING, encodeRoute(route)],
];
if (resolvedToken) {
metadataPairs.push([
MESSAGE_RSOCKET_AUTHENTICATION,
encodeBearerAuthMetadata(resolvedToken),
]);
}
return encodeCompositeMetadata(metadataPairs);
} vs. Mine: function makeMetadata(bearerToken?: string, route?: string) {
const map = new Map<WellKnownMimeType, Buffer>();
if (bearerToken) {
map.set(
MESSAGE_RSOCKET_AUTHENTICATION,
encodeBearerAuthMetadata(Buffer.from(bearerToken))
);
}
if (route) {
const encodedRoute = encodeRoute(route);
map.set(MESSAGE_RSOCKET_ROUTING, encodedRoute);
}
return encodeCompositeMetadata(map);
} |
Hey Kevin, thanks for that, I'll give it a try. I didn't find the well known metadata enums in v1, but I likely didn't look close enough. Will have a look. Thanks for the example! |
Hi,
I've created a angular wrapper based on version 0.2.9.alpha, which isn't working because of #263, RSocketWebsocketClient is not a constructor (likely it has more errors, couldn't test).
Link to the repo https://github.com/saleweaver/angular-rsocket (qwen coder made a mistake with async code, will be fixed...)
Now I was looking into upgrading to v1.0.0.alpha, but can't find a way to pass authentication to the client.
In version 0.0.29.alpha I could add tokens using WellKnownMimeTypes, but I can't find any documentation on v1 auth, and, looking through the code, can't find anything that seems related to auth.
I'm sure I'm missing something, can someone tell me what it is? Is there an option to add auth? If not, has there ever been a version 0.0.xxx where RSocketWebsocketClient could be instantiated in the browser - and if not, do you still accept pull requests for version 0.0.29?
Thanks a lot!
Here's some code how I added tokens to metadata to be read by spring rsocket.
EDIT:
I've converted the RSocketWebsocketClient to typescript, now it works with v0.0.29
The text was updated successfully, but these errors were encountered: