Skip to content

Remove RequiredPolicy #9399

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

Merged
merged 6 commits into from
Apr 18, 2019
Merged

Remove RequiredPolicy #9399

merged 6 commits into from
Apr 18, 2019

Conversation

HaoK
Copy link
Member

@HaoK HaoK commented Apr 15, 2019

Fixes #9398

@HaoK HaoK requested a review from pranavkm April 15, 2019 22:24
@analogrelay analogrelay added the area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer label Apr 16, 2019
@@ -51,6 +51,11 @@ public async Task Invoke(HttpContext context)

// IMPORTANT: Changes to authorization logic should be mirrored in MVC's AuthorizeFilter
var authorizeData = endpoint?.Metadata.GetOrderedMetadata<IAuthorizeData>() ?? Array.Empty<IAuthorizeData>();
if (authorizeData.Length == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting.

@@ -51,6 +51,12 @@ public async Task Invoke(HttpContext context)

// IMPORTANT: Changes to authorization logic should be mirrored in MVC's AuthorizeFilter
var authorizeData = endpoint?.Metadata.GetOrderedMetadata<IAuthorizeData>() ?? Array.Empty<IAuthorizeData>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rynowak \ @JamesNK can we have GetOrderedMetadata return an IReadOnlyList<T>? It internally caches an T[] so there isn't any code change involved with it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Eilon, @rynowak pointed out that this would be a breaking change since the API exists in 2.2. However, this seems like a worthwhile change to make - other APIs and users are likely to benefit from this change. How do you feel about this change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just do Count() here. It'll effectively be the same: https://github.com/dotnet/corefx/blob/master/src/System.Linq/src/System/Linq/Count.cs#L12-L22

@HaoK
Copy link
Member Author

HaoK commented Apr 17, 2019

@pranavkm test failure which doesn't look related to this change, is this a known issue? Should I just retry?

   at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at Microsoft.AspNetCore.Mvc.FunctionalTests.HttpClientExtensions.GetHtmlDocumentAsync(HttpClient client, String requestUri) in /_/src/Mvc/test/Mvc.FunctionalTests/Infrastructure/HttpClientExtensions.cs:line 18
   at Microsoft.AspNetCore.Mvc.FunctionalTests.FlushPointTest.FlushFollowedByLargeContent() in /_/src/Mvc/test/Mvc.FunctionalTests/FlushPointTest.cs:line 45
--- End of stack trace from previous location where exception was thrown ---
----- Inner Stack Trace -----
   at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
   at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
   at System.IO.Pipelines.Pipe.GetReadAsyncResult()
   at Microsoft.AspNetCore.TestHost.ResponseStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) in /_/src/Hosting/TestHost/src/ResponseStream.cs:line 114
   at System.IO.Stream.CopyToAsyncInternal(Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
   at System.Net.Http.StreamToStreamCopy.<>c.<DisposeSourceWhenCompleteAsync>b__1_0(Task completed, Object innerSource)
   at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location where exception was thrown ---
   at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer)
----- Inner Stack Trace -----

@pranavkm
Copy link
Contributor

@pranavkm
Copy link
Contributor

Yeah, I kicked off a retry. It's a fairly new test, so perhaps there's a bug :(

@aspnet-hello
Copy link

This comment was made automatically. If there is a problem contact ryanbrandenburg.

I've triaged the above build. I've created/commented on the following issue(s)
https://github.com/aspnet/AspNetCore-Internal/issues/2300

@HaoK HaoK merged commit 47ae9d9 into master Apr 18, 2019
HaoK added a commit that referenced this pull request Apr 25, 2019
@natemcmaster natemcmaster deleted the haok-noreq branch May 3, 2019 06:21
HaoK added a commit that referenced this pull request May 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove AuthorizationOptions.RequiredPolicy
5 participants