Giter Club home page Giter Club logo

Comments (6)

mathewbergt avatar mathewbergt commented on July 26, 2024

Nevermind, I seem to have resolved this issue. I was setting my CookieAuthenticationOptions like so:

new CookieAuthenticationOptions()
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/account/login"),
    Provider = new CookieAuthenticationProvider()
    {
        OnApplyRedirect = ctx =>
        {
            if (!ctx.Request.IsNtlmAuthenticationCallback())
            {
                ctx.Response.Redirect(ctx.RedirectUri);
            }
        }
    }
}

The problem seemed to be specifying the LoginPath. When I removed this option, everything worked correctly. Perhaps it's a cross-origin type issue related to specifying the CallbackPath PathString with the virtual directory (i.e. /<appname>/authentication/ntlm-signin), whereas the LoginPath did not contain the virtual directory (i.e. /account/login).

from pysco68.owin.authentication.ntlm.

mathewbergt avatar mathewbergt commented on July 26, 2024

A follow up on this issue and how I actually ended up resolving it... Since I specified a CallbackPath in the NtlmAuthenticationOptions I also needed to call IsNtlmAuthenticationCallback with the redirectPath overload in the following manner:

OnApplyRedirect = ctx =>
{
    if (!ctx.Request.IsNtlmAuthenticationCallback(CallbackPath))
    {
        ctx.Response.Redirect(ctx.RedirectUri);
    }
}

If CallbackPath is not specified then IsNtlmAuthenticationCallback makes the comparison using the NtlmAuthenticationOptions.DefaultRedirectPath (/authentication/ntlm-signin), which does not work for an app under a virtual directory (/<virtual_directory>/authentication/ntlm-signin).

This could be a helpful tip to add to the documentation for those running apps under virtual directories.

from pysco68.owin.authentication.ntlm.

pysco68 avatar pysco68 commented on July 26, 2024

It sure would be helpful, I'll try to take care of this asap!

Thank you very much for the follow-up!

from pysco68.owin.authentication.ntlm.

pysco68 avatar pysco68 commented on July 26, 2024

Added note: 901c8c7

from pysco68.owin.authentication.ntlm.

los93sol avatar los93sol commented on July 26, 2024

I'm having this same issue, but when I drop LoginPath from UseCookieAuthentication then it doesn't attempt to log the user in.

from pysco68.owin.authentication.ntlm.

los93sol avatar los93sol commented on July 26, 2024

Finally figured out how to do this and it should work dynamically....

    public void Configuration(IAppBuilder app)
    {
        var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);

        app.SetDefaultSignInAsAuthenticationType(DefaultAuthenticationTypes.ApplicationCookie);

        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Login"),
            Provider = new CookieAuthenticationProvider()
            {
                OnApplyRedirect = ctx =>
                {
                    if (!ctx.Request.IsNtlmAuthenticationCallback(new PathString(urlHelper.Action("authentication", "ntlm-signin"))))
                    {
                        ctx.Response.Redirect(ctx.RedirectUri);
                    }
                }
            }
        });

        app.UseNtlmAuthentication(new NtlmAuthenticationOptions()
        {
            CallbackPath = new PathString(urlHelper.Action("authentication", "ntlm-signin"))
        });
    }

from pysco68.owin.authentication.ntlm.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.