Skip to content
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

TokenValidator not being used #144

Open
cocowalla opened this issue Mar 16, 2020 · 1 comment
Open

TokenValidator not being used #144

cocowalla opened this issue Mar 16, 2020 · 1 comment

Comments

@cocowalla
Copy link

cocowalla commented Mar 16, 2020

I've got Function Monkey working without authorization, but now I want to add it.

My IFunctionHostBuilder builder is pretty spartan, and looks like this:

builder
    .Setup((services, commands) =>
    {
        services.AddLogging();
        commands.Register<MyCommandHandler>();
    })
    .Authorization(authorization => authorization
        .AuthorizationDefault(AuthorizationTypeEnum.TokenValidation)
        .TokenValidator<NulloValidator>()
    )
    .Functions(functions => functions
        .HttpRoute("Stuff", route => route
            .HttpFunction<MyCommand>()
        )
    );

NulloValidator is simply:

public class NulloValidator : ITokenValidator
{
    public NulloValidator()
    {

    }

    public Task<ClaimsPrincipal> ValidateAsync(string authorizationHeader)
    {
        throw new NotImplementedException();
    }
}

When I run it, locally or in Azure, calls return an empty 401 response. If I set breakpoints in NulloValidator, they are not hit (same with the command handler, so requests are no longer getting that far).

I don't see any logs at all related to Function Monkey, or why this is happening. Do you have any idea how this might happen, or how I can try to diagnose things, maybe see some logs etc?

Thanks!

@cocowalla
Copy link
Author

I tried downloading the Function Monkey source and stepping through, but haven't really got anywhere.

Not sure if there is a prerequisite that I'm missing, but all tests in FunctionMonkey.Tests.Integration are also failing for me:

FunctionMonkey.Commanding.Abstractions.Validation.ValidationResult Validate(System.Object) is not a GenericMethodDefinition. MakeGenericMethod may only be called on a method for which MethodBase.IsGenericMethodDefinition is true.
   at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
   at FunctionMonkey.Testing.ValidatingDispatcher.Validate(ICommand command) in C:\MyProject\src\3rdParty\Source\FunctionMonkey.Testing\ValidatingDispatcher.cs:line 55
   at FunctionMonkey.Testing.ValidatingDispatcher.DispatchAsync[TResult](ICommand`1 command, CancellationToken cancellationToken) in C:\MyProject\src\3rdParty\Source\FunctionMonkey.Testing\ValidatingDispatcher.cs:line 24
   at FunctionMonkey.Testing.Implementation.HttpDispatcher.DispatchAndConvertToActionResult[TResult](ICommand`1 command, IHttpResponseHandler httpResponseHandler, HttpFunctionDefinition httpFunctionDefinition) in C:\MyProject\src\3rdParty\Source\FunctionMonkey.Testing\Implementation\HttpDispatcher.cs:line 34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant