使用cURL对SharePoint Online进行身份验证(使用ADFS 2.1作为IP-STS)

使用cURL对SharePoint Online进行身份验证(使用ADFS 2.1作为IP-STS),curl,office365,saml,adfs,ws-trust,Curl,Office365,Saml,Adfs,Ws Trust,我正在尝试设置一个简单的脚本,通过执行以下操作,使用cURL来监视我们的SharePoint Online站点:- 使用“./ADFS/services/trust/13/usernamemix”端点,使用联合身份(ADFS 2.1)登录到我们的Office 365环境 获取SharePoint Cookie(FedAuth等) 浏览到SharePoint网站(验证内容等) 要完成第一步,我将使用cURL向我们的ADFS端点提交以下帖子: curl https://sts.contoso.com

我正在尝试设置一个简单的脚本,通过执行以下操作,使用cURL来监视我们的SharePoint Online站点:-

  • 使用“./ADFS/services/trust/13/usernamemix”端点,使用联合身份(ADFS 2.1)登录到我们的Office 365环境
  • 获取SharePoint Cookie(FedAuth等)
  • 浏览到SharePoint网站(验证内容等)
  • 要完成第一步,我将使用cURL向我们的ADFS端点提交以下帖子:

    curl https://sts.contoso.com/adfs/services/trust/13/UsernameMixed --data @req.txt -H "Content-Type: application/soap+xml" -o out.txt
    
    我发送的SOAP信封请求以下内容(这只是请求的摘录):

    
    https://login.microsoftonline.com/extSTS.srf
    http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer
    http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue
    urn:oasis:names:tc:SAML:1.0:assertion
    

    我从中得到的响应包含一个X509证书、一个摘要和一个签名,我不知道如何使用它。我在网上看到的所有指南都会导致此初始请求返回一个“BinarySecurityToken”,您可以提取并发布到Sharepoint.com,以获取访问所需的Cookie。诚然,他们都在使用MicrosoftOnline STS(云凭证),那么这仅仅是MicrosoftSTS可以实现的,而不是ADFS服务器吗

    还是我的方法有明显的错误

    任何帮助都将不胜感激

    干杯


    Duncan

    因此,我通过找到这个有用的堆栈答案(对一个非常类似的问题)解决了这个问题,它向我显示了发送到Microsoft STS的格式(底部答案):

    完成此操作后,我能够获得“t=Eddejdnefdn23enjd…”值,我能够将该值发布到我的SharePoint网站,并获取必要的SP cookies(FedAuth等)

    我现在被困在如何让这个概念与OWA一起工作。。。当我应用相同的逻辑时,Microsoft STS返回加密的XML和密码数据,而不是binarysecuritytoken。。这又让我感到困惑,所以如果有人有任何想法,请告诉我

    干杯

    如何使用C#应用此功能?
    <trust:RequestSecurityToken xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
        <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
            <a:EndpointReference>
                <a:Address>https://login.microsoftonline.com/extSTS.srf</a:Address>
            </a:EndpointReference>
        </wsp:AppliesTo>
        <trust:KeyType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer</trust:KeyType>
        <trust:RequestType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue</trust:RequestType>
        <trust:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</trust:TokenType>
    </trust:RequestSecurityToken>