-
Notifications
You must be signed in to change notification settings - Fork 47
Inject ICorsPolicyProvider instance through Invoke #106
Conversation
@Eilon are we going forward with this PR? And if so, do you want me to update (rebase) it? |
{ | ||
if (context.Request.Headers.ContainsKey(CorsConstants.Origin)) | ||
{ | ||
var corsPolicy = _policy ?? await _corsPolicyProvider?.GetPolicyAsync(context, _corsPolicyName); | ||
var corsPolicy = _policy ?? await corsPolicyProvider?.GetPolicyAsync(context, _corsPolicyName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure this can't be null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Invoking middleware will fail if it can't resolve the parameters, right? I'll remove the ?
.
This allows for scoped instances of `ICorsPolicyProvider` to be injected in the CORS middleware and prevents turning them into singletons. Resolves #105
@davidfowl @Eilon updated and rebased. |
We need to update baseline.json as well. |
BTW per the discussion in #105, this is a breaking change, so it can't be taken as-is in the 2.1 release, so this PR is "on hold" until we figure out how to resolve that. |
This issue was moved to dotnet/aspnetcore#2376 |
Sorry I was a bad bot. Re-opening this PR. |
@mkArtakMSFT - any further action planned on this PR? I think that given it's a breaking change, I recommend we close it. |
@Eilon close? |
Why close? It needs to be fixed at some point. |
I was going by the most recent comment here:
It's likely a breaking change would necessitate waiting until 3.0. |
Sure. Don't you have a way of assigning/labeling the PR for 3.0? |
It's usually tricky to keep a PR up-to-date (merge conflicts etc) for that long. Much easier to file a tracking issue and fix it in the release. |
Resolving the moved issue: dotnet/aspnetcore#2377 |
@henkmollema, we do want to take this change in, and we've just marked the referenced issue accordingly. However, this PR is outdated already and given that we aren't going to act on it yet, you can close it if you want and we'll do the change when the right time will come. |
Tracking merging this in #202 |
This allows for scoped instances of
ICorsPolicyProvider
to be injected in the CORS middleware and prevents turning them into singletons.Resolves #105