简体   繁体   English

如何在MVC应用程序上访问ACS令牌?

[英]How to access the ACS token on mvc application?

I am using Access Control Service (ACS). 我正在使用访问控制服务(ACS)。 I configure my MVC-4 application to use ACS. 我将MVC-4应用程序配置为使用ACS。 I put the return url to my controller, which is http://127.0.0.1:81/ACS/LogOn and after logon with any identity provider we are successfully return to the controller. 我将返回URL放置到我的控制器上,即http://127.0.0.1:81/ACS/LogOn并且在使用任何身份提供程序登录后,我们都已成功返回到控制器。 But now can anybody please tell me how i can access the issued token in the controller ? 但是现在有人可以告诉我如何在控制器中访问已发行的令牌吗?

Assuming that you've used the normal WIF-based mechanisms to configure your app to use ACS, everything you need should be accessible via Thread.CurrentPrincipal. 假设您已使用基于WIF的常规机制来配置您的应用程序以使用ACS,那么您需要的所有内容都应该可以通过Thread.CurrentPrincipal访问。 In most cases, you don't want the token itself but instead you want the claims within it. 在大多数情况下,您不希望令牌本身,而是希望其中包含声明。 See this example . 请参阅此示例

If you actually need the underlying token in XML/string form rather than the claims (I wouldn't recommend this most of the time) then you can get it by setting SaveBoostrapContext in your service configuration to true and accessing it via the BootstrapContext property on the claims identity. 如果您实际上需要XML /字符串形式的基础令牌而不是声明(我通常不建议这样做),那么可以通过将服务配置中的SaveBoostrapContext设置为true并通过BootstrapContext属性访问它来获取它。索赔身份。

Thread.CurrentPrincipal.Identity.BootstrapContext;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM