Azure Active DirectoryとSAPでSAML使ってSSOしてみた

以下の記事でADFS、OpenAMとSAMLを使ってSAPへのSSOを触ってきました。


AzureにはWindows Azure Active Directoryという機能があります。現在は、Windows AzureからMicrosoft Azureになったことで、Windows Azure Active Directoryも「Windows」の文言取れてAzure Active Directoryになったようです。
 
 

このAzure ADですが、単体でADFSのようにSTS(Security Token Service)としての機能も提供さてていて、WS-FederationやOAuth2.0、そしてSAML2.0に対応しているようです。Azure ADに関しては先日のde:code 2014でも安納さんのセッションが提供されていて、その辺りにも言及されています。
15 年使うためのハイブリッド認証基盤の設計と実装 ~ Side B: Microsoft Azure Active Directory によるクラウド アプリ連携編 ~ | de:code 2014 | Channel 9


Azure ADはオンプレミス側のADとのユーザ同期などもできますし、Azure上のマルチファクター認証機能と連携することで、例えばメッセージや電話などの認証と組み合わせた認証が簡単に実装できたりもします。


今回やろうとしていること

今回はこのAzure ADをIdPとして使って、SAPとのSAMLを利用したSSO環境を設定してみました。
自社内のアプリケーション(SAP)に対して、クラウド上のIdP(Azure AD)を使って認証する形になります。

f:id:yomon8:20140725200215p:plain

  1. SAPのJavaインスタンスにブラウザでアクセス
  2. Azure ADのログオン画面にリダイレクト(SAMLのAuthnRequest付き)
  3. Azure AD上のユーザでログオン(認証)
  4. Azure ADから発行された認証情報(SAMLResponse)をSAPにPOST
  5. SAP側でSAMLResponseをユーザIDにマッピングしてログオンしSAP画面表示


 

設定のポイント

設定のポイントとなったところだけ書いていきます。

Federationメタデータをダウンロード

Azure AD側のFederationメタデータのダウンロードリンクは以下になります。

https://login.windows.net/<TenantDomainName>/FederationMetadata/2007-06/FederationMetadata.xml 

URL内の「TenantDomainName」と言われても良くわからないと思いますが、このURL自体をAzure ADの以下の部分からコピーできます。この画面はAzure ADにアプリケーションを登録すると表示されます。

 
 
 

メタデータファイルの編集

ダウンロードしたXMLファイルから署名部分(ds:Signature属性)を削除します。
残ったままだとSAP側にIdPとしてAzure ADを登録する際のメタデータインポートウィザードが動きません。

<--省略-->
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<--省略-->
</ds:Signature>
<--省略-->

 
 
 

SAP側のプロバイダ名

Azure AD側のアプリケーションIDとSAP側のプロバイダ名を合わせる必要があります。

Azure AD側のここと、


SAP側のここです。

 
 
 

クレーム情報のマッピング

Azure ADからはクレーム属性として以下のものが出力されます。

<fed:ClaimTypesOffered>
		<auth:ClaimType Optional="true" Uri="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn" xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706">
			<auth:DisplayName>UPN</auth:DisplayName>
			<auth:Description>UPN of the user</auth:Description>
		</auth:ClaimType>
		<auth:ClaimType Optional="true" Uri="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706">
			<auth:DisplayName>Name</auth:DisplayName>
			<auth:Description>The display name for the user</auth:Description>
		</auth:ClaimType>
		<auth:ClaimType Optional="true" Uri="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname" xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706">
			<auth:DisplayName>Given Name</auth:DisplayName>
			<auth:Description>First name of the user</auth:Description>
		</auth:ClaimType>
		<auth:ClaimType Optional="true" Uri="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname" xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706">
			<auth:DisplayName>Surname</auth:DisplayName>
			<auth:Description>Last name of the user</auth:Description>
		</auth:ClaimType>
		<auth:ClaimType Optional="true" Uri="http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationinstant" xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706">
			<auth:DisplayName>Authentication Instant</auth:DisplayName>
			<auth:Description>The time (UTC) at which the user authenticated to the identity provider</auth:Description>
		</auth:ClaimType>
		<auth:ClaimType Optional="true" Uri="http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod" xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706">
			<auth:DisplayName>Authentication Method</auth:DisplayName>
			<auth:Description>The method of authentication used by the identity provider</auth:Description>
		</auth:ClaimType>
		<auth:ClaimType Optional="true" Uri="http://schemas.microsoft.com/identity/claims/tenantid" xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706">
			<auth:DisplayName>TenantId</auth:DisplayName>
			<auth:Description>Identifier for the user's tenant</auth:Description>
		</auth:ClaimType>
		<auth:ClaimType Optional="true" Uri="http://schemas.microsoft.com/identity/claims/identityprovider" xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706">
			<auth:DisplayName>IdentityProvider</auth:DisplayName>
			<auth:Description>Identity provider for the user.</auth:Description>
		</auth:ClaimType>
	</fed:ClaimTypesOffered>


例えば私の場合はこのようにAzure ADにユーザを登録しています。

ここから姓の値をSAP側のユーザIDとして利用したい場合は、

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname

をSAP側でログオンIDとしてマッピングしてあげます。




動かしてみる

SP-initiatedで動かしてみます。

SAPのJavaインスタンスにアクセスすると以下のようにAzure ADのログオン画面が表示されるので、ユーザとパスワードを入力してログオンします。

ここで使うユーザはAzure ADに登録されているユーザになります。

Azure ADにログオンが成功するとそのまま、JavaインスタンスにSSOした状態でリダイレクトされます。この際、上記で設定したようにAzure ADの姓の項目とSAP側のユーザIDがマッピングされてログオンできています。


2014/11/29追記

SAMLトークンの署名アルゴリズムSHA1からSHA256に変更されたようです。(たぶん前はSHA1だったはず)
手元のSAPは署名アルゴリズムに関してはSHA1しか対応してないので、SSOできなくなってしまいました。。。


参考情報

Azure Active Directory
http://azure.microsoft.com/ja-jp/services/active-directory/

Azure Active DirectorySAML情報
http://msdn.microsoft.com/ja-jp/library/azure/dn195591.aspx


SAPのSSOに関しては、会社のほうのブログにも纏めて書いてます。