IDX21323 OpenIdConnectProtocolValidationContext.Nonce was null,...












0















I'm attempting to authenticate for Azure AD and Graph for an Intranet (Based off Orchard CMS), this functions as expected on my local machine, however, when accessing what will be the production site (already set up with ssl on our internal dns), I get the above error at times, it's relatively inconsistent, others in my department while accessing usually get this error.



My Authentication Controller is as follows:



public void LogOn()
{
if (!Request.IsAuthenticated)
{

// Signal OWIN to send an authorization request to Azure.
HttpContext.GetOwinContext().Authentication.Challenge(
new AuthenticationProperties { RedirectUri = "/" },
OpenIdConnectAuthenticationDefaults.AuthenticationType);
}
}

public void LogOff()
{
if (Request.IsAuthenticated)
{
ClaimsPrincipal _currentUser = (System.Web.HttpContext.Current.User as ClaimsPrincipal);

// Get the user's token cache and clear it.
string userObjectId = _currentUser.Claims.First(x => x.Type.Equals(ClaimTypes.NameIdentifier)).Value;

SessionTokenCache tokenCache = new SessionTokenCache(userObjectId, HttpContext);
HttpContext.GetOwinContext().Authentication.SignOut(OpenIdConnectAuthenticationDefaults.AuthenticationType, CookieAuthenticationDefaults.AuthenticationType);
}

SDKHelper.SignOutClient();

HttpContext.GetOwinContext().Authentication.SignOut(
OpenIdConnectAuthenticationDefaults.AuthenticationType, CookieAuthenticationDefaults.AuthenticationType);
}


My openid options are configured as follows:



AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

var openIdOptions = new OpenIdConnectAuthenticationOptions
{
ClientId = Settings.ClientId,
Authority = "https://login.microsoftonline.com/common/v2.0",
PostLogoutRedirectUri = Settings.LogoutRedirectUri,
RedirectUri = Settings.LogoutRedirectUri,
Scope = "openid email profile offline_access " + Settings.Scopes,
TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = false,
},
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthorizationCodeReceived = async (context) =>
{
var claim = ClaimsPrincipal.Current;
var code = context.Code;

string signedInUserID = context.AuthenticationTicket.Identity.FindFirst(ClaimTypes.NameIdentifier).Value;


TokenCache userTokenCache = new SessionTokenCache(signedInUserID,
context.OwinContext.Environment["System.Web.HttpContextBase"] as HttpContextBase).GetMsalCacheInstance();
ConfidentialClientApplication cca = new ConfidentialClientApplication(
Settings.ClientId,
Settings.LogoutRedirectUri,
new ClientCredential(Settings.AppKey),
userTokenCache,
null);


AuthenticationResult result = await cca.AcquireTokenByAuthorizationCodeAsync(code, Settings.SplitScopes.ToArray());
},
AuthenticationFailed = (context) =>
{
context.HandleResponse();
context.Response.Redirect("/Error?message=" + context.Exception.Message);
return Task.FromResult(0);
}
}
};

var cookieOptions = new CookieAuthenticationOptions();
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

app.UseCookieAuthentication(cookieOptions);

app.UseOpenIdConnectAuthentication(openIdOptions);


The url for redirection is kept consistent both at apps.dev.microsoft.com and in our localized web config.










