Gob*_*ins 0 java http azure opensaml saml-2.0
我想向我的IDP(Azure AD)发送SAML请求,但是我不确定如何发送请求。
首先,我使用OpenSAML来构建AuthRequest。我将其编码为字符串。
现在,我想使用ApacheHttpClient发送请求并读取响应,而且我不确定OpenSAML是否提供了HTTP发送方法,因此我的想法是暂时使用Apaches HttpClient。
String encodedAuthRequest = generateAuthRequest();
String url = "http://myidp/samlendpoint";
CloseableHttpClient client = HttpClientBuilder.create().build();
HttpGet request = new HttpGet(url);
// add request header
request.addHeader("User-Agent", USER_AGENT);
// what is to add else?
HttpResponse response = client.execute(request);
Run Code Online (Sandbox Code Playgroud)
我现在陷入困境,因为我不确定如何设置请求,它是否需要像?saml=....GET中一样的查询参数,还是必须将编码的saml响应作为POST放在正文中。
有人可以帮助或澄清这些问题吗?
来自纪尧姆斯的更新答案:
我有来自IDPs MetaData的信息:
<IDPSSODescriptor>
<SingleSignOnService
Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
Location="https://myidp/saml2" />
<SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
Location="https://myidp/saml2" />
Run Code Online (Sandbox Code Playgroud)
取决于您应该使用哪种绑定。IdP文档或元数据应提及这一点。有几种:
我想在您的情况下将使用重定向绑定(编辑:您从IdP添加了元数据,它提到您可以同时使用重定向和POST绑定)。在此处进行了描述:https : //docs.oasis-open.org/security/saml/v2.0/saml-bindings-2.0-os.pdf第15页。
简短版本:您必须首先使用DEFLATE算法压缩XML请求,使用base64对其进行编码,使用URL编码对其进行编码,然后将其作为名为SAMLRequest的查询参数传递
?SAMLRequest=<your url-encoded base64-encoded deflated authnrequest>
Run Code Online (Sandbox Code Playgroud)
https://zh.wikipedia.org/wiki/SAML_2.0#SP_Redirect_Request.3B_IdP_POST_Response
| 归档时间: |
|
| 查看次数: |
7370 次 |
| 最近记录: |