AzureFunctions.Extensions.OpenIDConnect icon indicating copy to clipboard operation
AzureFunctions.Extensions.OpenIDConnect copied to clipboard

Make FunctionContext the resource that is passed into IAuthorizationService

Open MaxGuernseyIII opened this issue 2 years ago • 2 comments

I would like to make the executing function context be the resource passed to the authorization service and, therefore, to the handlers.

I tried to create a pull request for this but I don't generally contribute to open source projects and gave up when I was denied the ability to create a new branch.

I could not find a "how to contribute" section in the documentation.

The change is nigh unto trivial. In the test AuthorizationFunctionMiddlewareShould, (currently line 97):

        var authorizationService = Substitute.For<IAuthorizationService>();
        var context = Substitute.For<FunctionContext>();
        authorizationService.AuthorizeAsync(Arg.Any<ClaimsPrincipal>(), context, requirements)
            .Returns(AuthorizationResult.Failed());

In AuthorizationFunctionMiddleware, (currently line 60):

                    var authorizationResult = await _authorizationService.AuthorizeAsync(authenticationResult.User, executingContext, requirements);

In AuthorizationFilter, (currently line 52):

                    var authorizationResult = await _authorizationService.AuthorizeAsync(httpContext.User, executingContext, requirements);

I could not locate the tests for AuthorizationFilter.

I would gladly submit this as a PR but, as an open source noob, I'm afraid I don't know how to do that with this project.

MaxGuernseyIII avatar Jul 19 '23 16:07 MaxGuernseyIII

I figured out how to make a pull request. I had to create a fork for it, which feels weird but maybe that was right. Here is the link to the pull request.

https://github.com/fmichellonet/AzureFunctions.Extensions.OpenIDConnect/pull/28

MaxGuernseyIII avatar Jul 20 '23 13:07 MaxGuernseyIII

Has anyone had a chance to look at this?

MaxGuernseyIII avatar Jul 27 '23 16:07 MaxGuernseyIII