0

是否可以进行第一次身份验证登录到网站并进行第二次身份验证以将令牌保存到数据库中以供使用,即使通过第一次身份验证登录,我也有 2 个 openIdConnectionAuthentications 如下

app.UseOpenIdConnectAuthentication(CompanyOption1())

app.UseOpenIdConnectAuthentication(CompanyOption2())

Private Function CompanyOption1() As OpenIdConnectAuthenticationOptions
        clientId = ConfigurationManager.AppSettings("ida:ClientId")
        aadInstance = EnsureTrailingSlash(ConfigurationManager.AppSettings("ida:AADInstance"))
        tenantId = ConfigurationManager.AppSettings("ida:TenantId")
        postLogoutRedirectUri = ConfigurationManager.AppSettings("ida:PostLogoutRedirectUri")
        RedirectUri = ConfigurationManager.AppSettings("ida:RedirectUri")
        authority = aadInstance
        Return New OpenIdConnectAuthenticationOptions("CompanyOption1") With {
              .ClientId = clientId,
            .Authority = authority,
            .RedirectUri = RedirectUri,
            .SaveTokens = True,
            .RedeemCode = True,
            .PostLogoutRedirectUri = postLogoutRedirectUri,
            .Scope = OpenIdConnectScope.OpenIdProfile,
            .ResponseType = OpenIdConnectResponseType.IdToken,
            .TokenValidationParameters = New TokenValidationParameters() With {
            .ValidateIssuer = False
            },
            .Notifications = New OpenIdConnectAuthenticationNotifications With {
            .AuthenticationFailed = AddressOf OnAuthenticationFailed
            }
            }

    End Function
    Private Function CompanyOption2() As OpenIdConnectAuthenticationOptions
        clientId = ConfigurationManager.AppSettings("ppl:ClientId")
        aadInstance = EnsureTrailingSlash(ConfigurationManager.AppSettings("ppl:CallbackPath"))
        tenantId = ConfigurationManager.AppSettings("ppl:TenantId")
        postLogoutRedirectUri = ConfigurationManager.AppSettings("ida:PostLogoutRedirectUri")
        RedirectUri = ConfigurationManager.AppSettings("ida:RedirectUri")
        ClientSecret = ConfigurationManager.AppSettings("ppl:ClientSecret")
        authority = aadInstance

        Return New OpenIdConnectAuthenticationOptions("CompanyOption2") With {
             .ClientId = clientId,
            .Authority = authority,
            .RedirectUri = RedirectUri,
             .ClientSecret = ClientSecret,
            .SaveTokens = True,
            .RedeemCode = True,
            .PostLogoutRedirectUri = postLogoutRedirectUri,
            .Scope = OpenIdConnectScope.OpenIdProfile,
            .ResponseType = OpenIdConnectResponseType.IdToken,
            .TokenValidationParameters = New TokenValidationParameters() With {
            .ValidateIssuer = False
            },
            .Notifications = New OpenIdConnectAuthenticationNotifications With {
            .AuthenticationFailed = AddressOf OnAuthenticationFailed
            }
            }

    End Function

当我打电话给第二家公司时,它什么也没做。任何帮助表示赞赏

Context.GetOwinContext().Authentication.Challenge(New AuthenticationProperties With {
    .RedirectUri = webAuth
}, "CompanyOption2")
 
4

0 回答 0