Tag: openid connect

OWIN OpenIdConnect中间件IDX10311随机数无法validation

我有一个使用OWIN中间件的应用程序用于OpenIdConnect。 startup.cs文件使用app.UseOpenIdConnectAuthentication的标准实现。 cookie被设置为浏览器,但它出错: IDX10311:RequireNonce为’true’(默认值),但validationContext.Nonce为null。 nonce无法validation。 如果您不需要检查现时,请将OpenIdConnectProtocolValidator.RequireNonce设置为“false”。 我发现当像大多数调试项目一样运行fiddler时,会发生这种情况。 返回错误,但如果我返回该站点,一切正常,我的用户已通过身份validation。 有没有人在运行提琴手时看到这种行为? 随着提琴手: OpenIdConnect中的SecurityTokenValidated通知执行两次。 第二次通过IDX10311后抛出错误 浏览器包含有效的cookie,返回页面我可以查看有效的User.Identity数据。 没有提琴手跑: SecurityTokenValidated在OpenIdConnect中执行一次 没有抛出错误,继续加载控制器操作以进行后validation重定向Uri Cookie也有效且User.Identity数据正确。 想法? 我可以在不运行fiddler的情况下绕过它,但是在调试时也可以运行fiddler来检查流量。

OpenIddict – 如何获取用户的访问令牌?

