标签: wif

如何使用对称密钥配置MIcrosoft JWT?

我正在尝试将我的ASP.NET应用程序配置为接受使用对称密钥签名的JSON Web令牌(JWT).STS无法使用证书,所以我们使用它们的对称密钥支持.

在我的结尾,我正在使用微软的JWT开发者预览版.不幸的是,我没有看到任何关于如何使用对称密钥的示例.在使用各种工具进行一些挖掘后,我发现NamedKeyIssuerTokenResolver并发现我可以将其配置为使用对称密钥.例如:

<securityTokenHandlers>
  <add type="Microsoft.IdentityModel.Tokens.JWT.JWTSecurityTokenHandler,Microsoft.IdentityModel.Tokens.JWT" />
  <securityTokenHandlerConfiguration>
    <certificateValidation certificateValidationMode="PeerTrust" />
    <issuerTokenResolver
      type="Microsoft.IdentityModel.Tokens.JWT.NamedKeyIssuerTokenResolver,
        Microsoft.IdentityModel.Tokens.JWT">
      <securityKey
          symmetricKey="+zqf97FD/xyzzyplugh42ploverFeeFieFoeFooxqjE="
             name="https://localhost/TestRelyingParty" />
    </issuerTokenResolver>
  </securityTokenHandlerConfiguration>
</securityTokenHandlers>
Run Code Online (Sandbox Code Playgroud)

我不完全确定我应该在name那里使用什么.应该是观众Uri,也许是发行人Uri?无论如何,我知道如果我不包含a name,我的程序启动时会出现异常,因为该securityKey元素需要该属性.

无论如何,这仍然无法解决问题.在我对STS进行身份验证后,我得到以下异常:

[SecurityTokenValidationException: JWT10310: Unable to validate signature. validationParameters.SigningTokenResolver type: 'Microsoft.IdentityModel.Tokens.JWT.NamedKeyIssuerTokenResolver', was unable to resolve key to a token.
The SecurityKeyIdentifier is: 
'SecurityKeyIdentifier
    (
    IsReadOnly = False,
    Count = 1,
    Clause[0] = Microsoft.IdentityModel.Tokens.JWT.NamedKeyIdentifierClause
    )
'. validationParameters.SigningToken was null.]
   Microsoft.IdentityModel.Tokens.JWT.JWTSecurityTokenHandler.ValidateSignature(JWTSecurityToken jwt, TokenValidationParameters validationParameters) +2111
   Microsoft.IdentityModel.Tokens.JWT.JWTSecurityTokenHandler.ValidateToken(JWTSecurityToken jwt, TokenValidationParameters validationParameters) …
Run Code Online (Sandbox Code Playgroud)

.net wif jwt

17
推荐指数
3
解决办法
3万
查看次数

将基于声明的授权添加到MVC 3

我有一个MVC应用程序,我想添加基于声明的授权.在不久的将来,我们将使用ADFS2进行联合身份验证,但现在我们将在本地使用表单身份验证.

有没有人看过关于在没有外部身份提供者的情况下使用WIF的最佳方式的教程或博客文章?

我见过以下但现在已经有一年了,我认为应该有一个更简单的解决方案:

http://geekswithblogs.net/shahed/archive/2010/02/05/137795.aspx

asp.net-mvc claims-based-identity wif asp.net-mvc-3

16
推荐指数
1
解决办法
1万
查看次数

从客户端检测到一个潜在危险的Request.Form值(wresult ="<trust:RequestSecuri ...")

使用WIF时,我也收到了请求验证错误.我被正确地发送到STS,但在回来的路上,我得到了这个验证错误.

我遵循了所有指示.

<httpRuntime  requestValidationMode="2.0" />
Run Code Online (Sandbox Code Playgroud)

校验!

    [ValidateInput(false)]
Run Code Online (Sandbox Code Playgroud)

校验!

<pages validateRequest="false" >
Run Code Online (Sandbox Code Playgroud)

校验!

我尝试了一个自定义验证器,但它永远不会被实例化.

错误堆栈:

[HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (wresult="trust:RequestSecuri...").]
   System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection) +11396740
   System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, RequestValidationSource requestCollection) +82
   System.Web.HttpRequest.get_Form() +212
   Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.IsSignInResponse(HttpRequest request) +26
   Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.CanReadSignInResponse(HttpRequest request, Boolean onPage) +145
   Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs args) +108
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +270
Run Code Online (Sandbox Code Playgroud)

有什么建议?

wif single-sign-on asp.net-mvc-3

16
推荐指数
1
解决办法
2万
查看次数

什么是.NET 4.5等同于UserNameWSTrustBinding?

我正在将活动配置文件STS转换为新的.NET 4.5 System.IdentityModel框架.我的代码使用UserNameWSTrustBinding,它似乎不存在于新框架中.有什么建议.

wif .net-4.5

16
推荐指数
1
解决办法
3917
查看次数

我在哪里可以找到Microsoft.IdentityModel.Extensions.dll库?

我正在寻找Microsoft.IdentityModel.Extensions图书馆.在我正在阅读的文档中,他们建议它应该在我的GAC中提供,但事实并非如此.我正在使用Visual Studio 2012.

我在哪里可以找到它?

c# sharepoint wif asp.net-mvc-4

16
推荐指数
1
解决办法
3万
查看次数

如何访问WIF 4.5中的SecurityTokenHandlers集合?

我正在迁移一个使用Active Federation和WIF 3.5的ASP.Net站点来使用.Net 4.5.Windows Identity Foundation(WIF 3.5)的功能现已完全集成到.Net 4.5 Framework中.

由于类已移至三个不同的名称空间,因此主要是机械翻译问题.我遇到问题的部分是将GenericXmlSecurityTokenSTS发布的部分翻译成索赔委托人SessionAuthenticationModule.WriteSessionTokenToCookie.文档缺乏,我只需要找到WIF 4.5访问方式FederatedAuthentication.ServiceConfiguration.SecurityTokenHandlers

以下是无法在WIF 4.5中编译的WIF 3.5代码片段(为简洁起见省略了WSTrust通道创建):

var genericToken = channel.Issue(rst) as GenericXmlSecurityToken;

var handlers = FederatedAuthentication.ServiceConfiguration.SecurityTokenHandlers;

var token = handlers.ReadToken(new XmlTextReader(new StringReader(genericToken.TokenXml.OuterXml)));
var identity = handlers.ValidateToken(token).First();

var sessionToken = new SessionSecurityToken(ClaimsPrincipal.CreateFromIdentity(identity),
                                            TimeSpan.FromMinutes(20));

FederatedAuthentication.SessionAuthenticationModule.WriteSessionTokenToCookie(sessionToken);
Run Code Online (Sandbox Code Playgroud)

.net wif .net-4.5

15
推荐指数
1
解决办法
3958
查看次数

除IMEI,Android_ID,WLAN Mac和蓝牙地址外,设备的完美unique_id

目的:

我正在寻找一种方法来找到Android设备的unique_id.

背景:

我将在登录请求有效负载中使用Id,因为我的应用程序是基于许可证的服务应用程序,Id在正常情况下不应更改.

现有方法:

在iOS中,有一些针对iOS的唯一ID解决方案,例如CFUUID或者identifierForVendor,以及Keychain,广告标识符等,可以完成预期的工作.

但在Android中,我所知道的所有选项似乎都有漏洞.

IMEI:

TelephonyManager TelephonyMgr = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); 
String m_deviceId = TelephonyMgr.getDeviceId();
Run Code Online (Sandbox Code Playgroud)

缺点

这是依赖SIM卡的

  • 如果没有SIM卡那么我们就注定了

  • 如果有双卡,那么我们就会陷入困境

Android_ID:

  String m_androidId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
Run Code Online (Sandbox Code Playgroud)

缺点

  • 如果OS版本升级,则可能会更改
  • 如果设备已植根,则会更改
  • 不能保证device_id是唯一的,有些报告称某些制造商有重复的device_id

WLAN MAC地址

WifiManager m_wm = (WifiManager)getSystemService(Context.WIFI_SERVICE); 
String m_wlanMacAdd = m_wm.getConnectionInfo().getMacAddress();
Run Code Online (Sandbox Code Playgroud)

缺点

  • 如果没有wifi硬件那么我们就注定了
  • 在一些新设备中,如果关闭wifi,那么我们注定要失败.

蓝牙地址:

   BluetoothAdapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); 
   String m_bluetoothAdd = m_BluetoothAdapter.getAddress();
Run Code Online (Sandbox Code Playgroud)

缺点:

  • 如果没有蓝牙硬件我们就注定了.
  • 在将来的某些新设备中,如果它关闭,我们可能无法读取它.

可能的解决方案:

