Azure active directory Android/iOS:如何使用SAML协议为带有Azure AD的移动设备提供SSO

Azure active directory Android/iOS:如何使用SAML协议为带有Azure AD的移动设备提供SSO,azure-active-directory,single-sign-on,saml-2.0,Azure Active Directory,Single Sign On,Saml 2.0,我正在尝试使用SAML2.0协议在带有Azure AD的移动本机设备中实现SSO。从网络上我可以成功登录,但我找不到一种方法来做同样使用移动客户端。我尝试使用微软Azure提供的Android项目。我能够通过这个项目获得代币。但我不明白下一步需要做什么。我们以前的请求是这样的(没有Azure): . 对该请求的调用用于向我提供一个SAMLResponse,我在重定向URL中使用了它,作为回报,它用于向我提供用户配置文件的详细信息。现在,由于Azure中的机制完全不同,我不明白在收到访问令牌后应该

我正在尝试使用SAML2.0协议在带有Azure AD的移动本机设备中实现SSO。从网络上我可以成功登录,但我找不到一种方法来做同样使用移动客户端。我尝试使用微软Azure提供的Android项目。我能够通过这个项目获得代币。但我不明白下一步需要做什么。我们以前的请求是这样的(没有Azure):
. 对该请求的调用用于向我提供一个SAMLResponse,我在重定向URL中使用了它,作为回报,它用于向我提供用户配置文件的详细信息。现在,由于Azure中的机制完全不同,我不明白在收到访问令牌后应该如何继续。我应该如何调用上述URL以获取SAMLResponse代码,以便使用is从服务提供商获取用户配置文件。

下面的协议图描述了单点登录序列。云服务(服务提供商)使用HTTP重定向绑定将AuthnRequest(身份验证请求)元素传递给Azure AD(身份提供商)。Azure AD然后使用HTTP post绑定将响应元素发布到云服务

要请求用户身份验证,云服务将AuthnRequest元素发送到Azure AD。SAML 2.0 AuthnRequest示例可能如下所示:

<samlp:AuthnRequest
xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
ID="id6c1c178c166d486687be4aaf5e482730"
Version="2.0" IssueInstant="2013-03-18T03:28:54.1839884Z"
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
<Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">https://www.contoso.com</Issuer>
</samlp:AuthnRequest>

https://www.contoso.com
当请求的登录成功完成时,Azure AD将向云服务发布响应。对成功登录尝试的响应如下所示:

<samlp:Response ID="_a4958bfd-e107-4e67-b06d-0d85ade2e76a" Version="2.0" IssueInstant="2013-03-18T07:38:15.144Z" Destination="https://contoso.com/identity/inboundsso.aspx" InResponseTo="id758d0ef385634593a77bdf7e632984b6" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
  <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion"> https://login.microsoftonline.com/82869000-6ad1-48f0-8171-272ed18796e9/</Issuer>
  <ds:Signature xmlns:ds="https://www.w3.org/2000/09/xmldsig#">
    ...
  </ds:Signature>
  <samlp:Status>
    <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
  </samlp:Status>
  <Assertion ID="_bf9c623d-cc20-407a-9a59-c2d0aee84d12" IssueInstant="2013-03-18T07:38:15.144Z" Version="2.0" xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
    <Issuer>https://login.microsoftonline.com/82869000-6ad1-48f0-8171-272ed18796e9/</Issuer>
    <ds:Signature xmlns:ds="https://www.w3.org/2000/09/xmldsig#">
      ...
    </ds:Signature>
    <Subject>
      <NameID>Uz2Pqz1X7pxe4XLWxV9KJQ+n59d573SepSAkuYKSde8=</NameID>
      <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
        <SubjectConfirmationData InResponseTo="id758d0ef385634593a77bdf7e632984b6" NotOnOrAfter="2013-03-18T07:43:15.144Z" Recipient="https://contoso.com/identity/inboundsso.aspx" />
      </SubjectConfirmation>
    </Subject>
    <Conditions NotBefore="2013-03-18T07:38:15.128Z" NotOnOrAfter="2013-03-18T08:48:15.128Z">
      <AudienceRestriction>
        <Audience>https://www.contoso.com</Audience>
      </AudienceRestriction>
    </Conditions>
    <AttributeStatement>
      <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name">
        <AttributeValue>testuser@contoso.com</AttributeValue>
      </Attribute>
      <Attribute Name="http://schemas.microsoft.com/identity/claims/objectidentifier">
        <AttributeValue>3F2504E0-4F89-11D3-9A0C-0305E82C3301</AttributeValue>
      </Attribute>
      ...
    </AttributeStatement>
    <AuthnStatement AuthnInstant="2013-03-18T07:33:56.000Z" SessionIndex="_bf9c623d-cc20-407a-9a59-c2d0aee84d12">
      <AuthnContext>
        <AuthnContextClassRef> urn:oasis:names:tc:SAML:2.0:ac:classes:Password</AuthnContextClassRef>
      </AuthnContext>
    </AuthnStatement>
  </Assertion>
</samlp:Response>

https://login.microsoftonline.com/82869000-6ad1-48f0-8171-272ed18796e9/
...

SAML协议要求身份提供者(Azure AD)和服务提供者(应用程序)交换关于他们自己的信息

//执行身份验证请求 mAuthContext.acquireToken( getActivity(), 资源ID, 客户ID, 重定向\u URI,
即时行为,自动, getAuthInteractiveCallback())

//

//获取令牌以调用类似Microsoft Graph的API mAuthResult.getAccessToken()

一旦您拥有了令牌,就可以使用它来调用graph api

这里我们有一个在android中设置SSO的wiki,您可能会感兴趣


希望有帮助。

下面的协议图描述了单点登录序列。云服务(服务提供商)使用HTTP重定向绑定将AuthnRequest(身份验证请求)元素传递给Azure AD(身份提供商)。Azure AD然后使用HTTP post绑定将响应元素发布到云服务

要请求用户身份验证,云服务将AuthnRequest元素发送到Azure AD。SAML 2.0 AuthnRequest示例可能如下所示:

<samlp:AuthnRequest
xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
ID="id6c1c178c166d486687be4aaf5e482730"
Version="2.0" IssueInstant="2013-03-18T03:28:54.1839884Z"
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
<Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">https://www.contoso.com</Issuer>
</samlp:AuthnRequest>

https://www.contoso.com
当请求的登录成功完成时,Azure AD将向云服务发布响应。对成功登录尝试的响应如下所示:

<samlp:Response ID="_a4958bfd-e107-4e67-b06d-0d85ade2e76a" Version="2.0" IssueInstant="2013-03-18T07:38:15.144Z" Destination="https://contoso.com/identity/inboundsso.aspx" InResponseTo="id758d0ef385634593a77bdf7e632984b6" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
  <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion"> https://login.microsoftonline.com/82869000-6ad1-48f0-8171-272ed18796e9/</Issuer>
  <ds:Signature xmlns:ds="https://www.w3.org/2000/09/xmldsig#">
    ...
  </ds:Signature>
  <samlp:Status>
    <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
  </samlp:Status>
  <Assertion ID="_bf9c623d-cc20-407a-9a59-c2d0aee84d12" IssueInstant="2013-03-18T07:38:15.144Z" Version="2.0" xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
    <Issuer>https://login.microsoftonline.com/82869000-6ad1-48f0-8171-272ed18796e9/</Issuer>
    <ds:Signature xmlns:ds="https://www.w3.org/2000/09/xmldsig#">
      ...
    </ds:Signature>
    <Subject>
      <NameID>Uz2Pqz1X7pxe4XLWxV9KJQ+n59d573SepSAkuYKSde8=</NameID>
      <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
        <SubjectConfirmationData InResponseTo="id758d0ef385634593a77bdf7e632984b6" NotOnOrAfter="2013-03-18T07:43:15.144Z" Recipient="https://contoso.com/identity/inboundsso.aspx" />
      </SubjectConfirmation>
    </Subject>
    <Conditions NotBefore="2013-03-18T07:38:15.128Z" NotOnOrAfter="2013-03-18T08:48:15.128Z">
      <AudienceRestriction>
        <Audience>https://www.contoso.com</Audience>
      </AudienceRestriction>
    </Conditions>
    <AttributeStatement>
      <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name">
        <AttributeValue>testuser@contoso.com</AttributeValue>
      </Attribute>
      <Attribute Name="http://schemas.microsoft.com/identity/claims/objectidentifier">
        <AttributeValue>3F2504E0-4F89-11D3-9A0C-0305E82C3301</AttributeValue>
      </Attribute>
      ...
    </AttributeStatement>
    <AuthnStatement AuthnInstant="2013-03-18T07:33:56.000Z" SessionIndex="_bf9c623d-cc20-407a-9a59-c2d0aee84d12">
      <AuthnContext>
        <AuthnContextClassRef> urn:oasis:names:tc:SAML:2.0:ac:classes:Password</AuthnContextClassRef>
      </AuthnContext>
    </AuthnStatement>
  </Assertion>
</samlp:Response>

https://login.microsoftonline.com/82869000-6ad1-48f0-8171-272ed18796e9/
...

SAML协议要求身份提供者(Azure AD)和服务提供者(应用程序)交换关于他们自己的信息

//执行身份验证请求 mAuthContext.acquireToken( getActivity(), 资源ID, 客户ID, 重定向\u URI,
即时行为,自动, getAuthInteractiveCallback())

//

//获取令牌以调用类似Microsoft Graph的API mAuthResult.getAccessToken()

一旦您拥有了令牌,就可以使用它来调用graph api

这里我们有一个在android中设置SSO的wiki,您可能会感兴趣

希望能有帮助