2

I read this and this, and to the best of my understanding this did not help me solve my problem.

Code Snippets

    public void ConfigureAuth(IAppBuilder app)
    {
        app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);


        app.UseCookieAuthentication(new CookieAuthenticationOptions());


        var options = new OpenIdConnectAuthenticationOptions
        {
            // These are standard OpenID Connect parameters, with values pulled from web.config 
            ClientId = clientId,
            RedirectUri = redirectUri,
            PostLogoutRedirectUri = redirectUri,
            Notifications = new OpenIdConnectAuthenticationNotifications
            {
                AuthenticationFailed = OnAuthenticationFailed,
                RedirectToIdentityProvider = OnRedirectToIdentityProvider,
                AuthorizationCodeReceived = OnAuthorizationCodeReceived,
                SecurityTokenValidated = OnSecurityTokenValidated
            },
            Scope = "openid offline_access",
            ResponseType = "code id_token",


            // The PolicyConfigurationManager takes care of getting the correct Azure AD authentication 
            // endpoints from the OpenID Connect metadata endpoint.  It is included in the PolicyAuthHelpers folder. 
            ConfigurationManager = new PolicyConfigurationManager(
                string.Format(CultureInfo.InvariantCulture, aadInstance, tenant, "/v2.0", OIDCMetadataSuffix),
                new[] { GlobalSignInPolicyId, GlobalResetPasswordPolicyId }),


            // This piece is optional - it is used for displaying the user's name in the navigation bar. 
            TokenValidationParameters = new TokenValidationParameters
            {
                NameClaimType = "name",
                SaveSigninToken = true
            }
        };

        app.UseOpenIdConnectAuthentication(options);

    }

The following method does not fire

    private async Task OnAuthorizationCodeReceived(AuthorizationCodeReceivedNotification notification)
    {

        notification.AuthenticationTicket.Identity.AddClaim(new Claim("code", notification.Code));
    }

The OnRedirectToIdentityProvider does fire.

We are using Framework 4.6.2 - Microsoft.Owin version 3.0.1.0

The strange thing is I took the code from another project (call it Project A) that works, but my project (call it Project B) doesn't. If I give Project A my credentials OnAuthorizationCodeReceived does still fire. If I take Project A's credentials and put them in Project B OnAuthorizationCodeReceived does not fire. So I think I can rule out a configuration issue.

One key piece I may have left out, Project A is a MVC project and Project B is a Asp.net WebForms project

Mike
  • 5,918
  • 9
  • 57
  • 94

0 Answers0