azure-active-directory - 如何使用 saml 断言获取 MS 图形 API 的授权令牌
问题描述
我们使用sso登录Office365和我们自己的内网。sso 进程返回一个 saml2 断言,该断言可用于我的代码。
我希望使用它来获取授权令牌来访问图形 api。
我已按照此处的说明进行操作:https ://docs.microsoft.com/en-us/azure/active-directory/develop/v2-saml-bearer-assertion
最后我得到一个错误:“AADSTS50107:请求的联合领域对象' https://sts.windows.net/xyzzy/ '不存在。”
我得出的结论是,这是因为我们的 Office365 域是托管的,而不是联合的,并且此流程不适用于托管域(尽管不清楚为什么不这样做)。
最后我得到了一个不同的错误:“AADSTS700001:应用程序:spn:xyzzy 需要选择加入‘aio’可选声明,以便代表流程使用颁发给此应用程序的 SAML 令牌”。这里所指的应用程序是在 SSO 中使用的应用程序,当我们最初获得 saml 断言时(而不是用于获取图 api 的授权令牌的应用程序)。
我不知道如何选择“aio”可选声明。此声明未出现在应用程序配置的列表中。
我将不胜感激在克服这两个错误中的任何一个方面提供的任何帮助,或者任何使我能够使用 saml 断言获得图形 api 授权令牌的替代方法。
我尝试使用的 saml 断言示例:
<Assertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion" ID="_nnnnnnnn-9ed2-4511-8f04-nnnnnnnnn" IssueInstant="2020-01-16T16:12:44.389Z" Version="2.0">
<Issuer>https://sts.windows.net/nnnnnnnn-187d-415b-87e6-nnnnnnnn8a01/</Issuer>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
<Reference URI="#_nnnnnnnn-9ed2-4511-8f04-nnnnnnnn1800">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<DigestValue>mEW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AAaMhMB8wHQYDVR0OBBYEFEXiTeLGkA2LgAjQOrT2KChpgwCgMA0GCSqGSIb3DQEBCwUAA4IBAQA6GqtYZDQzym0yxfL2NnlSbJP/lLhSQOqbPBdN6DWQ/3duk+e08Ix5qy63hzW+qQR0PAkFEcooL5+bdheS66tFJpVejEcqCSKUVvwOUe6GY/ju752dlB7anBB9An362khehCxqydYNS5Igl0rtcP7dKC3ZBn1m2B9ULsyx46iNpfHQHHv9NKU2vVq2CtNc95CFktwjUwlyWMgbfI/DzPX/nnnnnnnnsuVVBO7+jIaBmi0XGqudooZkqgIrvnfNMM13Gy78TUNHsCiAQEwZ/L17yNbzotNGxAoPfuXldbD52MQNOsA7WhH+j8qFWY6gZzTN4NpVtuW4m04TCEFexnTz</X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
<Subject>
<NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent">nnnnnnnnavitA3FPq9Bqtu6d3UlysiFOxjMX_je3u-k</NameID>
<SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"/>
</Subject>
<Conditions NotBefore="2020-01-16T16:07:44.248Z" NotOnOrAfter="2020-01-16T17:12:44.248Z">
<AudienceRestriction>
<Audience>spn:nnnnnnnn-900b-4a82-b65f-3975nnnnnnnn</Audience>
</AudienceRestriction>
</Conditions>
<AttributeStatement>
<Attribute Name="http://schemas.microsoft.com/identity/claims/tenantid">
<AttributeValue>nnnnnnnn-187d-415b-87e6-295ennnnnnnn</AttributeValue>
</Attribute>
<Attribute Name="http://schemas.microsoft.com/identity/claims/objectidentifier">
<AttributeValue>nnnnnnnn-2111-48e1-ac4b-726nnnnnnnn</AttributeValue>
</Attribute>
<Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name">
<AttributeValue>nnnnnn.nnnnnn@nn.nnng</AttributeValue>
</Attribute>
<Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname">
<AttributeValue>nnnnnn</AttributeValue>
</Attribute>
<Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname">
<AttributeValue>nnnnn</AttributeValue>
</Attribute>
<Attribute Name="http://schemas.microsoft.com/identity/claims/displayname">
<AttributeValue>nnnnnnnnnnnnnnnnn</AttributeValue>
</Attribute>
<Attribute Name="http://schemas.microsoft.com/identity/claims/identityprovider">
<AttributeValue>https://sts.windows.net/nnnnnnnn-187d-415b-87e6-295e9nnnnnnnn/</AttributeValue>
</Attribute>
<Attribute Name="http://schemas.microsoft.com/claims/authnmethodsreferences">
<AttributeValue>http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/password</AttributeValue>
</Attribute>
</AttributeStatement>
<AuthnStatement AuthnInstant="2020-01-14T15:47:10.396Z">
<AuthnContext>
<AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password</AuthnContextClassRef>
</AuthnContext>
</AuthnStatement>
</Assertion>
解决方案
推荐阅读
- regex - 正则表达式:在字符之间查找和替换蛇大小写为 UpperCamelCase/PascalCase
- python - 如何将 LSTM 与 CNN 结合使用
- ruby-on-rails - ActiveSupport TimeWithZone 如何保持价值?
- python - 构造函数中的 Magic Mock 函数
- regex - 如何用 Google 表格中的公式用单个字符替换一个字符组,用另一个单个字符替换另一个字符组?
- c# - 根据 Unity 中的世界位置隐藏所有孩子
- java - 即使从最近的应用程序中清除应用程序或在 Red MI 设备上关闭应用程序,也可以继续服务
- google-cloud-platform - 谷歌云是否支持 Tibco EMS?如果没有,如何在谷歌云中运行 EMS 代理?
- java - SQL Query with Entity Manager
- python - SQLAlchemy 最多获得 N 个结果,其中每个类别少于 M