TypeScript servicestack-clientを使用して、ServiceStack ServerからSSEイベントにフックしようとしています。Typescript Servicestack SSEイベントのクライアント認証
認証がAuthenticate
クラスを送信し、sesssionクッキーを受信することにより構成されています
import { ServerEventsClient } from 'servicestack-client';
export class ServicestackService {
private sseClient: ServerEventsClient;
constructor() {
this.createSseClient();
}
login(username: string, password: string) {
let request = new Authenticate(username, password);
return this.sseClient.serviceClient.post(request);
}
startClient() {
this.sseClient.start();
console.log('eventSource created');
}
subscribeChannel(channel: string) {
this.sseClient.subscribeToChannels(channel);
}
private createSseClient() {
this.sseClient = new ServerEventsClient('http://ss_api_url', ['*'], {
handlers: { ...define handlers for onConnect & onMessage here... }
}
}
}
上記のコードが正常にagainsのservicestackのAPIおよびセキュアなAPIリクエストを認証に適しています。 startClient()
メソッドは、すべてのログイン認証が完了した後に呼び出され、オブジェクトをプロパティとしてthis.sseClient
に作成します。
しかし、このオブジェクトはwithCredentials: false
です! したがって、servicestackクライアントがCookies
ヘッダーを送信していないため、次のチャネルサブスクリプションのいずれも認証されないため失敗します。
認証済みSSE接続はどのようにして実現できますか?