Security icon indicating copy to clipboard operation
Security copied to clipboard

Consider changing AuthorizationHandler.Handle from void to return a result

Open lfoust opened this issue 11 years ago • 1 comments

The current signature of AuthorizationHandler.Handle is:

public void Handle(AuthorizationContext context)

and to implement this method, you are expected to call either context.Succeed or context.Fail to indicate the result of the AuthorizationHandler. This feels like a very awkward API and allows for people to implement Handle without ever signaling a result.

A much clearer approach would be to make the Handle method return a result either as a boolean:

public bool Handle(AuthorizationContext context)

or as a result object:

public AuthorizationResult Handle(AuthorizationContext context)

This would allow for developers who are implementing their own requirements to fall into the pit of success when signaling authorization results.

For reference, the change (by @HaoK) where this was added is: SHA: 775eb5ec

lfoust avatar Aug 11 '15 21:08 lfoust

This was considered and the reasoning was basically that we wanted to allow handlers that did nothing potentially. The current design gives full control to the handlers as they are called with every requirement, and they don't necessarily handle every requirement. But they are always given the option.

HaoK avatar Aug 11 '15 22:08 HaoK