Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Per-Route authentication is causing RouteExecutionEarlyExitException

I'm quite new to Nancy and am now experimenting with Auth. Looking forward to fully implement Forms authentication.

For testing purposes, I have 3 modules set up.

Other module:

public class OtherModule : NancyModule
{
    public OtherModule() : base()
    {
        // Use global, module level authentication.
        this.RequiresAuthentication();

        Get["/other"] = _ =>
        {
            return "Other";
        };

        Get["/woot"] = _ =>
        {
            return "Woot";
        };
    }
}

Main module:

public class MainModule : NancyModule
{
    public MainModule() : base()
    {
        Get["/yolo"] = _ =>
        {
            // Use per-route authentication.
            this.RequiresAuthentication();

            return "#YOLO";
        };
    }
}

AuthModule:

public class AuthModule : NancyModule
{
    public AuthModule() : base()
    {
        Get["/login"] = _ =>
        {
            return "To proceed, you must authenticate. [show form]";
        };
    }
}

Now, when I navigate to /other and/or /woot, I am redirected to /login - as expected. Though, when I navigate to /yolo, the application throws an Nancy.ErrorHandling.RouteExecutionEarlyExitException, where I assumed it should redirect me to /login?returnUrl=seeme.

I have walked through the github forms auth source, which features the behavior in this file. I cannot seem to find any major differences (my Bootstrapper, my IUserMapper, my IUserIdentity).

Is my use wrong here? Should I try/catch it and prepare responses accordingly? Is it a bug?

I'm running NancyFX in a self-hosted environment (Nancy.Hosting.Self), no ASP and no OWIN.

like image 338
tomsseisums Avatar asked Jul 03 '14 14:07

tomsseisums


1 Answers

False alert, false alert.

It was my Visual Studio debugger, who just reported about the exception.

Of course, as usual, I pushed "Break" and the app went down. Pressing "Continue" instead, did redirect me to the correct page.

like image 92
tomsseisums Avatar answered Sep 21 '22 17:09

tomsseisums