-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add Security Headers in Response.OnStarting #39
Comments
Hmm, could you link to a sample of its usage? That certainly sounds like something that could be done. |
Thanks, I'll try to look at doing this in the weekend. |
FYI, I just did a quick test with this and it seemed to work
|
Couldn't implement this quite yet, the change is incompatible with the current unit tests. Getting a NotImplementedException when calling OnStarting to register the delegate. |
Understood. Thank you for looking at it. I took a bit of time today to play around with it. I was able to get something similar to this working in some tests of a similar middleware: https://stackoverflow.com/questions/49740194/unit-testing-asp-net-core-httpresponse-onstarting Not sure if you ran across this approach. |
Ooh, mocking the response feature interface with Moq might work :) |
It looks like you are adding headers before calling next() in the middleware. This means that any middleware registered after the security header middleware does not have a chance to preempt the middleware and add their own more appropriate headers.
Have you considered registering an action to be invoked on Response.OnStarting? This would allow for you to check to see if any other middleware closer to the response generation had already added the header.
The text was updated successfully, but these errors were encountered: