WCF FederatedAuthentication 会话状态与 ClaimsAuthorizationManager 混淆
上下文:
Stack 和 Bing 上有一些讨论WCF 和与 ASP.NET 的会话共享。没有一个能完全满足我的问题。所以这里是:
我有一个 MVC 站点,它在 RouteTable 位于路径“/services”下。这一切都非常好用。我可以调用控制器操作和 WCF 服务方法。
我已启用 WIF 和 联合身份验证 与 Windows Azure 访问控制服务 (ACS)。这也很好用。我可以使用 Facebook、Google 等登录,并且在我的网站上明确建立了会话。我可以调用 MVC 控制器操作和 WCF 方法。在这些正文中,当前用户的 IPrincipal 设置为我当前的会话。
现在我想成为一个好孩子并使用自定义 ClaimsAuthenticationManager 和自定义 ClaimsAuthorizationManager。现在出现了一个奇怪的问题:
设置:
对于这种情况,我已登录。我有一个会话。我可以在 MVC 控制器方法和 WCF 服务方法的方法体内确认这一点。这意味着我们可以将自定义的 ClaimsAuthenticationManager 排除在外,因为当我已经有一个会话时它不会被触及。
这是自定义的 ClaimsAuthorizationManager 导致我头痛。
当我调用 MVC 站点时,我在 ClaimsAuthorizationManager.CheckAccess 方法内部以及 MVC 控制器操作主体内部的会话中进行身份验证。到目前为止,一切都很好。
问题:
当我调用 WCF 服务时,我没有通过 ClaimsAuthorizationManager.CheckAccess 方法内的会话进行身份验证,但当我在 WCF 服务内遇到断点时,我(突然)通过了身份验证方法。
这根本没有任何意义!看起来我的会话并没有在 ClaimsAuthorization 管理器内部膨胀,但是当我点击我自己的 WCF 代码时,会话就就位了!
怎么会这样呢?
干杯,
马格努斯
Context:
There are a few threads here on Stack and on Bing that talk about WCF and session sharing with ASP.NET. None satisfy my issue fully. So here goes:
I have an MVC site which also has a few services in the RouteTable under the path "/services". This all works really nice. I can call Controller actions and WCF service methods both.
I have enabled WIF and Federated Authentication with the Windows Azure Access Control Service (ACS). This also works nicely. I can login using Facebook, Google etc. and a session is clearly established on my site. I can call the MVC controller actions and the WCF methods. Inside the body of those the IPrincipal for the current user is set to my current session.
Now I want to be a good boy and use a custom ClaimsAuthenticationManager and a custom ClaimsAuthorizationManager. A weird problem now occurs:
The setup:
For this scenario I am logged in. I have a session. I can confirm this inside of the method bodies of my MVC controller methods and my WCF service methods. This means we can leave the custom ClaimsAuthenticationManager out of this since it is not being touched when I already have a session.
It's the custom ClaimsAuthorizationManager which causes my headache.
When I make a call to the MVC site I am authenticated with my session inside of the ClaimsAuthorizationManager.CheckAccess method AND also inside of the body of my MVC controller actions. So far so good.
The problem:
When I make a call to the WCF services I am NOT authenticated with my session inside of the ClaimsAuthorizationManager.CheckAccess method but I am authenticated (suddenly) as I hit my breakpoint inside of the WCF service method.
This just does not make any sense! It seems my session is not inflated inside of the ClaimsAuthorization manager but further down the pipeline when I hit my own WCF code the session is in place!
How can this be?
Cheers,
Magnus
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是 Stackoverflow 的问题,但是当我将您的配置复制到记事本 ++ 中时,我在 AuthenticationManager 类型值中看到了一些垃圾字符:
至于问题的其余部分,您在此处显示的元素之前是否有
元素?It might be the Stackoverflow's problem, but when I copied your config into notepad++ I saw some junk characters in the AuthenticationManager type value:.
As the rest of the question goes, do you have
<clear />
element before the elements that you show here?