Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取Azure';s ACS页需要被动身份验证_Azure_Single Sign On_Acs - Fatal编程技术网

获取Azure';s ACS页需要被动身份验证

获取Azure';s ACS页需要被动身份验证,azure,single-sign-on,acs,Azure,Single Sign On,Acs,我支持一个集IDP和STS于一体的解决方案。可以将其视为一个MVC应用程序,通过本地存储的配置文件进行简单的身份验证。我想在我的一个页面上放置一个链接,当单击该链接时,它将构建一个SAML有效负载,并通过ACS将其发送到合作伙伴的站点(该站点反过来使用WIF从ACS读取传入的SAML2有效负载)。我不想在旅程中显示另一个登录页面(如ACS的home realm discovery页面),因为当他们单击我的链接时,他们已经通过了身份验证。我只想将声明发送到目的地依赖方url,我想在到达目的地的途中

我支持一个集IDP和STS于一体的解决方案。可以将其视为一个MVC应用程序,通过本地存储的配置文件进行简单的身份验证。我想在我的一个页面上放置一个链接,当单击该链接时,它将构建一个SAML有效负载,并通过ACS将其发送到合作伙伴的站点(该站点反过来使用WIF从ACS读取传入的SAML2有效负载)。我不想在旅程中显示另一个登录页面(如ACS的home realm discovery页面),因为当他们单击我的链接时,他们已经通过了身份验证。我只想将声明发送到目的地依赖方url,我想在到达目的地的途中通过ACS

ACS通过“自定义登录页面”支持类似的功能。您可以下载一个HTML页面,您可能会在IDP上自定义和托管该页面,并让用户在前往依赖方时单击该页面。HTML文件源于一个ACS托管的Javascript文件(IdentityProviders.js),该文件提供一个LoginUrl作为它吸收的JSON参数之一。LoginUrl包含一个wctx参数(看起来是加密的或其他的),我会复制它,然后像这样使用它:

private SignInRequestMessage GetSignInRequestMessage() {
    SignInRequestMessage aMessage = new SignInRequestMessage(new Uri("https://something.accesscontrol.windows.net/"), "http://accesscontrol.windows.net/");
    aMessage.Reply = "http://locohost:65447/Home/SAML";
    aMessage.Realm = "https://something.accesscontrol.windows.net/v2/wsfederation";
    aMessage.Context = THE_WCTX_PARAM_I_GRABBED; 
    return aMessage;
}
最终结果是,我的链接点击将我一直带到依赖方的登录页(
http://locohost:65447/Home/SAML
在本例中),通过允许索赔映射和筛选以及签名和加密支持的ACS

我注意到,当我在相应的依赖方中更改返回URL时,wctx值只发生了轻微的更改。我的猜测是,它包含领域和返回URL,尽管我不明白为什么它需要它,因为我可以通过编程方式提供这些数据位,如上图所示。我的目标是能够以编程方式构建wctx参数,而无需获取神奇字符串或at。有人能提供建议吗

编辑:这是一张概述所需流程的图像。帐户存储在合作伙伴,而不是Azure Active Directory中

这里有更多的伪代码,显示了我如何使用wctx参数将表单post驱动到ACS

public async Task<string> DoACSSAMLPost(List<Claim> aClaimsList, ClaimsPrincipal aPrincipal, string aTokenServiceUrl) {
    // SignInRequestMessage is what is sent to ACS (see code sample above)
    SignInRequestMessage aSignInRequestMessage = await GetSignInRequestMessage();
    // sign request with private key. Public key has been installed in ACS.
    X509SigningCredentials aSigningCredentials = new X509SigningCredentials(theSigningCertificate);
    // configuration allows the token service to sign request and identifies itself as the token service
    SecurityTokenServiceConfiguration aConfig = new SecurityTokenServiceConfiguration(aTokenServiceUrl, aSigningCredentials);
    CustomSecurityTokenService aSecurityTokenService = new CustomSecurityTokenService(aConfig, aClaimsList);
    // Message is generated by the System.IdentityModel plumbing
    SignInResponseMessage aResponseMessage = FederatedPassiveSecurityTokenServiceOperations.ProcessSignInRequest(aSignInRequestMessage, aPrincipal, aSecurityTokenService);
    // and the form post HTML is returned
    return aResponseMessage.WriteFormPost();
}
public异步任务DoACSSAMLPost(列出aclaisList、ClaimsPrincipal aPrincipal、字符串aTokenServiceUrl){
//SignInRequestMessage是发送到ACS的信息(请参见上面的代码示例)
SignInRequestMessage aSignInRequestMessage=等待GetSignInRequestMessage();
//使用私钥签署请求。ACS中已安装公钥。
X509签名凭证作为签名凭证=新的X509签名凭证(签名证书);
//配置允许令牌服务对请求进行签名,并将自身标识为令牌服务
SecurityTokenServiceConfiguration aConfig=新的SecurityTokenServiceConfiguration(AtokeServiceURL,aSigningCredentials);
CustomSecurityTokenService aSecurityTokenService=新的CustomSecurityTokenService(aConfig,aclaisList);
//消息由System.IdentityModel生成
SignInResponseMessage aResponseMessage=FederatedPassiveSecurityTokenServiceOperations.ProcessSignInRequest(aSignInRequestMessage,aPrincipal,AsSecurityTokenService);
//然后返回表单post HTML
返回aResponseMessage.WriteFormPost();
}

我可以从IdentityProvider.js中获取此参数并动态构建此参数,但我想了解a)我的方法是否合理,是否是处理此问题的“正确”方法,以及b)是否有更好的方法获取该wctx参数(或者,如果我不更改ACS中依赖方配置中的返回URL,我可以在本地缓存它。我不确定我是否100%符合意图。您是否试图跳过HRD,以便直接将身份验证发送到所选IdP?如果是这种情况,您可以简单地插入“?whr=issuername”您甚至可以在原始请求中将其发送到RP,并在redirectingtoidentityprovider事件中提取和传递它。 您不需要处理wctx参数,因为它的目标是在各种重定向中保持状态,但这里的目标似乎不是这个。 嗯
V.

更新了原始问题以增加清晰度