Aspnetcore.docs: Single policy with multiple requirements

Created on 1 Feb 2019  Â·  8Comments  Â·  Source: dotnet/AspNetCore.Docs

It's not clear how a single policy with multiple requirements will work. Do all requirements have to pass, or is a single one enough? In other words, does it work like an "AND" or an "OR" between the requirements?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

P1 P2 Source - Docs.ms

All 8 comments

I understand that all handlers for all requirements will be called, but in order for the policy to succeed, is it sufficient for a single one of them to pass? Or does (at least) one handler _for each requirement_ need to pass?

If one handler returns context.Succeed and no handler returns context.Fail, it succeeds.

If any handler returns context.Fail, it fails.

Return Task.CompletedTask when requirements aren't met. Task.CompletedTask is neither success or failure—it allows other authorization handlers to run.

I suppose I could add that to the doc.

@blowdart are you OK with me adding that to the doc?

I don't think you need to add that to the docs, it's already well explained. But it all refers to a single requirement with multiple handlers.

My question is about a single policy with multiple requirements, a completely different matter.

Ah, for a policy with multiple requirements all _requirements_ must pass for the policy to pass.

@christiansk would you be able to create a PR to add that information? Use this link to edit in the browser and create the PR.

Yes, glad to help. I just submitted the PR (#10754).

Fixed in #10754

Was this page helpful?
0 / 5 - 0 ratings