Tag: identityserver3

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来检查流量。

更新System.IdentityModel.Tokens.Jwt导致IdentityServer3客户端发生重大更改

希望很容易解决。 微软的System.IdentityModels.Tokens.Jwt软件包昨天在NuGet上从4.0.2.206211351更新到v5.0 。 遗憾的是,这会导致一些“标准” IdentityServer3代码发生重大变化。 即从他们的代码示例中提取,所以我想很多开发人员可能会在未来几天看到这个问题。 原始代码 使用v4.0.2.xxxxxx版本的软件包。 我有 using System.IdentityModel.Tokens; 在命名空间中。 然后在Configuration方法中开始如下: public void Configuration(IAppBuilder app) { AntiForgeryConfig.UniqueClaimTypeIdentifier = “sub”; JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary(); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = “Cookies” }); app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions { … }; 更新后 更新配置行后: JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary(); 造成问题。 第一件事是,Class显然已经移入System.IdentityModel.Tokens.Jwt命名空间,这个解决起来并不是那么糟糕。 但是,我现在正在获取JwtSecurityTokenHandler.InboundClaimTypeMap上的Object reference required for a non-static field错误Object reference required for […]

身份服务器4令牌未在使用Identity Server 3的.NetFramework Api中validation

在我的身份服务器应用程序中使用idsv4并在端口“5000”上运行有一个客户端 new Client { ClientId = “client”, // no interactive user, use the clientid/secret for authentication AllowedGrantTypes = GrantTypes.ClientCredentials, // secret for authentication ClientSecrets = { new Secret(“secret”.Sha256()) }, // scopes that client has access to AllowedScopes = { “api1” } }` 在我的.Net Framework Api的启动类中使用端口号“7001”: app.UseIdentityServerBearerTokenAuthentication( new IdentityServerBearerTokenAuthenticationOptions { Authority = “http://localhost:5000”, ValidationMode = ValidationMode.ValidationEndpoint, […]

:通过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 = […]

处理Identity Server客户端凭据流时在自签名客户端证书中出现问题

我使用MakeCert.exe为我的内部开发目的创建了自签名证书 步骤1 :我使用以下命令创建了根CA. makecert -n “CN=Bala root signing authority” -cy authority -r -sv root.pvk root.cer 步骤2 :使用以下命令安装在步骤#1中创建的根CA证书 certutil -user -addstore Root root.cer 步骤3 :我使用以下命令创建了客户端证书 makecert -pe -n “CN=Bala Client” -a sha1 -cy end ^ -sky signature ^ -ic root.cer -iv root1.pvk ^ -sv Bala.pvk Bala.cer 步骤#4 :我使用以下命令为相应的客户端证书创建了一个.pfx文件 pvk2pfx -pvk Bala.pvk -spc Bala.cer -pfx Bala.pfx 根CA即“CN […]

如何从经过身份validation的SecurityToken中获取声明

我将一个标记作为字符串传递给SOAP服务,并validation该标记是有效的。 我现在有一个SecurityToken,在调试模式下我可以看到所有声明,特别是userId声明我想要传递给另一个方法。 我似乎无法弄清楚如何获得索赔。 现在我解码了令牌的字符串版本(令牌的无validation字符串版本,我至少等到成功validation后。)这是代码块: SecurityToken validatedToken = null; if (VerifyToken(sPassword, ref response, ref validatedToken)) { var claimsObj = JObject.Parse(Encoding.UTF8.GetString(Base64Url.Decode(claims))); JToken userId = claimsObj.GetValue(“userId”); return implClass.Process(userId); } 如何从SecurityToken中获取声明? validatedToken.Id; // not it validatedToken.ToClaimsPrincipal(cert); // doesn’t work 对于暴露的属性,我没有其他任何东西看起来很有希望,但是因为我可以在调试器中看到声明,我确信有一种方法我只是没有看到。

如何向身份服务器本身发出访问令牌?

这可能是一个愚蠢的问题,但在这里:) 我在这个问题上有以下应用程序: IdentityServer3 WebApi2应用程序,它使用Identityserver作为其身份validation器 MVC网络应用程序 我想要做的是从IdentityServer调用WebApi上的安全服务,但为了做到这一点,我需要一个访问令牌。 我如何在IdentityServer中向自己发出访问令牌(按顺序将通过WebApi自身进行身份validation)

用于用户管理的Identity Server和web api

我正在为我的项目使用Identity Server3,我目前有一个网站和api受Id服务器保护,这工作正常但是因为我将用户存储在Id Server数据库中我无法真正更改任何用户的数据从网站上更改个人资料图片或任何索赔值。 为了解决这个问题,我正在考虑在IdServer之上创建API,这个API将管理用户,更改密码,检索用户或更改与用户相关的任何内容,我想在示例项目上创建此API我有我的IdServer使用Owin映射。 现在我在/身份路线中有我的idServer public class Startup { public void Configuration(IAppBuilder app) { Log.Logger = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.Trace().CreateLogger(); app.Map(“/identity”, idserverApp => { var efConfig = new EntityFrameworkServiceOptions { ConnectionString = “IdSvr3Config” }; var options = new IdentityServerOptions { SiteName = “Identity server”, IssuerUri = ConfigurationManager.AppSettings[“idserver:stsIssuerUri”], PublicOrigin = ConfigurationManager.AppSettings[“idserver:stsOrigen”], SigningCertificate = Certificate.Get(), Factory = Factory.Configure(efConfig), AuthenticationOptions […]

如何在使用IdentityServer进行身份validation后获取WebAPI控制器上的用户信息?

在我的客户端应用程序成功validationIdentityServer3后,我无法在WebAPI控制器上获取用户信息。 以下是步骤: 从JavaScript Implicit Client应用程序成功登录“使用配置文件和访问令牌” 我在“ID令牌内容”面板上看到用户的数据 我对我的WebAPI服务进行“呼叫服务”,我在ClaimsPrincipal中看到了许多声明,但无法获取客户端显示的电子邮件,角色等值。 以下是代码和回复。 任何人都可以帮我提供一些如何在WebAPI上获取用户数据的帮助吗?

转换方法以使用异步

我正在转换身份validation过程以支持异步,VS 2015 IDE警告我以下消息: async方法缺少’await’运算符并将同步运行…等… 无论如何,代码连接到LDAP商店并validation用户的帐户等…我已经尝试了各种各样的东西等待,但我只是在这里遗漏了一些东西。 我把代码恢复到以前的状态..我将非常感谢能够正确支持异步的任何指导… 这是代码: public async Task GetAsyncADUser(PrincipalContextParameter param) { try { if (UseLDAPForIdentityServer3) { using (var pc = new PrincipalContext(ContextType.Domain, param.ADDomain, param.ADServerContainer, param.ADServerUser, param.ADServerUserPwd)) { UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(pc, param.UserNameToValidate); if (userPrincipal != null) { bool isvalid = pc.ValidateCredentials(userPrincipal.DistinguishedName, param.UserPasswordToValidate, ContextOptions.SimpleBind); if (isvalid) { User user = new User { ad_guid […]