在 ASP.NET MVC 应用程序中,我正在尝试针对外部 OIDC 服务实施身份验证。对于我的测试,我使用IdentityServer3 ( https://identityserver.github.io/Documentation/ ) 和公共 OIDC 演示服务器:https ://mitreid.org/
我从 GitHub 克隆了这个示例:https : //github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/MVC%20Authentication
然后添加以下代码将公共 OIDC 服务器注册为外部登录提供程序:
private void ConfigureIdentityProviders(IAppBuilder app, string signInAsType)
{
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "<AuthTypeName>",
Authority = "https://mitreid.org/",
Caption = "MIT Test Server",
ClientId = "<Client Id>",
ClientSecret = "<Client Secret>",
RedirectUri = "https://localhost:44319/", //NOT SURE WHAT TO PUT HERE
ResponseType = "code",
Scope = "openid email profile",
SignInAsAuthenticationType = signInAsType
});
}
Run Code Online (Sandbox Code Playgroud)
代码有效,我可以选择通过外部 OIDC 服务器登录。浏览器重定向到外部服务器登录页面,当输入登录名和密码时,将显示同意页面。但是,在浏览器导航回 …