share|improve this question





























    0















    I'm attempting to authenticate for Azure AD and Graph for an Intranet (Based off Orchard CMS), this functions as expected on my local machine, however, when accessing what will be the production site (already set up with ssl on our internal dns), I get the above error at times, it's relatively inconsistent, others in my department while accessing usually get this error.



    My Authentication Controller is as follows:



    public void LogOn()
    {
    if (!Request.IsAuthenticated)
    {

    // Signal OWIN to send an authorization request to Azure.
    HttpContext.GetOwinContext().Authentication.Challenge(
    new AuthenticationProperties { RedirectUri = "/" },
    OpenIdConnectAuthenticationDefaults.AuthenticationType);
    }
    }

    public void LogOff()
    {
    if (Request.IsAuthenticated)
    {
    ClaimsPrincipal _currentUser = (System.Web.HttpContext.Current.User as ClaimsPrincipal);

    // Get the user's token cache and clear it.
    string userObjectId = _currentUser.Claims.First(x => x.Type.Equals(ClaimTypes.NameIdentifier)).Value;

    SessionTokenCache tokenCache = new SessionTokenCache(userObjectId, HttpContext);
    HttpContext.GetOwinContext().Authentication.SignOut(OpenIdConnectAuthenticationDefaults.AuthenticationType, CookieAuthenticationDefaults.AuthenticationType);
    }

    SDKHelper.SignOutClient();

    HttpContext.GetOwinContext().Authentication.SignOut(
    OpenIdConnectAuthenticationDefaults.AuthenticationType, CookieAuthenticationDefaults.AuthenticationType);
    }


    My openid options are configured as follows:



    AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

    var openIdOptions = new OpenIdConnectAuthenticationOptions
    {
    ClientId = Settings.ClientId,
    Authority = "https://login.microsoftonline.com/common/v2.0",
    PostLogoutRedirectUri = Settings.LogoutRedirectUri,
    RedirectUri = Settings.LogoutRedirectUri,
    Scope = "openid email profile offline_access " + Settings.Scopes,
    TokenValidationParameters = new TokenValidationParameters
    {
    ValidateIssuer = false,
    },
    Notifications = new OpenIdConnectAuthenticationNotifications
    {
    AuthorizationCodeReceived = async (context) =>
    {
    var claim = ClaimsPrincipal.Current;
    var code = context.Code;

    string signedInUserID = context.AuthenticationTicket.Identity.FindFirst(ClaimTypes.NameIdentifier).Value;


    TokenCache userTokenCache = new SessionTokenCache(signedInUserID,
    context.OwinContext.Environment["System.Web.HttpContextBase"] as HttpContextBase).GetMsalCacheInstance();
    ConfidentialClientApplication cca = new ConfidentialClientApplication(
    Settings.ClientId,
    Settings.LogoutRedirectUri,
    new ClientCredential(Settings.AppKey),
    userTokenCache,
    null);


    AuthenticationResult result = await cca.AcquireTokenByAuthorizationCodeAsync(code, Settings.SplitScopes.ToArray());
    },
    AuthenticationFailed = (context) =>
    {
    context.HandleResponse();
    context.Response.Redirect("/Error?message=" + context.Exception.Message);
    return Task.FromResult(0);
    }
    }
    };

    var cookieOptions = new CookieAuthenticationOptions();
    app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

    app.UseCookieAuthentication(cookieOptions);

    app.UseOpenIdConnectAuthentication(openIdOptions);


    The url for redirection is kept consistent both at apps.dev.microsoft.com and in our localized web config.










    share|improve this question



























      0












      0








      0








      I'm attempting to authenticate for Azure AD and Graph for an Intranet (Based off Orchard CMS), this functions as expected on my local machine, however, when accessing what will be the production site (already set up with ssl on our internal dns), I get the above error at times, it's relatively inconsistent, others in my department while accessing usually get this error.



      My Authentication Controller is as follows:



      public void LogOn()
      {
      if (!Request.IsAuthenticated)
      {

      // Signal OWIN to send an authorization request to Azure.
      HttpContext.GetOwinContext().Authentication.Challenge(
      new AuthenticationProperties { RedirectUri = "/" },
      OpenIdConnectAuthenticationDefaults.AuthenticationType);
      }
      }

      public void LogOff()
      {
      if (Request.IsAuthenticated)
      {
      ClaimsPrincipal _currentUser = (System.Web.HttpContext.Current.User as ClaimsPrincipal);

      // Get the user's token cache and clear it.
      string userObjectId = _currentUser.Claims.First(x => x.Type.Equals(ClaimTypes.NameIdentifier)).Value;

      SessionTokenCache tokenCache = new SessionTokenCache(userObjectId, HttpContext);
      HttpContext.GetOwinContext().Authentication.SignOut(OpenIdConnectAuthenticationDefaults.AuthenticationType, CookieAuthenticationDefaults.AuthenticationType);
      }

      SDKHelper.SignOutClient();

      HttpContext.GetOwinContext().Authentication.SignOut(
      OpenIdConnectAuthenticationDefaults.AuthenticationType, CookieAuthenticationDefaults.AuthenticationType);
      }


      My openid options are configured as follows:



      AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

      var openIdOptions = new OpenIdConnectAuthenticationOptions
      {
      ClientId = Settings.ClientId,
      Authority = "https://login.microsoftonline.com/common/v2.0",
      PostLogoutRedirectUri = Settings.LogoutRedirectUri,
      RedirectUri = Settings.LogoutRedirectUri,
      Scope = "openid email profile offline_access " + Settings.Scopes,
      TokenValidationParameters = new TokenValidationParameters
      {
      ValidateIssuer = false,
      },
      Notifications = new OpenIdConnectAuthenticationNotifications
      {
      AuthorizationCodeReceived = async (context) =>
      {
      var claim = ClaimsPrincipal.Current;
      var code = context.Code;

      string signedInUserID = context.AuthenticationTicket.Identity.FindFirst(ClaimTypes.NameIdentifier).Value;


      TokenCache userTokenCache = new SessionTokenCache(signedInUserID,
      context.OwinContext.Environment["System.Web.HttpContextBase"] as HttpContextBase).GetMsalCacheInstance();
      ConfidentialClientApplication cca = new ConfidentialClientApplication(
      Settings.ClientId,
      Settings.LogoutRedirectUri,
      new ClientCredential(Settings.AppKey),
      userTokenCache,
      null);


      AuthenticationResult result = await cca.AcquireTokenByAuthorizationCodeAsync(code, Settings.SplitScopes.ToArray());
      },
      AuthenticationFailed = (context) =>
      {
      context.HandleResponse();
      context.Response.Redirect("/Error?message=" + context.Exception.Message);
      return Task.FromResult(0);
      }
      }
      };

      var cookieOptions = new CookieAuthenticationOptions();
      app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

      app.UseCookieAuthentication(cookieOptions);

      app.UseOpenIdConnectAuthentication(openIdOptions);


      The url for redirection is kept consistent both at apps.dev.microsoft.com and in our localized web config.










      share|improve this question
















      I'm attempting to authenticate for Azure AD and Graph for an Intranet (Based off Orchard CMS), this functions as expected on my local machine, however, when accessing what will be the production site (already set up with ssl on our internal dns), I get the above error at times, it's relatively inconsistent, others in my department while accessing usually get this error.



      My Authentication Controller is as follows:



      public void LogOn()
      {
      if (!Request.IsAuthenticated)
      {

      // Signal OWIN to send an authorization request to Azure.
      HttpContext.GetOwinContext().Authentication.Challenge(
      new AuthenticationProperties { RedirectUri = "/" },
      OpenIdConnectAuthenticationDefaults.AuthenticationType);
      }
      }

      public void LogOff()
      {
      if (Request.IsAuthenticated)
      {
      ClaimsPrincipal _currentUser = (System.Web.HttpContext.Current.User as ClaimsPrincipal);

      // Get the user's token cache and clear it.
      string userObjectId = _currentUser.Claims.First(x => x.Type.Equals(ClaimTypes.NameIdentifier)).Value;

      SessionTokenCache tokenCache = new SessionTokenCache(userObjectId, HttpContext);
      HttpContext.GetOwinContext().Authentication.SignOut(OpenIdConnectAuthenticationDefaults.AuthenticationType, CookieAuthenticationDefaults.AuthenticationType);
      }

      SDKHelper.SignOutClient();

      HttpContext.GetOwinContext().Authentication.SignOut(
      OpenIdConnectAuthenticationDefaults.AuthenticationType, CookieAuthenticationDefaults.AuthenticationType);
      }


      My openid options are configured as follows:



      AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

      var openIdOptions = new OpenIdConnectAuthenticationOptions
      {
      ClientId = Settings.ClientId,
      Authority = "https://login.microsoftonline.com/common/v2.0",
      PostLogoutRedirectUri = Settings.LogoutRedirectUri,
      RedirectUri = Settings.LogoutRedirectUri,
      Scope = "openid email profile offline_access " + Settings.Scopes,
      TokenValidationParameters = new TokenValidationParameters
      {
      ValidateIssuer = false,
      },
      Notifications = new OpenIdConnectAuthenticationNotifications
      {
      AuthorizationCodeReceived = async (context) =>
      {
      var claim = ClaimsPrincipal.Current;
      var code = context.Code;

      string signedInUserID = context.AuthenticationTicket.Identity.FindFirst(ClaimTypes.NameIdentifier).Value;


      TokenCache userTokenCache = new SessionTokenCache(signedInUserID,
      context.OwinContext.Environment["System.Web.HttpContextBase"] as HttpContextBase).GetMsalCacheInstance();
      ConfidentialClientApplication cca = new ConfidentialClientApplication(
      Settings.ClientId,
      Settings.LogoutRedirectUri,
      new ClientCredential(Settings.AppKey),
      userTokenCache,
      null);


      AuthenticationResult result = await cca.AcquireTokenByAuthorizationCodeAsync(code, Settings.SplitScopes.ToArray());
      },
      AuthenticationFailed = (context) =>
      {
      context.HandleResponse();
      context.Response.Redirect("/Error?message=" + context.Exception.Message);
      return Task.FromResult(0);
      }
      }
      };

      var cookieOptions = new CookieAuthenticationOptions();
      app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

      app.UseCookieAuthentication(cookieOptions);

      app.UseOpenIdConnectAuthentication(openIdOptions);


      The url for redirection is kept consistent both at apps.dev.microsoft.com and in our localized web config.







      c# azure-active-directory microsoft-graph orchardcms






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 10 at 19:41









      Dmitry

      3,904102730




      3,904102730










      asked Apr 20 '18 at 14:33









      Michael FlanaganMichael Flanagan

      1016




      1016
























          4 Answers
          4






          active

          oldest

          votes


















          1














          How to solve IDX21323



          The problem is solved with this lines of codes, the reason of the error was that ASP.NET don't has the sessión info created yet. The function "authFailed.OwinContext.Authentication.Challenge()" fill the header with the info that needs for the authentication.





                  app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions()
          {
          Notifications = new OpenIdConnectAuthenticationNotifications()
          {
          AuthenticationFailed = AuthenticationFailedNotification<OpenIdConnect.OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> authFailed =>
          {
          if (authFailed.Exception.Message.Contains("IDX21323"))
          {
          authFailed.HandleResponse();
          authFailed.OwinContext.Authentication.Challenge();
          }

          await Task.FromResult(true);
          }
          }
          });





          share|improve this answer





















          • 2





            Please add some explanation of how this code answers the question to improve your answer.

            – Eric Hauenstein
            Jan 3 at 14:19











          • No worries, and welcome to Stack Overflow.

            – Eric Hauenstein
            Jan 29 at 13:48



















          0














          With it being inconsistent, it makes me believe the error you are seeing is caused by what people call "Katana bug #197".



          Luckily, there is a workaround with a nuget package called Kentor.OwinCookieSaver.



          After installing the nuget package add app.UseKentorOwinCookieSaver(); before app.UseCookieAuthentication(cookieOptions);.



          For more info, checkout the Kentor.OwinCookieSaver repo on GitHub.






          share|improve this answer

































            0














            I've got the same error in production environment while locally it worked for all development team. I've tried Kentor.OwinCookieSaver solution suggested by Michael Flanagan but it did not help. After digging a little bit I discovered that authentication itself completed successfully and OwinContext contains user identity and claims, but AuthenticationFailed event handler is raised with IDX21323 exception. So I decided to use the following workaround - I updated AuthenticationFailed event handler:



            // skip IDX21323 exception
            if (context.Exception.Message.Contains("IDX21323"))
            {
            context.SkipToNextMiddleware();
            } else {
            context.HandleResponse();
            context.Response.Redirect("/Error?message=" + context.Exception.Message);
            }
            return Task.FromResult(0);


            This way system will not throw IDX21323 exception but continues auth process and allows users to login and use the system.



            I know this not a solution, but at least users can now login until I find a better way to solve this issue.






            share|improve this answer































              0














              Check the URL mentioned in the AD App Registrations --> Settings --> Reply URL's. if for example that url is https://localhost:44348/



              Go to MVC Project --> Properties (Right Click and Properties) --> Web Section --> Start URL and Project URL should also be https://localhost:44348/



              This has resolved the issue for me. other option is to dynamically set the Redirect URL after AD authentication in Startup.Auth






              share|improve this answer























                Your Answer






                StackExchange.ifUsing("editor", function () {
                StackExchange.using("externalEditor", function () {
                StackExchange.using("snippets", function () {
                StackExchange.snippets.init();
                });
                });
                }, "code-snippets");

                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "1"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49944071%2fidx21323-openidconnectprotocolvalidationcontext-nonce-was-null-openidconnectpro%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                1














                How to solve IDX21323



                The problem is solved with this lines of codes, the reason of the error was that ASP.NET don't has the sessión info created yet. The function "authFailed.OwinContext.Authentication.Challenge()" fill the header with the info that needs for the authentication.





                        app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions()
                {
                Notifications = new OpenIdConnectAuthenticationNotifications()
                {
                AuthenticationFailed = AuthenticationFailedNotification<OpenIdConnect.OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> authFailed =>
                {
                if (authFailed.Exception.Message.Contains("IDX21323"))
                {
                authFailed.HandleResponse();
                authFailed.OwinContext.Authentication.Challenge();
                }

                await Task.FromResult(true);
                }
                }
                });





                share|improve this answer





















                • 2





                  Please add some explanation of how this code answers the question to improve your answer.

                  – Eric Hauenstein
                  Jan 3 at 14:19











                • No worries, and welcome to Stack Overflow.

                  – Eric Hauenstein
                  Jan 29 at 13:48
















                1














                How to solve IDX21323



                The problem is solved with this lines of codes, the reason of the error was that ASP.NET don't has the sessión info created yet. The function "authFailed.OwinContext.Authentication.Challenge()" fill the header with the info that needs for the authentication.





                        app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions()
                {
                Notifications = new OpenIdConnectAuthenticationNotifications()
                {
                AuthenticationFailed = AuthenticationFailedNotification<OpenIdConnect.OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> authFailed =>
                {
                if (authFailed.Exception.Message.Contains("IDX21323"))
                {
                authFailed.HandleResponse();
                authFailed.OwinContext.Authentication.Challenge();
                }

                await Task.FromResult(true);
                }
                }
                });





                share|improve this answer





















                • 2





                  Please add some explanation of how this code answers the question to improve your answer.

                  – Eric Hauenstein
                  Jan 3 at 14:19











                • No worries, and welcome to Stack Overflow.

                  – Eric Hauenstein
                  Jan 29 at 13:48














                1












                1








                1







                How to solve IDX21323



                The problem is solved with this lines of codes, the reason of the error was that ASP.NET don't has the sessión info created yet. The function "authFailed.OwinContext.Authentication.Challenge()" fill the header with the info that needs for the authentication.





                        app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions()
                {
                Notifications = new OpenIdConnectAuthenticationNotifications()
                {
                AuthenticationFailed = AuthenticationFailedNotification<OpenIdConnect.OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> authFailed =>
                {
                if (authFailed.Exception.Message.Contains("IDX21323"))
                {
                authFailed.HandleResponse();
                authFailed.OwinContext.Authentication.Challenge();
                }

                await Task.FromResult(true);
                }
                }
                });





                share|improve this answer















                How to solve IDX21323



                The problem is solved with this lines of codes, the reason of the error was that ASP.NET don't has the sessión info created yet. The function "authFailed.OwinContext.Authentication.Challenge()" fill the header with the info that needs for the authentication.





                        app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions()
                {
                Notifications = new OpenIdConnectAuthenticationNotifications()
                {
                AuthenticationFailed = AuthenticationFailedNotification<OpenIdConnect.OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> authFailed =>
                {
                if (authFailed.Exception.Message.Contains("IDX21323"))
                {
                authFailed.HandleResponse();
                authFailed.OwinContext.Authentication.Challenge();
                }

                await Task.FromResult(true);
                }
                }
                });






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 31 at 11:01

























                answered Jan 3 at 10:02









                Adrià Martínez LópezAdrià Martínez López

                135




                135








                • 2





                  Please add some explanation of how this code answers the question to improve your answer.

                  – Eric Hauenstein
                  Jan 3 at 14:19











                • No worries, and welcome to Stack Overflow.

                  – Eric Hauenstein
                  Jan 29 at 13:48














                • 2





                  Please add some explanation of how this code answers the question to improve your answer.

                  – Eric Hauenstein
                  Jan 3 at 14:19











                • No worries, and welcome to Stack Overflow.

                  – Eric Hauenstein
                  Jan 29 at 13:48








                2




                2





                Please add some explanation of how this code answers the question to improve your answer.

                – Eric Hauenstein
                Jan 3 at 14:19





                Please add some explanation of how this code answers the question to improve your answer.

                – Eric Hauenstein
                Jan 3 at 14:19













                No worries, and welcome to Stack Overflow.

                – Eric Hauenstein
                Jan 29 at 13:48





                No worries, and welcome to Stack Overflow.

                – Eric Hauenstein
                Jan 29 at 13:48













                0














                With it being inconsistent, it makes me believe the error you are seeing is caused by what people call "Katana bug #197".



                Luckily, there is a workaround with a nuget package called Kentor.OwinCookieSaver.



                After installing the nuget package add app.UseKentorOwinCookieSaver(); before app.UseCookieAuthentication(cookieOptions);.



                For more info, checkout the Kentor.OwinCookieSaver repo on GitHub.






                share|improve this answer






























                  0














                  With it being inconsistent, it makes me believe the error you are seeing is caused by what people call "Katana bug #197".



                  Luckily, there is a workaround with a nuget package called Kentor.OwinCookieSaver.



                  After installing the nuget package add app.UseKentorOwinCookieSaver(); before app.UseCookieAuthentication(cookieOptions);.



                  For more info, checkout the Kentor.OwinCookieSaver repo on GitHub.






                  share|improve this answer




























                    0












                    0








                    0







                    With it being inconsistent, it makes me believe the error you are seeing is caused by what people call "Katana bug #197".



                    Luckily, there is a workaround with a nuget package called Kentor.OwinCookieSaver.



                    After installing the nuget package add app.UseKentorOwinCookieSaver(); before app.UseCookieAuthentication(cookieOptions);.



                    For more info, checkout the Kentor.OwinCookieSaver repo on GitHub.






                    share|improve this answer















                    With it being inconsistent, it makes me believe the error you are seeing is caused by what people call "Katana bug #197".



                    Luckily, there is a workaround with a nuget package called Kentor.OwinCookieSaver.



                    After installing the nuget package add app.UseKentorOwinCookieSaver(); before app.UseCookieAuthentication(cookieOptions);.



                    For more info, checkout the Kentor.OwinCookieSaver repo on GitHub.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited May 11 '18 at 19:03

























                    answered May 11 '18 at 18:05









                    David OuwingaDavid Ouwinga

                    1377




                    1377























                        0














                        I've got the same error in production environment while locally it worked for all development team. I've tried Kentor.OwinCookieSaver solution suggested by Michael Flanagan but it did not help. After digging a little bit I discovered that authentication itself completed successfully and OwinContext contains user identity and claims, but AuthenticationFailed event handler is raised with IDX21323 exception. So I decided to use the following workaround - I updated AuthenticationFailed event handler:



                        // skip IDX21323 exception
                        if (context.Exception.Message.Contains("IDX21323"))
                        {
                        context.SkipToNextMiddleware();
                        } else {
                        context.HandleResponse();
                        context.Response.Redirect("/Error?message=" + context.Exception.Message);
                        }
                        return Task.FromResult(0);


                        This way system will not throw IDX21323 exception but continues auth process and allows users to login and use the system.



                        I know this not a solution, but at least users can now login until I find a better way to solve this issue.






                        share|improve this answer




























                          0














                          I've got the same error in production environment while locally it worked for all development team. I've tried Kentor.OwinCookieSaver solution suggested by Michael Flanagan but it did not help. After digging a little bit I discovered that authentication itself completed successfully and OwinContext contains user identity and claims, but AuthenticationFailed event handler is raised with IDX21323 exception. So I decided to use the following workaround - I updated AuthenticationFailed event handler:



                          // skip IDX21323 exception
                          if (context.Exception.Message.Contains("IDX21323"))
                          {
                          context.SkipToNextMiddleware();
                          } else {
                          context.HandleResponse();
                          context.Response.Redirect("/Error?message=" + context.Exception.Message);
                          }
                          return Task.FromResult(0);


                          This way system will not throw IDX21323 exception but continues auth process and allows users to login and use the system.



                          I know this not a solution, but at least users can now login until I find a better way to solve this issue.






                          share|improve this answer


























                            0












                            0








                            0







                            I've got the same error in production environment while locally it worked for all development team. I've tried Kentor.OwinCookieSaver solution suggested by Michael Flanagan but it did not help. After digging a little bit I discovered that authentication itself completed successfully and OwinContext contains user identity and claims, but AuthenticationFailed event handler is raised with IDX21323 exception. So I decided to use the following workaround - I updated AuthenticationFailed event handler:



                            // skip IDX21323 exception
                            if (context.Exception.Message.Contains("IDX21323"))
                            {
                            context.SkipToNextMiddleware();
                            } else {
                            context.HandleResponse();
                            context.Response.Redirect("/Error?message=" + context.Exception.Message);
                            }
                            return Task.FromResult(0);


                            This way system will not throw IDX21323 exception but continues auth process and allows users to login and use the system.



                            I know this not a solution, but at least users can now login until I find a better way to solve this issue.






                            share|improve this answer













                            I've got the same error in production environment while locally it worked for all development team. I've tried Kentor.OwinCookieSaver solution suggested by Michael Flanagan but it did not help. After digging a little bit I discovered that authentication itself completed successfully and OwinContext contains user identity and claims, but AuthenticationFailed event handler is raised with IDX21323 exception. So I decided to use the following workaround - I updated AuthenticationFailed event handler:



                            // skip IDX21323 exception
                            if (context.Exception.Message.Contains("IDX21323"))
                            {
                            context.SkipToNextMiddleware();
                            } else {
                            context.HandleResponse();
                            context.Response.Redirect("/Error?message=" + context.Exception.Message);
                            }
                            return Task.FromResult(0);


                            This way system will not throw IDX21323 exception but continues auth process and allows users to login and use the system.



                            I know this not a solution, but at least users can now login until I find a better way to solve this issue.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jul 2 '18 at 8:38









                            KeymaticKeymatic

                            16114




                            16114























                                0














                                Check the URL mentioned in the AD App Registrations --> Settings --> Reply URL's. if for example that url is https://localhost:44348/



                                Go to MVC Project --> Properties (Right Click and Properties) --> Web Section --> Start URL and Project URL should also be https://localhost:44348/



                                This has resolved the issue for me. other option is to dynamically set the Redirect URL after AD authentication in Startup.Auth






                                share|improve this answer




























                                  0














                                  Check the URL mentioned in the AD App Registrations --> Settings --> Reply URL's. if for example that url is https://localhost:44348/



                                  Go to MVC Project --> Properties (Right Click and Properties) --> Web Section --> Start URL and Project URL should also be https://localhost:44348/



                                  This has resolved the issue for me. other option is to dynamically set the Redirect URL after AD authentication in Startup.Auth






                                  share|improve this answer


























                                    0












                                    0








                                    0







                                    Check the URL mentioned in the AD App Registrations --> Settings --> Reply URL's. if for example that url is https://localhost:44348/



                                    Go to MVC Project --> Properties (Right Click and Properties) --> Web Section --> Start URL and Project URL should also be https://localhost:44348/



                                    This has resolved the issue for me. other option is to dynamically set the Redirect URL after AD authentication in Startup.Auth






                                    share|improve this answer













                                    Check the URL mentioned in the AD App Registrations --> Settings --> Reply URL's. if for example that url is https://localhost:44348/



                                    Go to MVC Project --> Properties (Right Click and Properties) --> Web Section --> Start URL and Project URL should also be https://localhost:44348/



                                    This has resolved the issue for me. other option is to dynamically set the Redirect URL after AD authentication in Startup.Auth







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Oct 24 '18 at 11:14









                                    Narasimha Rao DattappaNarasimha Rao Dattappa

                                    345




                                    345






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Stack Overflow!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49944071%2fidx21323-openidconnectprotocolvalidationcontext-nonce-was-null-openidconnectpro%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Monofisismo

                                        Angular Downloading a file using contenturl with Basic Authentication

                                        Olmecas