More Related Content Similar to Windows Phone で Active Directory 認証 2011.12.1版 Similar to Windows Phone で Active Directory 認証 2011.12.1版 (20) More from junichi anno (20) Windows Phone で Active Directory 認証 2011.12.1版1. 企業利用者のための Windows Phone アプリ開発
~業務アプリケーションの配信と管理を実装する
Part II
アプリケーションに
認証機能を実装する
2011.12.1 V1.01
日本マイクロソフト株式会社
エバンジェリスト
安納 順一(あんのう じゅんいち)
http://blogs.technet.com/junichia/
twitter @junichia
2. Agenda
1. クラウドサービスとオンプレミス認証基盤の連携方法
• Windows Azure インスタンスと Active Directory の連携方法
2. Windows Phone から認証基盤にアクセスする方法
• Silverlight アプリから Active Directory で認証する方法
3. WEB サービスが Active Directory で認証されたアプリケーションを
受け入れる方法
• WCFサービス が Active Directory の認証結果を受け入れる方法
お時間の都合上、この部分の詳しい解説は割愛させていただきます
2
4. 復習:業務サービスの構成
1. 業務サービスの場所
① オンプレミス いずれの場合も認証
② 一部または全部がクラウド 基盤との連携が重要
2. 業務サービスへの接続アプリ
① Internet Explorer 認証基盤との
② Silverlight アプリ 連携方法が異なる
4
5. 業務アプリの「使い勝手」を考えれば...
IE9 Mobile クラウドアプリ
Active Directory ファミ
リ
SharePoint Server
Silverlight アプ
リ
Exchange Server
その他業務サーバー
5
7. 業務サービスの構成 ~ SL アプリの場合
① 業務サービス
(SOAP/REST)
認証基盤に直接アクセス 認証
する必要は無い
ここが問題!
クラウド
オンプレミス
認証基盤
認証 業務サービス
(SOAP/REST)
7
8. 業務サービスの構成 ~ SL アプリの場合
② 業務サービス
(SOAP/REST)
認可
認証基盤に直接アクセス
する必要は無い
クラウド
オンプレミス
認証 認証基盤
認可 業務サービス
(SOAP/REST)
認証基盤に直接アクセス
する必要は無い
8
9. 課題はなに?
1. クラウドサービスとオンプレミス認証基盤の連携方法
• Windows Azure インスタンスと Active Directory の連携方法
2. Windows Phone から認証基盤にアクセスする方法
• Silverlight アプリから Active Directory で認証する方法
3. WEB サービスが Active Directory で認証されたアプリ
ケーションを受け入れる方法
• WCFサービス が Active Directory の認証結果を受け入れる方法
本日は時間の都合でここまでは解説できませんが、良質のサンプル
が大量に存在します
9
12. Windows Azure Connect
どう使う?
Windows Azure アプリがオンプレミスの SQL Server にアクセス
Windows Azure インスタンスを Active Directory ドメインに参加
Windows Azure アプリからファイル サーバーにアクセス
Windows Azure アプリからオンプレミスのプリンターに印刷
Windows Azure アプリ/OS を PowerShell でリモート管理
12
13. Windows Azure Connect の仕組み
• 「ロール」と「エンドポイントグループ」間を Relay を通して接続
(IPv6 with IPSEC)
• 既存のネットワークも同時に使用可能
Role
インスタンス インスタンス インスタンス
Azure Connect
Relay エンドポイント
ソフトウェア
Firewall
エンドポイント グループ
13
14. Windows Azure Connect を使用すると
業務サービス
認証 AD ドメインに参
認証基盤に直接アクセス
加
する必要は無い
Windows Azure Connect により社
内サーバーとの通信が可能に
クラウド
オンプレミス
認証基盤
Silverlight アプ
リ mobile 9
IE 認証 業務サービス
14
15. Windows Azure Connect の設定方法
1. ライセンス認証トークンを取得する
2. ライセンス認証トークンをプロジェクトに埋め込む
3. プロジェクトを Windows Azure にデプロイ
15
16. 4. オンプレミスのサーバーに Azure Connect エンドポイントソフトウェアをイ
ンストール(Azure インスタンスには自動的にインストールされる)
オンプレミスのサーバー上で
こいつにアクセスすると
インストーラーがダウンロードされる
インストールが完了すると、Azure Connect 専用の仮
想ネットワークカードが作成され、Azure Connect リ
レー
サービスに接続される。
要再起動
16
17. 5. オンプレミスのサーバーと Azure インスタンスをグルーピング
※グルーピングはプロジェクトのアップロードが完了してから
Azure Connect エンドポイントソフトウェアを
インストールしたサーバー
Azure Connect を有効にしたインスタンス
構成が完了すると「!」マークが消える
17
18. Active Directory ドメインに参加するには
プロジェクトに必要情報を埋め込んでからデプロイする
• Microsoft.WindowsAzure.Plugins.Connect.EnableDomainJoin ここで指定したドメインコント
• Microsoft.WindowsAzure.Plugins.Connect.DomainFQDN ローラにエンドポイントソフト
• ウェアをインストールしておく
Microsoft.WindowsAzure.Plugins.Connect.DomainControllerFQDN
• Microsoft.WindowsAzure.Plugins.Connect.DomainAccountName
• Microsoft.WindowsAzure.Plugins.Connect.DomainPassword encrypt する!
18
19. パスワードの encrypt 方法
サービス証明書を使用し、PowerShell 等でパスワードを暗号化する
1. Visual Studio コマンドプロンプトを「管理者権限」で起動
2. サービス証明書を作成
① 証明書(.cer)ファイルとプライベートキーファイル( .pvk)ファイルを作成
makecert -r -pe -n "CN=PwdEncCert”
-sky exchange “PwdEncCert.cer” -sv “PwdEncCert.pvk"
② pvk と .cer から .pfx ファイルを作成する
pvk2pfx -pvk “PwdEncCert.pvk“
-spc “PwdEncCert.cer“ -pfx “PwdEncCert.pfx“ -pi <パスワード>
3. 作成した .pfx ファイルを当該 Azure インスタンスのサービス証明書として
アップロード
19
20. 5. 作成した .cer ファイルを開発環境にインストール
※インストールした場所を覚えておくこと!(例えば CurrentUserMy)
6. PowerShell コンソールからの操作
① インストールした証明書の Thumbprint を取得
PS C:> cd cert:CurrentUserMy
PS cert:CurrentUsermy> dir
Thumbprint Subject
---------- -------
F8ACE------------------------FB827AC61A3 CN=127.0.0.1, O=TESTING ONLY, OU=W.
EB805------------------------842E095355B CN=www.fabrikamshipping.com
66EBD87D67398CD8FEA41E931B00BB98B8F06B06 CN=PwdEncCert
・
・
PS cert:LocalMachinemy> cd c:
PS C:>
20
21. ② Thumbprint を使用して暗号化
PS C:> $PlainPassword = “<パスワード>"
PS C:> $thumbprint = “<Thumbprint>"
PS C:> $AzureCert = get-item cert:LocalMachineMY$thumbprint
PS C:> [Reflection.Assembly]::LoadWithPartialName("System.Security")
PS C:> $pass = [Text.Encoding]::UTF8.GetBytes($PlainPassword)
PS C:> $content = new-object Security.Cryptography.Pkcs.ContentInfo –argumentList (,$pass)
PS C:> $env = new-object Security.Cryptography.Pkcs.EnvelopedCms $content
PS C:> $env.Encrypt((new-object System.Security.Cryptography.Pkcs.CmsRecipient($AzureCert)))
PS C:> [Convert]::ToBase64String($env.Encode())
MIIBlAYJKoZIhvcNAQcDoIIBhTCCAYECAQAxggFFMIIBQQIBADApMBUxEzARBxxxxAMTClB3c0VuY0N
lcnQCEF/PzJ/f6bOxxxxPlIhq7rUwDQYJKoZIhvcNAQEBBQAEggEAqkWA5vT7A8K8dvaxQOKWG5Oegq
eERbgzw2SOYwh9UqAyIMhEAm44YwV8DrYMykIMPJnwODV8f8M4M7FjRGJ9rrDjHJSf8W9DOJtsavEdZ
xG9gDEoZ3lfrjP/CvppnSh3Kxxxxxxxxxxxx3UONXGZNyBrA2hz+LcTbLs8BKFUDLlP++iearfPoQ2
6X0EcSnn6ImlkaRcJ7A0wh/TzZTtsaqA1I/2uF47hNlUSz0f55nGJloQUldSsf3L/NvtnjHmFNEiVLR
pqgxxxxdzG9qA1LxWbxv9uDk09ObP6MFCQNg627v3FTHIVkUv2vcirOS1Su9QLpSInLq8352kUegoUj
AzBgkqhkiG9w0BBwEwFAYIKoZIhvcNAwcECKgNvWGg707FgBDhojvrH17/nTKwlY23cPzs
PS C:>
21
22. 7. 暗号化したパスワードを
Microsoft.WindowsAzure.Plugins.Connect.DomainPassword にセット
8. 使用した証明書の Thumbprint をプロジェクトにセット
22
23. Azure インスタンスがドメイン参加するまでの流れ
1. プロジェクトを展開
2. オンプレミスにエンドポイントソフトウェアをインストール
3. インスタンスとエンドポイントをグループ化
約 Azure インスタンス側の Azure Connect エンドポイントソフトウェ
15 アが
分 ドメインコントローラと通信ができることを確認後、自動的にドメ
イン参加が行われる(再起動有)
4. ドメイン参加完了
インスタンスが複数ある場合には、全てのインスタンスがドメインに参
加する
23
26. SSL と Windows Phone
Windows Phone に規定でインストールされている Root Certificate
詳細は http://msdn.microsoft.com/en-us/library/gg521150(v=VS.92).aspx
AOL (United States) RSA Security (United States)
Comodo (United States) SECOM Trust Systems Co. Ltd (Japan)
DigiCert (United States) Taiwan-CA Inc. (Taiwan)
Entrust (Canada) TrustCenter (Germany)
GlobalSign (United Kingdom) Trustwave (United States)
GoDaddy (United States) VeriSign (United States)
Keynectis (France) VeriSign Business (United States)
QuoVadis (Bermuda)
26
29. Windows Phone と認証
本日のテーマはこれ
ライブラリ Identity Provider
Active
SL.IdentityModel
Directory
Windows Live Connect
Windows Live
SDK
Facebook C# SDK Facebook
Windows Azure
SL.Phone.Federation AppFabric ACS
Google
29
30. Windows Phone と Active Directory
• System.DirectoryServce がサポートされていない
– Active Directory に直接アクセスできない
– 何らかのサービスを介して認証の代行を依頼する必要がある
AD DS
認証
利用 認証
認証代行
サービス
30
31. Windows Phone と Active Directory Federation Service
WS-Trust(SOAP) AD FS AD DS
① UserID/Password ② 認証
⑤ セキュリティトークン ③ 属性
④ 属性に署名
① AD FS にはドメインのユーザーIDとパスワードを渡す(もちろん SSL)
② AD 認証は AD FS が代行
③ AD DS からユーザーの属性が返される(どんな属性を返すかはAD FSに定義されている)
④ AD FS は「属性(クレーム)」に署名をしてセキュリティートークン(SAML アサーション)
を生成
⑤ WP アプリにはセキュリティトークンが返される
31
32. セキュリティトークンの使い道
WS-Trust(SOAP) AD FS AD DS
① UserID/Password ② 認証
⑤ セキュリティトークン ③ 属性
④ 属性に署名 信頼
⑦ 認可
⑥ セキュリティトークン
業務アプリ
⑥ アプリケーションにセキュリティトークンを送付
⑦ アプリケーションはセキュリティトークンを参照して「認可」
32
33. クレーム とは
アプリケーションに渡すユーザー自身の属性
ユーザーのロールを表現しアクセス認可に使用される
33
34. セキュリティ トークン/アサーション
パッケージ化されたクレーム
発行者(オーソリティ)の署名によって信頼性を担保
発行者とセキュリティトークン利用者は事前に信頼関係を結んでおく
セキュリティトークン/アサーション
34
35. AD FS とは Domain Service
Lightweight Directory Service
• Active Directory 5兄弟 の五男 Certificate Service
• AD 認証されたユーザーに対してセキュリティトーク Rights Management Service
ンを発行する(セキュリティトークンサービス:STS) Federation Service
社内ネットワーク DMZ
AD DS 構成DB AD FS AD FS PROXY
cluster
load balance
load balance
認証 or
standalon
AD DS or
SQL Server or
e Internet
AD LDS
or
WID
クレーム
ストア
構成DB STS R-PROXY
35
36. AD FS のセットアップ
• 正確には Active Directory Federation Service 2.0
• 最新版は WEB からダウンロード
http://www.microsoft.com/downloads/ja-jp/details.aspx?FamilyID=118C3588-
9070-426A-B655-6CEC0A92C10B
ADFS ダウンロード 検索
• サポートしている OS
• Windows Server 2008 Datacenter/
• Windows Server 2008 Enterprise/
• Windows Server 2008 R2/
• Windows Server 2008 R2 Datacenter/
• Windows Server 2008 R2 Enterprise/
• Windows Server 2008 R2 Foundation/
• Windows Server 2008 R2 Standard/
• Windows Server 2008 Service Pack 2/
• Windows Server 2008 Standard/
• Windows Small Business Server 2008 Premium/
• Windows Small Business Server 2008 Standard
• Active Directory ドメイン 必須
36
37. Windows Phone から AD FS を利用するには
SL.IdentityModel ライブラリ
• Identity Developer TrainingKit 2010 April に含まれている
http://www.microsoft.com/download/en/details.aspx?id=14347
• PC 用 Silverlight 版なので移植が必要
Claims ProtocolsWSTrust
├ Claim.cs ├ IRequestCredentials.cs
├ ClaimCollection.cs ├ IssueCompletedEventArgs.cs
├ ClaimsIdentity.cs ├ IssuedTokenHeader.cs
├ ClaimsPrincipal.cs ├ IWSTrustContract.cs
├ ClaimType.cs ├ RequestedSecurityToken.cs
├ IClaimsIdentity.cs ├ RequestSecurityToken.cs
└ IClaimsPrincipal.cs ├ RequestSecurityTokenResponse.cs
├ UsernameCredentials.cs
Services ├ WindowsCredentials.cs
└ TokenCache.cs ├ WSTrust13Constants.cs
├ WSTrust13ResponseSerializer.cs
├ WSTrustBinding.cs
├ WSTrustBindingUsernameMixed.cs
├ WSTrustBindingWindows.cs
├ WSTrustClient.cs
├ WSTrustRequestBodyWriter.cs
└ WSTrustSerializationHelper.cs
37
38. SL.IdentityModel ライブラリの移植手順
1. プロジェクトを作成
• テンプレート
:Windows Phone クラスライブラリ(Visual C#)
• 名前
:(例)WP.IdentityModel とか
2. 参照設定の追加
• System.Runtime.Serialization
• System.ServiceModel
• System.Xml.Linq
3. SL.IdentityModel から ソースをひたすらコピペ
38
39. SL.IdentityModel を使用したアプリの作成
1. 必要情報の収集
AD FS のエンドポイント
https://<ADFSサーバー>/adfs/services/trust/13/usernamemixed
スコープ(ApplyTo、業務アプリの識別名)
(例)https://www.contoso.com/
2. 参照設定の追加
• 移植したライブラリのプロジェクトを選択
3. using の追加
• using SL.IdentityModel.Claims;
• using SL.IdentityModel.Protocols.WSTrust;
• using SL.IdentityModel.Services;
39
40. 4. 認証&セキュリティトークンの取得
WSTrustClient _client;
private void _btnLogin_Click(object sender, RoutedEventArgs e)
{ RequestST(); }
private void RequestST()
{
_client = new WSTrustClient( WS-Trustクライアントを作成
new WSTrustBindingUsernameMixed(),
new EndpointAddress("https://tfadfs.tf.com/adfs/services/trust/13/usernamemixed"),
new UsernameCredentials(< >, < >));
var rst = new RequestSecurityToken(WSTrust13Constants.KeyTypes.Bearer)
{
AppliesTo = new EndpointAddress("https://www.contoso.com/")
};
_client.IssueCompleted += client_IssueCompleted;
_client.IssueAsync(rst); セキュリティトークンを非同期で要求
} 非同期で実行
40
41. void client_IssueCompleted(object sender, IssueCompletedEventArgs e)
{
_client.IssueCompleted -= client_IssueCompleted;
if (e.Error == null)
{
Globals.RSTR = e.Result;
MessageBox.Show( e.Result );
}
else
{
MessageBox.Show(e.Error.Message);
_btnLogin.IsEnabled = true;
}
}
41
42. セキュリティトークン(SAML アサーション)
<saml:Assertion MajorVersion="1" MinorVersion="1" AssertionID="_b6d37acb-381c-4160-a712-d3eceee44ef5"
Issuer="http://tfadfs.tf.com/adfs/services/trust" IssueInstant="2011-11-28T00:16:18.445Z"
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion">
<saml:Conditions NotBefore="2011-11-28T00:16:18.445Z" NotOnOrAfter="2011-11-28T01:16:18.445Z“>
<saml:AudienceRestrictionCondition>
<saml:Audience>https://www.contoso.com/</saml:Audience>
</saml:AudienceRestrictionCondition></saml:Conditions>
<saml:AttributeStatement>
<saml:Subject><saml:SubjectConfirmation>
<saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod></saml:SubjectConfirmation></saml:Subj
ect>
<saml:Attribute AttributeName="name" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims">
<saml:AttributeValue>西城秀樹</saml:AttributeValue></saml:Attribute>
<saml:Attribute AttributeName="emailaddress" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims">
<saml:AttributeValue>administrator@tf.com</saml:AttributeValue></saml:Attribute>
<saml:Attribute AttributeName="companyname" AttributeNamespace="http://schemas.tf.com">
<saml:AttributeValue>マイクロソフト</saml:AttributeValue></saml:Attribute>
<saml:Attribute AttributeName="department"AttributeNamespace="http://shcemas.tf.com">
<saml:AttributeValue>エバンジェリズムグループ</saml:AttributeValue></saml:Attribute></saml:AttributeStatement>
<saml:AuthenticationStatement AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:password" AuthenticationInstant="2011-11-
28T00:16:18.023Z">
<saml:Subject><saml:SubjectConfirmation><saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMetho
d></saml:SubjectConfirmation></saml:Subject></saml:AuthenticationStatement>
42
43. つづき
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
<ds:Reference URI="#_b6d37acb-381c-4160-a712-d3eceee44ef5">
<ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /></ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
<ds:DigestValue>mT+IdNIJq6No0jKKX034keFNO+0HZ3dIbnOrDnzfnI4=</ds:DigestValue></ds:Reference></ds:SignedInfo>
<ds:SignatureValue>fQ/ju362tt3EGKAMOtlfFwNAa7+dZoLftbNv1wyFjkytnPaD/BlxASXkDf2KeyBG8lxIpPDBTJFczME8A3gpHKBLuFIlURldx4V5ZuVkxz
ltLqjInHs/ectAzbagSHhDVYlRuo3F8zGoV2YFH4ZHme1snqPk0ArB60W5vh8jnAvmN7VsMovmmwPupMc5d4WLeXKH7/2Piz8Q2gM2sQb818lPhYzP9V80gJPPyDX
6gbbn+QUjcnITv8nohZOutophufy54498Ul6EnBfFuEUToaZZCVfh6O5NaO/gXHp4XvNgWkRNbNM1IVYBHiOrQyTPrVrccLpYKMxed1j3yJS/Nw==</ds:Signatu
reValue>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<X509Data>
<X509Certificate>MIIC1jCCAb6gAwIBAgIQX4B1j9QgNZ9GI3IsMJ/+vTANBgkqhkiG9w0BAQsFADAnMSUwIwYDVQQDExxBREZTIFNpZ25pbmcgLSB0ZmFkZnMu
dGYuY29tMB4XDTExMDQxNTA1NDIwM1oXDTEyMDQxNDA1NDIwM1owJzElMCMGA1UEAxMcQURGUyBTaWduaW5nIC0gdGZhZGZzLnRmLmNvbTCCASIwDQYJKoZIhvcNA
QEBBQADggEPADCCAQoCggEBALcp//XyPz6m9F5ok4ebtuz7XsIdesuvlze5OgN2FD4PkAykETXHRgeheAq1TtbTN/nIiTy11kKgEAseyUSfvMGJarf49vui+zNcy3
7t+tbrBGdx+MRhuncTb7+O8FKJ3Wg/q9h8e10hq3VeEoxhzd4Ghdl1R4DfJYf10PztfFeQPvoD3FJNgca7v1BB1gRtUEEykmJvSoZFt18mhk1l+9Bsk5SJyEZaZc4
M99ubqriVzzgDMZBa02+9Y6nmyy0P+sNrPnMSg031IulcGH+Zp8/W2B2ojHx3HisNkhYc8cQPYtLVoYanZ/qLG6hdqphM5TFi67QubdqclAE7MAoOx50CAwEAATAN
BgkqhkiG9w0BAQsFAAOCAQEAsU3E1uCieRjMAeVel29h9/oHLXy8hoGiy7iG3cgQBysA3Mlm3BjrLII4ze2JEZ74U8t5dk4K3K04emDuy4JhKpOP/iZXRN56UEuhI
idFfsHi/k9PLXPEgG1AJnueK52u71xj8noyPJ1EsYwVWTqm5emN5CVDEpJtPFJmsdrBviChFaOO9XURrz2rcp+TAt56cDJKFqj39aKv5YAYWBiSj0UP5cSnXxI7F3
lk7kNS19L2HdhPliXFoXI+doQ6ynOJrVUSqVMIbww7nOehWxI6TyWo9+A6TTl3LmpdNYyFYXJFjNI0JMKBm1U6yEvXEApI15LQ8IfJtSjPHoIPBHfSig==</X509C
ertificate>
</X509Data>
</KeyInfo>
</ds:Signature>
</saml:Assertion>
43
44. 5. クレームの抽出
var sb = new StringBuilder(128);
IClaimsPrincipal n = TokenHandler.Convert(Globals.RSTR);
n.ClaimsIdentity.Claims.ToList().ForEach(vc => sb.AppendFormat("{0}n {1}nn", vc.ClaimType, vc.Value));
MessageBox.Show(sb.ToString());
public static class TokenHandler
{
private static XNamespace ASSERTION_NAMESPACE = "urn:oasis:names:tc:SAML:1.0:assertion";
private const string CLAIM_VALUE_TYPE = "http://www.w3.org/2001/XMLSchema#string"; // bit of a hack
public static IClaimsPrincipal Convert(RequestSecurityTokenResponse rstr)
{
return new ClaimsPrincipal( GetClaimsIdentity( rstr ) );
}
private static ClaimsIdentity GetClaimsIdentity(RequestSecurityTokenResponse rstr)
{
次ページ
}
}
44
45. private static ClaimsIdentity GetClaimsIdentity( RequestSecurityTokenResponse rstr )
{
XDocument responseDoc = XDocument.Parse(rstr.RequestedSecurityToken.RawToken);
XElement attStatement = responseDoc.Element(ASSERTION_NAMESPACE +
"Assertion").Element(ASSERTION_NAMESPACE + "AttributeStatement");
var issuer = responseDoc.Root.Attribute("Issuer").Value;
ClaimCollection claims = new ClaimCollection();
foreach (var c in attStatement.Elements(ASSERTION_NAMESPACE + "Attribute"))
{
string attrName = c.Attribute("AttributeName").Value;
string attrNamespace = c.Attribute("AttributeNamespace").Value;
string claimType = attrNamespace + "/" + attrName;
foreach (var val in c.Elements(ASSERTION_NAMESPACE + "AttributeValue"))
{
claims.Add(new Claim(issuer, issuer, claimType, val.Value, CLAIM_VALUE_TYPE));
}
}
return new ClaimsIdentity(claims);
}
45
46. スコープについて
• AD FS 上では「証明書利用者信頼」として定義されている
• セキュリティトークンを渡す相手(業務アプリ)のこと
• 定義されていないスコープにはセキュリティトークンは発行されない
AD FS AD DS
WS-Trust(SOAP)
① UserID/Password ② 認証
⑤ セキュリティトークン ③ 属性
④ 属性に署名
信頼
⑦ 認可
⑥ セキュリティトークン
業務アプリ
46
50. 資格情報の再利用
• 認証のために入力した資格情報(UserID/Password)は分離ストレージに保存して再利用す
ることが可能
• 保存の際には暗号化することが望ましい
ID/Password 入力
ID/Password を送信
認証結果
次回以降は起動したらすぐ
に認証開始
50
51. DPAPI を使用した暗号化/復号化
いったんByte型に変換してから暗号化する
using System.Text;
using System.Security.Cryptography;
//暗号化
byte[] PinByte = Encoding.UTF8.GetBytes(<文字列>);
byte[] ProtectedPinByte = ProtectedData.Protect(PinByte, null);
//復号化
byte[] PinByte = ProtectedData.Unprotect(ProtectedPinByte, null);
n = Encoding.UTF8.GetString(PinByte, 0, PinByte.Length);
51
52. 暗号化した文字列を参照するには
Base64 にエンコード
IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
if (store.FileExists(encryptpin.FilePath_username) )
{
MessageBox.Show(
System.Convert.ToBase64String(encryptpin.ReadPinFromFile(encryptpin.FilePath_username))
);
}
else
{
MessageBox.Show(" ");
}
52
53. ※WCFサービス が Active Directory の認証結果を受け入れる方法
セキュリティトークンに対応した
WCF サービスの作成方法
本日は解説いたしません
53
54. セキュリティトークンを受け取るメリット
WS-Trust(SOAP) AD FS AD DS
② 認証
• 情報の正当性が担保されている ① UserID/Password
• STS による署名 ⑤ セキュリティトークン ③ 属性
• STS との信頼関係 ④ 属性に署名
⑦ 認可
⑥ セキュリティトークン
• クレームによりユーザーを認可(承認)できる 業務アプリ
• AD グループのメンバーシップ
• 所属部署や役職 など アプリが固有に持つ必要が無い
• アプリケーションの動作に必要な情報を受け取れる
• 氏名
• メールアドレス など 取りに行く必要が無い
54
55. Identity Developer Training Kit 2010 April
http://www.microsoft.com/download/en/details.aspx?id=1434
7
EXERCISE 1:
USING WINDOWS IDENTITY FOUNDATION TO HANDLE
AUTHENTICATION AND AUTHORIZATION IN A WCF SERVICE
EXERCISE 2:
ACCEPTING TOKENS FROM AN ACTIVE DIRECTORY FEDERATION
SERVICES (ADFS) STS
EXERCISE 3:
INVOKING A WCF SERVICE ON THE BACKEND VIA DELEGATED
ACCESS
55
57. まとめ
• クラウドのミドルウェアは要注目です
• Windows Azure Connect
• Windows Azure AppFabric ACS
• Windows Azure Sync Service など
• AD FS は AD DS の安全装置でもあります
• アプリが直接 AD DS にアクセスするのを防げます
• この分野は「知ってる者勝ち」です
57
59. The information herein is for informational purposes only and represents the current view of
Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to
changing market conditions, it should not be interpreted to be a commitment on the part of
Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the
date of this presentation.
MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO
THE INFORMATION IN THIS PRESENTATION.
© 2011 Microsoft Corporation.
All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.