4/5 adfs 2.0 を使用して windows azure との sso を実現しよう v1.1
DESCRIPTION
7.クレーム対応アプリの作成と展開~クラウド編 - Windows Azure の準備 - アプリケーションの開発 - Windows Azure にアプリケーションを展開TRANSCRIPT
![Page 1: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/1.jpg)
1
クレーム対応アプリケーションの作成と展クレーム対応アプリケーションの作成と展開開~ クラウド 編~ クラウド 編
いままでの知識を総動員
1. Windows Azure の準備2. Windows Azure 用アプリケーションの作成3. Windows Azure に展開4. AD FS 2.0 に登録
![Page 2: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/2.jpg)
2
クレーム対応アプリケーションの作成と展開~ クラウド 編
WINDOWS AZURE の準備1. サービスの新規作成2. 自己署名証明書の準備3. 証明書の登録
![Page 3: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/3.jpg)
3
サービスの新規作成~
サービスの新規作成
![Page 4: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/4.jpg)
4
サービスの新規作成 ~
作成するサービスの選択今回は「 Hosted Services 」を選択
![Page 5: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/5.jpg)
5
サービスの新規作成 ~
Service Label を指定サービスの識別名です。わかりやすい名前にしましょう。
![Page 6: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/6.jpg)
6
サービスの新規作成 ~
公開 URL とデータセンターを指定http://■ ■ ■ ■ ■ ■.cloudapp.net/
![Page 7: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/7.jpg)
7
サービスの新規作成 ~
サービスの初期状態
![Page 8: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/8.jpg)
8
自己署名証明書の準備 ~
Windows Azure で使用する証明書とは
• サブスクリプション証明書( .cer )– サービス管理 API ( SMAPI )へのアクセスに使用– X.509 V3 ( .CER )に対応し、最低 2048 bit キー を持ってい
る
• サービス証明書( .pfx )– サービスへの SSL 通信に使用– thumbprint によってアプリケーションと対応付け
参考http://blogs.technet.com/b/junichia/archive/2010/09/02/3353275.aspx
いずれも自己署名証明書を利用可能
![Page 9: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/9.jpg)
9
Hosted ServiceHosted Service Storage AccountStorage Account
TenantTenant
Subscription
(参考) Windows Azure へのアクセス経路
WindowsLiveID
Service Management Portal
Service Management API(SMAPI)
Admin
Storage NodeCompute Node
Controller Controller
Role Instance
Load
Bala
nce
rEnd User
blob
table
queue
• Upload Application• Manage
証明書
SAK
Drives
FabricFabric
![Page 10: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/10.jpg)
10
(参考) SSL 通信と証明書管理
SMAPI
FabricFabric
Storage NodeCompute Node
Controller Controller
SAK
GuestGuest
Hypervisor
発行RESTREST
SSL
格納
RootRoot
GA FA FA
PKCS12PKCS12
Microsoft CA
SSL
発行内部通信に使用される
外部ー FC との通信に使用
SSL
![Page 11: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/11.jpg)
11
自己署名証明書の準備~
[FAQ] 証明書の主体について
Windows Azure 上に展開されるアプリケーションの FQDN は…
xxxxxxxx.cloudapp.netマイクロソフト所有のドメイン…
ということは…
xxxxxxxx.cloudapp.net で証明書を取得することはできない
CNAME を使用して証明書を取得する必要がある
※今回は自己署名証明書を使用します
http://blogs.technet.com/b/junichia/archive/2010/09/03/3353536.aspx
![Page 12: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/12.jpg)
12
自己署名証明書の準備 ~
証明書の登録場所
サブスクリプション
サービスtf.cloudapp.net
サービスtf.cloudapp.net
サブスクリプション証明書( .cer )
サービス証明書( .pfx )
サービスxxxx.cloudapp.net
サービスxxxx.cloudapp.net
サービスyyyy.cloudapp.net
サービスyyyy.cloudapp.net
アカウントアカウント import
import
![Page 13: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/13.jpg)
13
自己署名証明書の準備~
自己署名証明書の作成1. Visual Studio をインストールしたマシンにログオン2. [ スタート ]-[ すべてのプログラム ]-[Microsoft Visual Studio 2010]-[Visual
Studio Tools]-[Visual Studio コマンドプロンプト ] を起動3. 証明書( .cer )ファイルとプライベートキーファイル( .pvk )ファイルを作
成
4. .pvk と .cer から .pfx ファイルを作成する
5. .cer と .pfx ファイルを Windows Azure にインポートする
pvk2pfx -pvk "sydneytest.cloudapp.net.pvk“ -spc “tf01.cloudapp.net.cer“ -pfx “tf01.cloudapp.net.pfx“ -pi < パスワード >
makecert -r -pe -n "CN=tf01.cloudapp.net" -sky exchange “tf01.cloudapp.net.cer" -sv “tf01.cloudapp.net.pvk"
![Page 14: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/14.jpg)
14
証明書の登録~
サブスクリプション証明書の登録( .cer )
![Page 15: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/15.jpg)
15
証明書の登録~
サービス証明書の登録( .pfx )
![Page 16: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/16.jpg)
16
クレーム対応アプリケーションの作成と展開~ クラウド 編
WINDOWS AZURE 用アプリケーションの作成
![Page 17: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/17.jpg)
17
アプリケーションの開発 ~
テンプレートの選択
![Page 18: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/18.jpg)
18
アプリケーションの開発 ~
ロールの指定ワーカーロールと Web ロールの違いについての詳細は以下を参照
Windows Azure Platform の概要http://technet.microsoft.com/ja-jp/cloud/gg236628.aspx
![Page 19: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/19.jpg)
19
アプリケーションの開発 ~
Windows Identity Foundation への参照追加
.NET から Microsoft.IdentityModel を追加する
![Page 20: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/20.jpg)
20
アプリケーションの開発 ~
Microsoft.IdentityModel モジュールの複製設定
Windows Azure で用意されている Windows Server には WIF がインストールされていない。そこで、 Microsoft.IdentityModel を Azure 上でも使用できるよう、パッケージの中に組み込んでおく必要がある。
パッケージ
Microsoft.IdentityModelMicrosoft.IdentityModel
一緒
にア
ップ
ロー
ド一
緒に
アッ
プロ
ード
![Page 21: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/21.jpg)
21
アプリケーションの開発 ~
SSL の設定 ①SSL を使用する場合には、サービス証明書へのポインター( Thumprint )を設定しておく必要がある
thumbprintthumbprint
![Page 22: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/22.jpg)
22
アプリケーションの開発 ~
SSL の設定 ②
![Page 23: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/23.jpg)
23
アプリケーションの開発 ~
SSL の設定 ③
識別名なので何でもよい
識別名なので何でもよい
サービス証明書の
Thumbprint
サービス証明書の
Thumbprint
証明書の識別名証明書の識別名
このままこのまま
![Page 24: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/24.jpg)
24
アプリケーションの開発~
STS 参照の追加 ①
自分自身の公開後のURL を指定する
![Page 25: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/25.jpg)
25
アプリケーションの開発~
STS 参照の追加 ②
オンプレミスの場合と同じ
![Page 26: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/26.jpg)
26
アプリケーションの開発~
STS 参照の追加 ③
![Page 27: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/27.jpg)
27
アプリケーションの開発~
Web.config の編集 ①サービス証明書の Thumbprint を追記する
<serviceCertificate> <certificateReference x509FindType="FindByThumbprint" findValue=“<THUMBPRINT>"/></serviceCertificate>
![Page 28: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/28.jpg)
28
アプリケーションの開発~
Web.config の編集 ②
<configuration><system.web> に以下を追記•<customErrors mode=“off” />•<httpRuntime requestValidiationMode=“2.0” />
![Page 29: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/29.jpg)
29
アプリケーションの開発~
ちょっとだけコーディング(?)①今回は、オンプレミスに展開したアプリケーションのコードを流用• Default.aspx のソースの修正
<%@ Page Language=“C#” AutoEventWireup=“true” CodeBehind=“Default.aspx.cs” Inherits=“WebRole1._Default” validateRequest="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
(略)
</html>
<%@ Page Language=“C#” AutoEventWireup=“true” CodeBehind=“Default.aspx.cs” Inherits=“WebRole1._Default” validateRequest="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
(略)
</html>
Claims-Aware ASP.NET テンプレートで提供されている Default.aspx のコード部を、作成中の Default.aspx に上書きでコピペして、以下の通り修正
ちょっとだけ修正
ちょっとだけ修正
![Page 30: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/30.jpg)
30
アプリケーションの開発~
ちょっとだけコーディング(?)②• Default.aspx.cs のソースを「注意しながら」修正
public partial class _Default : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { (略) }}
using Microsoft.IdentityModel.Claims;
namespace WebRole1{ public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) {
} }}
using Microsoft.IdentityModel.Claims;
namespace WebRole1{ public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) {
} }}
挿入
追記
Claims-Aware ASP.NET テンプレートのソース
Claims-Aware ASP.NET テンプレートのソース
![Page 31: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/31.jpg)
31
アプリケーションの発行方法
直接発行直接発行
2 通りの発行方法•Visual Studio から直接発行する•パッケージファイルを保存して、ポータルサイトからアップする
.cspkg .cscfg
Windows Azure Portal
サービ
スパ
ッ
ケージ
を作成
サービ
スパ
ッ
ケージ
を作成
アップロード
アップロード
depl
oyde
ployここまでは
開発者の仕事展開するのはITPRO の仕事
今回はこちらの方法を使用する今回はこちらの方法を使用する
![Page 32: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/32.jpg)
32
アプリケーションの開発~
サービスパッケージを作成IIS への発行とは少し異なります
インフラ担当者は、今後パッケージの展開を依頼されることがあるはずですその場合にはこの方法を使用します。
![Page 33: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/33.jpg)
33
アプリケーションの開発~
サービスパッケージをアップロード
.cspkg を指定
.cspkg を指定
.cscfg を指定.cscfg を指定
![Page 34: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/34.jpg)
34
Deploy が完了するまで 15 分~ 20 分
約15 分後
約15 分後
![Page 35: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/35.jpg)
35
約5 分後
約5 分後
![Page 36: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/36.jpg)
36
メタデータへの接続を確認
https://tf01.cloudapp.net/FederationMetadata/2007-06/FederationMetadata.xml
アップロードが完了してステータスが「 Ready 」になったら、以下に接続して表示されることを確認してみましょう。
![Page 37: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/37.jpg)
37
AD FS 2.0 への登録 ①今度は Windows Azure に展開したアプリケーションを、 AD FS 2.0 に登録します。
前ページのメタデータ
の URL を指定する
前ページのメタデータ
の URL を指定する
![Page 38: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/38.jpg)
38
AD FS 2.0 への登録 ②見分けがつきやすい表示名を指定す
る
見分けがつきやすい表示名を指定す
る
![Page 39: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/39.jpg)
39
AD FS 2.0 への登録 ③
![Page 40: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/40.jpg)
40
実行テストhttps://tf01.cloudapp.net/
![Page 41: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/41.jpg)
41
WIF アプリケーションと SSO の仕組み
オンプレミス
クラウド
AD DS AD FS 2.0
信頼信頼
12
3
4
クラウド上に Identity 情報を用意せずに、クレームによるアクセス承認が可能
WIF
5
6
7
8
WIF : Windows Identity Foundation
![Page 42: 4/5 ADFS 2.0 を使用して Windows Azure との SSO を実現しよう V1.1](https://reader033.vdocuments.pub/reader033/viewer/2022061616/5565fe10d8b42aa6628b465a/html5/thumbnails/42.jpg)
42
WS-Federation (Passive SSO) の流れ
1. オンプレミスの AD DS にログオン依頼2. AD DS からクレデンシャルが送信されクライアントに保
存------------3. Windows Azure 上のアプリケーションにアクセス4. クレーム ポリシーをアプリケーションから受け取り、
STS (AD FS 2.0) にリダイレクト5. 属性ストアである AD DS からクレームを収集6. 集めたクレームに署名をしてセキュリティトークンを生成
し、 Windows Azure アプリケーションに送信7. アプリケーションはセキュリティトークンを受け取
り、 Windows Identity Foundation (WIF) を使用してクレームを取り出し、評価する
8. 画面がブラウザーに送られる