javascript - How to use Kinesis Video Stream WebRTC SDK in the browser without providing credentials? - Stack Overflow

I want to use kinesis video streams webrtc javascript sdk for producing video stream from a web page.T

I want to use kinesis video streams webrtc javascript sdk for producing video stream from a web page. The sdk readme says i need to supply accessKeyId and secrectAccessKey

signalingClient = new KVSWebRTC.SignalingClient({
    channelARN,
    channelEndpoint: endpointsByProtocol.WSS,
    clientId,
    role: KVSWebRTC.Role.VIEWER,
    region,
    credentials: {
        accessKeyId,
        secretAccessKey,
    },
    systemClockOffset: kinesisVideoClient.config.systemClockOffset,
});

Is there a way to make this more secure and avoid supplying the secret access key inside the javascript code? Doesn't it mean anyone viewing my web page source can take these credentials from the web page and use them to access the signaling channel? Can I use amplify-js Auth class to use the signaling client with an authenticated user?

I want to use kinesis video streams webrtc javascript sdk for producing video stream from a web page. The sdk readme says i need to supply accessKeyId and secrectAccessKey

signalingClient = new KVSWebRTC.SignalingClient({
    channelARN,
    channelEndpoint: endpointsByProtocol.WSS,
    clientId,
    role: KVSWebRTC.Role.VIEWER,
    region,
    credentials: {
        accessKeyId,
        secretAccessKey,
    },
    systemClockOffset: kinesisVideoClient.config.systemClockOffset,
});

Is there a way to make this more secure and avoid supplying the secret access key inside the javascript code? Doesn't it mean anyone viewing my web page source can take these credentials from the web page and use them to access the signaling channel? Can I use amplify-js Auth class to use the signaling client with an authenticated user?

Share Improve this question edited Jul 10, 2020 at 1:37 Marcelo Luiz Onhate 5218 silver badges18 bronze badges asked May 20, 2020 at 18:21 tomeraztomeraz 3234 silver badges16 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

Turns out I can use credentials inside the backend, and send a presigned link to the client using the class SigV4RequestSigner. There's no need to supply credentials on the client side.

Found it in the documentation:

This is a useful class to use in a NodeJS backend to sign requests and send them back to a client so that the client does not need to have AWS credentials.

When creating the SignalingClient you can either specify the credentials or a requestSigner that returns a Promise<string>, see:

https://github./awslabs/amazon-kinesis-video-streams-webrtc-sdk-js/blob/master/README.md#class-signalingclient

credentials {object} Must be provided unless a requestSigner is provided.

Be aware that when not using credentials in the browser you will also need to run the KinesisVideoSignalingChannels related code on the server side, because this class does not supports request signer.

For Kinesis, one of the possibilities is to implement in your NodeJS backend a function for signing your URLs.

const endpointsByProtocol = getSignalingChannelEndpointResponse.ResourceEndpointList.reduce((endpoints, endpoint) => {
    endpoints[endpoint.Protocol] = endpoint.ResourceEndpoint;
    return endpoints;
}, {});
console.log('[VIEWER] Endpoints: ', endpointsByProtocol);

const region = "us-west-2";
const credentials = {
    accessKeyId: "XAXAXAXAXAX",
    secretAccessKey: "SECRETSECRET"
};
const queryParams = {
    'X-Amz-ChannelARN': channelARN,
    'X-Amz-ClientId': formValues.clientId
}
const signer = new SigV4RequestSigner(region, credentials);
const url = await signer.getSignedURL(endpointsByProtocol.WSS, queryParams);
console.log(url);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745205457a4616573.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信