我正在使用AngularJs为OpenIddict开发示例应用程序。 我被告知你不应该使用像Satellizer这样的客户端框架,因为这不是建议的,而是允许服务器处理服务器端的登录(本地和使用外部登录提供程序),并返回访问令牌。 我有一个演示angularJs应用程序并使用服务器端登录逻辑并回调角度应用程序,但我的问题是,我如何获得当前用户的访问令牌? 这是我的startup.cs文件,所以到目前为止你可以看到我的配置 public void ConfigureServices(IServiceCollection services) { var configuration = new ConfigurationBuilder() .AddJsonFile(“config.json”) .AddEnvironmentVariables() .Build(); services.AddMvc(); services.AddEntityFramework() .AddSqlServer() .AddDbContext(options => options.UseSqlServer(configuration[“Data:DefaultConnection:ConnectionString”])); services.AddIdentity() .AddEntityFrameworkStores() .AddDefaultTokenProviders() .AddOpenIddict(); services.AddTransient(); services.AddTransient(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { env.EnvironmentName = “Development”; var factory = app.ApplicationServices.GetRequiredService(); factory.AddConsole(); factory.AddDebug(); app.UseDeveloperExceptionPage(); app.UseIISPlatformHandler(options => { options.FlowWindowsAuthentication = false; }); app.UseOverrideHeaders(options […]

OpenID Connect – 在WinForms和Web应用程序之间使用IdentityServer进行SSO

我有Thinktecture IdentityServer设置,我有两个可信客户端应用程序,一个WinForms应用程序和一个Web应用程序,我想在它们之间实现SSO。 用户将首先打开桌面应用程序,该应用程序具有通过身份服务器进行身份validation的登录页面。 桌面应用程序将包含一些生成的Web链接,单击这些链接时会打开一个新的浏览器窗口,指向需要身份validation的Web应用程序的安全区域,但是,单击这些链接后,我不希望用户必须再次登录已通过桌面应用程序validation过一次。 我很难看到哪些流程可以实现这一目标。 OpenID connect或Thinktecture IdentityServer提供哪些机制(如果有)可以促进此过程?

:通过IdentityServer3通过LDAPvalidation用户

我需要一种方法来通过IdentityServer3validation组织内的用户(使用LDAP和Active Directory)并授予他们对资源的访问权限。 IdentityServer3似乎是OpenID Connect协议的实现框架,适用于身份validation和授权。 到目前为止,我已经能够使用InMemory实现validation硬编码用户并获得JWT(JSON Web令牌)访问令牌。 请参考这个例子: https://rajdeep.io/2015/05/07/creating-a-single-sign-on-using-thinktecture-identity-server-part-1/ 但是,在我必须validation大型组织中的用户(存储在活动目录中)并发出令牌来访问资源的情况下,这不会非常有用。 以下是我根据此链接所做的工作 ( http://stackoverflow.com/questions/31536420/thinktecture-identityserver-v3-with-windowsauth ): 创建了一个实现IUserService的ActiveDirectoryUserService。 namespace LDAPSSO { public class ActiveDirectoryUserService : IUserService { private const string DOMAIN = “company domain”; public Task AuthenticateExternalAsync(ExternalIdentity externalUser, SignInMessage message) { return Task.FromResult(null); } public Task AuthenticateLocalAsync(string username, string password, SignInMessage message) { try { using (var pc = […]

用于承载令牌认证的Owin中间件,支持JWT密钥轮换

我正在寻找配置owin中间件承载令牌身份validation以支持Open Id Connect密钥轮换的一些指导。 Opend Id Connect规范说明了关于键旋转的以下内容: 可以使用以下方法完成签名密钥的旋转。 签名者在其jwks_uri位置的JWK集中发布其密钥,并在每个消息的JOSE标题中包括签名密钥的孩子,以向validation者指示将使用哪个密钥来validation签名。 可以通过在jwks_uri位置定期向JWK Set添加新密钥来覆盖密钥。 签名者可以自行决定开始使用新密钥,并使用kid值向validation者发出更改信号。 validation者知道返回到jwks_uri位置以在看到不熟悉的孩子值时重新检索密钥。 我在这个主题上可以找到的最相似的问题是: OWIN中的SecurityTokenSignatureKeyNotFoundException连接到Google的OpenID Connect中间件 解决方案不能正常工作,因为在发出新私钥和客户端刷新其公钥缓存之间会出现错误。 因此,我想配置客户端,以便在找到有效的,正确签名的,未过期的JWT令牌时下载丢失的公共JWK密钥,该JWT令牌具有不在本地缓存的孩子。 我目前正在使用IdentityServer3.AccessTokenValidation,但客户端在收到一个无法识别的孩子的令牌时不会下载新密钥。 我快速浏览了一下Microsoft.Owin.Security.Jwt – > UseJwtBearerAuthentication以及Microsoft.Owin.Security.OpenIdConnect – > UseOpenIdConnectAuthentication但我没有太过分。 我正在寻找一些方向来扩展/配置任何上述软件包以支持密钥轮换。

在OwinStartup之后为新租户添加Owin管道中间件

我有一个多租户应用程序,每个租户可以为WsFed或OpenIdConnect定义自己的ClientID,Authority等。 所有租户都在OwinStartup注册如下: public void Configuration(IAppBuilder app) { List WsFedTenantOptions = BuildWsFedTenantOptionsList(); List OpenIdConnectTenantOptions = BuildOpenIdConnectTenantOptionsList(); app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); app.UseCookieAuthentication(new CookieAuthenticationOptions() { CookieSecure = CookieSecureOption.Never }); foreach (var WsFedTenantOption in WsFedTenantOptions) app.UseWsFederationAuthentication(WsFedTenantOption); foreach (var OpenIdConnectTenantOption in OpenIdConnectTenantOptions) app.UseOpenIdConnectAuthentication(OpenIdConnectTenantOption); … } 它通过context.Authentication.Challenge(AuthenticationType)切换要使用的STS。 这工作得很好。 问题是当新租户注册时,如何在没有应用程序池回收的情况下访问IAppBuilder并添加新的AuthenticationOptions ?

一小时后,身份从持有人令牌中消失

我正在使用Azure AD与Web应用程序和Web API建立多租户解决方案。 Web应用程序使用OpenIdConnect来检索承载令牌(在Azure Redis缓存中缓存),该令牌在Angular中用于从Web api获取JSON。 在Web应用程序和Web API(在Azure AD应用程序中设置)之间使用用户模拟。 问题: 这可以正常工作大约一个小时,然后身份突然消失在web api端。 如果我刷新Web应用程序,我会看到该页面被重定向到Microsoft登录页面,但不需要执行任何操作,因为用户只是重定向回Web应用程序并且一切都有效。 据我所知,Web应用程序在失败时使用相同的承载令牌,在再次运行时刷新(相同的过期时间)。 AuthenticationContext.AcquireTokenSilent适用于这两种情况。 我试图增加很多不同的超时,但没有任何帮助。 我还在web api上禁用了除持有者令牌身份validation之外的所有身份validation。 我不明白为什么身份会消失,为什么它有助于刷新客户。 有任何想法吗? 🙂 附加信息 这是RequestContext.Principal.Identity在登录或刷新后大约一小时查找的内容(在web api上): 这是大约一个小时后,导致身份validation失败: 我尝试过的一些代码更改: 在web api HttpConfiguration中: config.SuppressDefaultHostAuthentication(); config.Filters.Add( new HostAuthenticationFilter( new WindowsAzureActiveDirectoryBearerAuthenticationOptions().AuthenticationType)); 这将未经身份validation的主体从WindowsPrincipal更改为ClaimsPrincipal,但在一小时后仍然失败。 WindowsAzureActiveDirectoryBearerAuthenticationOptions BackChannelTimeout set to 5 days. Still fails 在Web应用程序web.config中: sessionState timeout=”525600″ for RedisSessionStateProvider. Still fails 在web应用程序owin auth进程中,增加了时间跨度并增加了滑动到期时间。 仍然失败: app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); […]

在ASP.NET 5中使用声明与OpenIdConnect.Server

在过去的7天里,我尝试使用OpenIdConnect.Server和资源所有者流来设置ASP.NET 5 WebApi。 我在生成令牌和访问[Authorize]受保护的操作方面或多或少成功。 但是,当我尝试访问this.User.Identity.Claims ,它是空的。 我现在使用的是ASP.NET 5,beta6(升级到最近的beta7并等待它正式发布时遇到麻烦) 在Startup.cs中我得到了以下内容: public void ConfigureServices(IServiceCollection services) { services.AddCaching(); services.AddEntityFramework() .AddSqlServer() .AddDbContext(options => { options.UseSqlServer(Configuration.Get(“Data:DefaultConnection:ConnectionString”)); }); services.AddIdentity( options => options.User = new Microsoft.AspNet.Identity.UserOptions { RequireUniqueEmail = true, UserNameValidationRegex = “^[a-zA-Z0-9@_\\.-]+$” }) .AddEntityFrameworkStores() .AddDefaultTokenProviders(); services.ConfigureCors(configure => { configure.AddPolicy(“CorsPolicy”, builder => { builder.WithOrigins(“http:/localhost/”, “http://win2012.bludev.com/”); }); }); services.AddScoped(); } public void Configure(IApplicationBuilder […]

如何从ASP.Net OpenID连接OWIN组件设置声明?

我对使用新的ASP.Net OpenID Connect框架有疑问,同时在身份validation管道中添加新的声明,如下面的代码所示。 我不确定幕后会发生多少’魔术’。 我认为我的大部分问题都集中在不了解OWIN认证中间件而不是OpenID Connect上。 Q1。 我应该从OwinContext.Authentication.User手动设置HttpContext.Current.User和Thread.CurrentPrincipal吗? Q2。 我希望能够像以前一样使用System.IdentityModel.Claims.Claim向对象添加对象类型。 新的System.Security.Claims.Claim类只接受字符串值? Q3。 我是否需要在System.Security.Claims.CurrentPrincipal为我的ClaimsPrincipal使用新的SessionSecurityToken包装器来序列化为cookie – 我正在使用app.UseCookieAuthentication(new CookieAuthenticationOptions()); 但是现在确定在维护我在SecurityTokenValidated事件期间添加的任何其他声明方面究竟做了什么? public void ConfigureAuth(IAppBuilder app) { app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); app.UseCookieAuthentication(new CookieAuthenticationOptions()); app.UseOpenIdConnectAuthentication( new OpenIdConnectAuthenticationOptions { ClientId = clientId, Authority = authority, PostLogoutRedirectUri = postLogoutRedirectUri, Notifications = new OpenIdConnectAuthenticationNotifications() { SecurityTokenValidated = (context) => { // retriever caller data from the incoming […]

OpenIdConnectAuthenticationHandler:message.State为null或为空

我正在使用UseOpenIdConnectAuthentication中间件为ASP.Net Core应用程序对Dells云访问管理器令牌提供程序进行身份validation(设置为提供OpenId / OAuth2身份validation)。 以下是代码: app.UseCookieAuthentication(new CookieAuthenticationOptions { AutomaticAuthenticate = true, AutomaticChallenge = true, AuthenticationScheme = “ClientCookie”, CookieName = CookieAuthenticationDefaults.CookiePrefix + “ClientCookie”, ExpireTimeSpan = TimeSpan.FromMinutes(5), LoginPath = new PathString(“/signin”), LogoutPath = new PathString(“/signout”) }); app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions { RequireHttpsMetadata = false, SaveTokens = true, ClientId = “XYZClient_Id”, ClientSecret = “XYZ_ClientSecret”, ResponseType = OpenIdConnectResponseType.Code, PostLogoutRedirectUri = “https://example.com”, […]