我的问题是关于Identity Server 4和从已有的.NET框架MVC应用程序调用它。
我已经按照ID4的“快速入门”指南进行操作,使其可运行并正确响应示例.NET Core MVC应用程序。
作为一个快速测试,我创建了一个基本的.NET Framework MVC应用程序,并创建了一个启动.cs文件...
在ID4配置中,我创建了一个客户端以匹配...
应用程序将通过登录和权限页面进行进度,最终ID4指示用户已登录....
我已经按照ID4的“快速入门”指南进行操作,使其可运行并正确响应示例.NET Core MVC应用程序。
作为一个快速测试,我创建了一个基本的.NET Framework MVC应用程序,并创建了一个启动.cs文件...
using Microsoft.Owin;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.OpenIdConnect;
using Owin;
using System.Collections.Generic;
using System.IdentityModel.Tokens;
[assembly: OwinStartup(typeof(MVC_OWIN_Client.Startup))]
namespace MVC_OWIN_Client
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
string baseClientAddress = "http://localhost:44301/";
var authority = JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
ClientId = "mvc.standard",
Authority = "http://localhost:5000/",
RedirectUri = baseClientAddress + "signin-oidc",
PostLogoutRedirectUri = baseClientAddress + "signout-callback-oidc",
ResponseType = "code id_token",
Scope = "openid api1 offline_access",
UseTokenLifetime = false,
SignInAsAuthenticationType = "Cookies"
});
}
}
}
在ID4配置中,我创建了一个客户端以匹配...
public static IEnumerable<Client> GetClients()
{
...
new Client
{
ClientId = "mvc.standard",
ClientName = "MVC Client2",
AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,
ClientSecrets =
{
new Secret("secret".Sha256())
},
RedirectUris = { "http://localhost:44301/signin-oidc" },
PostLogoutRedirectUris = { "http://localhost:44301/signout-callback-oidc" },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"api1"
},
AllowOfflineAccess = true
}
};
应用程序将通过登录和权限页面进行进度,最终ID4指示用户已登录....
info: IdentityServer4.ResponseHandling.AuthorizeInteractionResponseGenerator[0]
User consented to scopes: openid, api1, offline_access
info: IdentityServer4.Endpoints.AuthorizeCallbackEndpoint[0]
Authorize endpoint response
{
"SubjectId": "2",
"ClientId": "mvc.standard",
"RedirectUri": "http://localhost:44301/signin-oidc",
"State": "OpenIdConnect.AuthenticationProperties=pnxKmthLCWSNS1Tj8sBS1K4K-Erxq8_W3Sfj1gg3zXhTCqP-gKV-Hsfgh_pRLPYQcIdVJONhzA3VMdBNv4xqE7y8uX-pzEmeNKBYb0cPAh6Q9lm5knIS5ds9gccYKubK1U0NpnGAW7tw38brRzD7dEG-EkSgXqjnEGeS4pMCrFaG2CFwq08_-KyA85VufscpT3y9sL0hTLLYYbRiJhWIZBOM427piwaHpR-jbl7KXGo",
"Scope": "openid api1 offline_access"
}
info: Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler[10]
AuthenticationScheme: idsrv signed in.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 152.1613ms 200 text/html; charset=UTF-8
就是这样。MVC应用程序从未被恢复,它一直存在直到超时。
有没有人有Identity Server的经验并能告诉我是否有遗漏的内容?提前感谢您的时间,Andy。