ASP.net IdentiyServer 3 AuthorizationCode收到未触发

时间:2019-01-31 17:51:28

标签: asp.net openid identityserver3

当用户通过Identity Server 3进行身份验证时,AuthorizationCodeReceived永远不会触发。 RedirectToIdentityProvider确实被解雇了,仅此而已。我试图调用一个函数,该函数将获取用户的电子邮件或Windows ID,然后添加自定义声明。但是,如果没有调用AuthorizationCodeReceived方法,我不确定该怎么做。有人对此有经验吗?不确定是否重要,但是我的代码是ASP.net Windows窗体(不是MVC)

这是我的代码:

    Public Sub ConfigureAuth(app As IAppBuilder)
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
        JwtSecurityTokenHandler.DefaultInboundClaimTypeMap = New Dictionary(Of String, String)


        app.UseCookieAuthentication(New CookieAuthenticationOptions() With {
            .AuthenticationType = CookieAuthenticationDefaults.AuthenticationType
        })

        Dim OpenIdAuthOption = New OpenIdConnectAuthenticationOptions() With {
           .Authority = "https://myidentityserver.azurewebsites.net/core/",
           .ClientId = "adfafasfasdfa",
           .RedirectUri = "https://localhost:44321/default.aspx/",
           .ResponseType = ("access_token"),
           .RequireHttpsMetadata = False,
           .SignInAsAuthenticationType = "Cookies",
           .Notifications = New OpenIdConnectAuthenticationNotifications() With {

                .AuthorizationCodeReceived = Function(ctx)
                                                 Dim claimPrincipal As ClaimsPrincipal = ctx.AuthenticationTicket.Identity.Claims
                                                 TransformClaims(claimPrincipal)
                                                 Return Task.FromResult(0)
                                             End Function,
                .RedirectToIdentityProvider = Function(context)
                                                  RedirectLogin(context)
                                                  Return Task.FromResult(0)
                                              End Function
                }
        }
        app.UseOpenIdConnectAuthentication(OpenIdAuthOption)
    End Sub

0 个答案:

没有答案