aws-observability / aws-rum-web

Amazon CloudWatch RUM Web Client
Apache License 2.0
114 stars 65 forks source link

[Feature Request]: Update CookieAttributes.unique behavior to control cwr_c name #557

Open ChaseFranz opened 1 month ago

ChaseFranz commented 1 month ago

Please provide your feature request

Problem

When utilizing multiple rum clients targeting app monitors in different AWS accounts (requiring a different set of AWS credentials for signatures) we receive 403 error responses on PUT requests.

Context

We currently have a MFE architecture where multiple MFE's utilize distinct rum clients. These clients each need to push metrics into distinct app monitors existing in different AWS accounts. The current configuration support of the client does not support this behavior without utilizing a proxy. All clients store credentials in the same cwr_c key. When a rum client signs a PUT request it is accessing credentials from different rum client session and causing 403 errors due to the invalid signature.

Request

We require the CookieAttributes.unique property to control the name used for cwr_c similarly to how it controls cwr_s and cwr_u. If this property is set to false the key used in local storage will continue to be cwr_c and if it's set to true use the pattern cwrc[AppMonitor Id]. This would enable rum clients requiring distinct sets of credentials to sign PUT requests properly.

qhanam commented 4 weeks ago

I think this would be a good feature addition, as it solves a common use case and should be straightforward to implement.

The unique cookie attribute makes the cwr_s key unique by appending the app monitor Id. This configuration option could be extended to make the cwr_c key unique as well. Specifically, the app monitor Id could be added to the localStorage key written within EnhancedAuthentication credential provider.