umbraco / Umbraco.Headless.Client.Net

.NET Client Library and Samples for the Umbraco headless cms Cloud Service called Umbraco Heartcore
https://umbraco.com/products/umbraco-heartcore/
13 stars 14 forks source link

Fix preview cookie being cleared on each request #37

Closed rasmusjp closed 3 years ago

rasmusjp commented 3 years ago

In the PreviewController we are injecting IOptionsSnapshot<PreviewOptions> meaning it'll be created for each request. This meant that the default key used to sign the JWT was regenerated each time the controller was hit, and hence different when it's validated in the PreviewMiddleware

This PR moves the generation of the SigningCredentials to the AddPreview method instead and sets it on the options if no user SigningCredentials is set