Jump to content

ASP.NET 4.6 OpenID Connect 404 Problem


damien113

Recommended Posts

I am having a really hard time getting OpenIDConnect to work properly with this asp.net 4.6 mvc 5 project. Recently I was getting a 404 error and ended up adding a custom route to the callback action to get it to work past that. AFter that I started getting a error about GetExternalLoginInfoAsync() returning null and getting a nullreferenceexception. This is what my config looks like with some things redacted, along with the routing. Also the image provided is one of the errors I get,if i dont use custom routing i just get a 404 error. If anyone has a sample project connecting to WHMCS with OpenID Connect in C# with Owin, let me know.

OpenIdConnect nonce cookie is there, along with session ID, also in the URL it is sending the state and the code which is below.

    https://localhost:44348/signin-oidc/?code=e33dab0ae5e9640ef731c460180780092703727b&state=OpenIdConnect.AuthenticationProperties%3D-JlLC-VdZi-KZst8OY4JikRrl59vm19HATAcOaqUv8a22U8ch9gC_IJARHlsvaDKZQrqfeTewtdk5d-KcZSrUR3qCoJVcmzNRDP8C0JJ2NH9ql42J3H1xkxEzoAvJ0wxITy-tCj5H-N-bYhMZbO4kB8s2S4msCF0kEDzgipoPmGfZfreUeyYcerwK_OJGH3uYKUYa1NjqA0G-hlhiYpUj8DUp59EXpDz6sr1wtohTiI

 

enter image description here

 

 

Code

 var json = "";
            using (WebClient wc = new WebClient())
            {
                json = wc.DownloadString("http://orders.data443.com/oauth/openid-configuration.php");
            }

            var settings = new OpenIdConnectAuthenticationOptions
            {
                Authority = "https://orders.data443.com/oauth/",
                ClientId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                RedirectUri = "https://localhost:44348/signin-oidc/",
                CallbackPath = new PathString("/signin-oidc/"),
                Configuration = new OpenIdConnectConfiguration(json),
                ResponseType = OpenIdConnectResponseType.Code,
                SignInAsAuthenticationType = "Cookies",
                TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer = false,
                },
                Scope = "openid email profile"
            };
            app.UseOpenIdConnectAuthentication(settings);


Routing    

routes.MapRoute(
            name: "signin-oidc",
            url: "signin-oidc",
            defaults: new { controller = "Account", action = "ExternalLoginCallback" });


  [1]: https://i.stack.imgur.com/ZT4aT.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated