如何与Identity Server ASP.NET应用程序和OWIN共享会话cookie?

时间:2015-06-02 14:11:50

标签: cookies owin thinktecture-ident-server machinekey

我正在使用Identity Server v2和SessionAuthenticationModule。

我想添加一个新的OWIN应用程序(在IIS中托管),它可以共享相同的会话cookie" idsrvauth "与我现有的STS。

我该怎么做?

  1. SessionAuthenticationModule可以解密会话cookie并在OWIN应用程序中设置IPrincipal吗?
  2. 或者我应该使用OWIN中间件来做到这一点?是否有现有的中间件或我需要写新的?
  3. 我在每个web.config中都有相同的 machineKey 但是在访问OWIN网站时,我收到了一个CryptographicException:

    CryptographicException: Error occurred during a cryptographic operation.
     System.Web.Security.Cryptography.HomogenizingCryptoServiceWrapper.HomogenizeErrors(Func`2 func, Byte[] input) +246
     System.IdentityModel.Services.MachineKeyTransform.Decode(Byte[] encoded) +200
     System.IdentityModel.Tokens.SessionSecurityTokenHandler.ApplyTransforms(Byte[] cookie, Boolean outbound) +173
     System.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver) +752
     System.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(Byte[] token, SecurityTokenResolver tokenResolver) +99
     System.IdentityModel.Services.SessionAuthenticationModule.ReadSessionTokenFromCookie(Byte[] sessionCookie) +1233
     System.IdentityModel.Services.SessionAuthenticationModule.TryReadSessionTokenFromCookie(SessionSecurityToken& sessionToken) +314
     System.IdentityModel.Services.SessionAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs eventArgs) +243
     System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
    

0 个答案:

没有答案