我认为有两种方法可以解决这个问题

  • 我们通过哈希时间戳生成一个随机ID,我用上面提到的唯一ID并存储它,以便下次登录时我们将检查key的存储值是否为null,如果是,那么我们将生成并存储它我们' ll使用密钥的值.

    如果有相当于iOS的钥匙串的东西,那么我们对这种方法很好.

  • 找到类似于iOS的advertisingIdentifier的全局标识符,该标识符对于设备中的所有应用程序都是相同的.

任何帮助表示赞赏!

android mac-address bluetooth uniqueidentifier wif

14
推荐指数
1
解决办法
6234
查看次数

使用多个ADFS从外部应用程序登录时,Asp.Net应用程序的SSO的最佳方法

我有一个已经构建的Asp.Net应用程序,它使用Asp.Net成员资格提供程序.

有一个客户端Web应用程序,它有自己的登录名.登录后,用户会获得一些链接.这些链接针对我开发的应用程序.目前,由于这是两个域中托管的两个不同的应用程序,因此需要两次登录.

我想要实现的是拥有SSO,而不必在用户已登录客户端应用程序时登录.我已经通读了,似乎可以通过像ThinkTecture IdentityServer这样的STS提供商完成这项工作,并在我们的最后使用ADFS.

这是最好的方法,如果是的话,我找不到很多关于我需要从主应用程序团队要求启用SSO的更新的文档.

asp.net federated-identity claims-based-identity wif single-sign-on

14
推荐指数
1
解决办法
1219
查看次数

创建自定义声明类型的最佳做法

给定一组特定的权限,例如EditPage,CreateProject,ModifyUser,我目前正在研究创建一些自定义声明类型的两种不同方法来模拟此行为.我可以在网上找到关于最佳方法的小信息,并希望得到一些关于如何在自己的系统中完成此操作的反馈.

我考虑的第一种方法是使用"操作"声明类型,其中特定操作由声明的值指定:

var claims = new [] 
{
    new Claim("http://schemas.company.com/claims/project/action", "EditPage"),
    new Claim("http://schemas.company.com/claims/project/action", "CreateProject"),
    new Claim("http://schemas.company.com/claims/project/action", "ModifyUser")
}
Run Code Online (Sandbox Code Playgroud)

第二种方法是使用声明类型本身来定义正在执行的操作,不使用该值.这就像"PossessProperty"安全风格,只要用户具有声明类型,他们就可以执行操作.

var claims = new [] 
{
    new Claim("http://schemas.company.com/claims/project/editpage", ""),
    new Claim("http://schemas.company.com/claims/project/createproject", ""),
    new Claim("http://schemas.company.com/claims/project/modifyuser", "")
}
Run Code Online (Sandbox Code Playgroud)

另请注意,在上面的索赔类型中,我包含了一个"项目"鉴别器,以便我可以区分可以编辑项目A中的页面而不是项目B的用户.

我们还计划将所有这些自定义声明存储在中央"授权"数据库中,因此需要唯一性.

任何想法或反馈将不胜感激.

permissions claims-based-identity claims wif

13
推荐指数
1
解决办法
4097
查看次数

WIF安全令牌缓存

我有一个网站是我们基于WIF的自定义STS的依赖方.我们最近实现了一个安全令牌缓存,如下所述:Azure/web-farm ready SecurityTokenCache.我们的实现与该链接中描述的实现之间的主要区别在于,我们使用Azure AppFabric缓存作为持久缓存的后备存储,而不是表存储.这有助于减轻我们在某些浏览器上的令牌截断问题,但引入了一个新问题(我们看到截断问题主要是在除了fedauth cookie之外还有谷歌分析+防伪cookie的页面上).我们现在每天收到几千次以下异常:

System.IdentityModel.Tokens.SecurityTokenException
ID4243: Could not create a SecurityToken. A token was not found in the token cache and no cookie was found in the context.

System.IdentityModel.Tokens.SecurityTokenException: ID4243: Could not create a       SecurityToken. A token was not found in the token cache and no cookie was found in the context.
   at Microsoft.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver)
   at Microsoft.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(Byte[] token, SecurityTokenResolver tokenResolver)
   at Microsoft.IdentityModel.Web.SessionAuthenticationModule.ReadSessionTokenFromCookie(Byte[] sessionCookie)
   at Microsoft.IdentityModel.Web.SessionAuthenticationModule.TryReadSessionTokenFromCookie(SessionSecurityToken& sessionToken)
   at Microsoft.IdentityModel.Web.SessionAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs eventArgs)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep …
Run Code Online (Sandbox Code Playgroud)

wif

12
推荐指数
2
解决办法
9357
查看次数