asp.net-mvc – thinktecture identityserver v3
发布时间:2020-05-24 15:26:33 所属栏目:asp.Net 来源:互联网
导读:尝试使用Thinctecture identityserver v3作为多个mvc应用程序的简单sts. 我能够遍历所提供的示例应用程序并且运行正常,但它们都使用嵌入式身份服务器.我需要将identityserver作为一个单独的应用程序,以便我可以将它用作多个应用程序的sts.当我尝试运行身份服
|
尝试使用Thinctecture identityserver v3作为多个mvc应用程序的简单sts.
示例mvc应用程序使用武士刀 app.USEOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions... 但我只是不明白如何正确配置外部应用服务. 这是我的依赖方配置为mvc. 在mvc应用程序中,每当我尝试导航到需要授权的视图时,我都会得到异常. 堆栈跟踪: [HttpRequestException: Response status code does not indicate success: 404 (Not Found).] System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode() +87960 Microsoft.IdentityModel.Protocols.<GetDocumentAsync>d__0.MoveNext() +496 [IOException: Unable to get document from: https://localhost:44333/.well-known/openid-configuration] Microsoft.IdentityModel.Protocols.<GetDocumentAsync>d__0.MoveNext() +830 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +24 Microsoft.IdentityModel.Protocols.<GetAsync>d__0.MoveNext() +512 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +24 Microsoft.IdentityModel.Protocols.<GetConfigurationAsync>d__3.MoveNext() +1332 这是mvc应用程序中的完整身份验证配置. app.USEOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
//Authority = "https://localhost:44319/identity",Authority = "https://localhost:44333",ClientId = "mvc",Scope = "openid profile roles",RedirectUri = "https://localhost:44319/",SignInAsAuthenticationType = "Cookies",UseTokenLifetime = false,Notifications = new OpenIdConnectAuthenticationNotifications
{
SecurityTokenValidated = async n =>
{
var id = n.AuthenticationTicket.Identity;
// we want to keep first name,last name,subject and roles
var givenName = id.FindFirst(Constants.ClaimTypes.GivenName);
var familyName = id.FindFirst(Constants.ClaimTypes.FamilyName);
var sub = id.FindFirst(Constants.ClaimTypes.Subject);
var roles = id.FindAll(Constants.ClaimTypes.Role);
// create new identity and set name and role claim type
var nid = new ClaimsIdentity(
id.AuthenticationType,Constants.ClaimTypes.GivenName,Constants.ClaimTypes.Role);
nid.AddClaim(givenName);
nid.AddClaim(familyName);
nid.AddClaim(sub);
nid.AddClaims(roles);
// keep the id_token for logout
nid.AddClaim(new Claim("id_token",n.ProtocolMessage.IdToken));
// add some other app specific claim
nid.AddClaim(new Claim("app_specific","some data"));
n.AuthenticationTicket = new AuthenticationTicket(
nid,n.AuthenticationTicket.Properties);
},RedirectToIdentityProvider = async n =>
{
if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.LogoutRequest)
{
var idTokenHint = n.OwinContext.Authentication.User.FindFirst("id_token");
if (idTokenHint != null)
{
n.ProtocolMessage.IdTokenHint = idTokenHint.Value;
}
}
}
}
});
解决方法您的端点最后缺少/ identity(编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – SignalR Autofac OWIN:为什么GlobalHost.Conne
- asp.net – 编辑条目时的实体框架DateTime格式
- 是否有可能在asp经典和asp.net之间共享会话状态
- ASP.NET – 从客户端访问两次网页
- asp.net-mvc – 在MVC2中使用区域
- .net – App_LocalResources如何使用MVC?
- 如何保护我的ASP.NET AJAX应用程序?
- asp.net-mvc – ASP.NET MVC泛型基础视图类
- 如何在page_Load函数中设置的asp.net中显示变量值
- asp.net – 如何在生产.NET网站中更改Web引用?
推荐文章
站长推荐
- asp.net-mvc – MVC导航到不同的控制器视图
- asp.net中的泛型处理程序是什么?
- asp.net-mvc – 在asp .net mvc 5中显示外部网页
- asp.net 删除项目文件/文件夹IIS重启,Session丢
- entity-framework – ASP.NET-Identity限制UserN
- 使用ASP.NET和C#在DropDownList中选择多个值
- asp.net-mvc-3 – ASP.NET MVC 3书籍计划
- asp.net-mvc – 解耦Microsoft.AspNet.Identity.
- asp.net-mvc – 如何使用ASP.NET MVC实现自定义缓
- asp.net-core – 使用[FromBody]时获取原始POST数
热点阅读
