このトピックでは、フェデレーション セキュリティの概念の概要について説明します。 また、フェデレーション セキュリティ アーキテクチャの展開に関する Windows Communication Foundation (WCF) のサポートについても説明します。 フェデレーションを示すサンプル アプリケーションについては、「 フェデレーション サンプル」を参照してください。
フェデレーション セキュリティの定義
フェデレーション セキュリティを使用すると、クライアントがアクセスしているサービスと、関連付けられている認証と承認の手順を完全に分離できます。 フェデレーション セキュリティにより、さまざまな信頼領域の複数のシステム、ネットワーク、および組織間のコラボレーションも可能になります。
WCF では、フェデレーション セキュリティを使用する分散システムの構築と展開がサポートされています。
フェデレーション セキュリティ アーキテクチャの要素
フェデレーション セキュリティ アーキテクチャには、次の表に示すように、3 つの重要な要素があります。
要素 | 説明 |
---|---|
ドメイン/領域 | 単一のセキュリティ管理または信頼の単位。 一般的なドメインには、1 つの組織が含まれる場合があります。 |
フェデレーション | 信頼を確立したドメインのコレクション。 信頼のレベルは異なる場合がありますが、通常は認証が含まれており、ほとんどの場合、承認が含まれます。 一般的なフェデレーションには、一連のリソースへの共有アクセスに対する信頼を確立している多数の組織が含まれる場合があります。 |
セキュリティ トークン サービス (STS) | セキュリティ トークンを発行する Web サービス。つまり、信頼できる証拠に基づいて、サービスを信頼する任意の相手に対してアサーションを行います。 これにより、ドメイン間の信頼ブローカーの基礎が形成されます。 |
シナリオ例
次の図は、フェデレーション セキュリティの例を示しています。
このシナリオには、A と B の 2 つの組織が含まれます。組織 B には、組織内の一部のユーザーが貴重な Web リソース (Web サービス) を持っています。
注
このセクションでは、 リソース、 サービス、 Web サービス という用語を同じ意味で使用します。
通常、組織 B では、組織 A のユーザーがサービスにアクセスする前に、何らかの有効な認証形式を提供する必要があります。 さらに、組織では、問題の特定のリソースへのアクセスをユーザーに許可する必要がある場合もあります。 この問題に対処し、組織 A のユーザーが組織 B のリソースにアクセスできるようにする方法の 1 つは次のとおりです。
組織 A のユーザーは、自分の資格情報 (ユーザー名とパスワード) を組織 B に登録します。
リソース アクセス中に、組織 A のユーザーは資格情報を組織 B に提示し、リソースにアクセスする前に認証されます。
この方法には、次の 3 つの重要な欠点があります。
組織 B は、ローカル ユーザーの資格情報を管理するだけでなく、組織 A のユーザーの資格情報を管理する必要があります。
組織 A のユーザーは、組織 A 内のリソースにアクセスするために通常使用する資格情報とは別に、追加の資格情報セット (つまり、追加のユーザー名とパスワードを記憶する) を維持する必要があります。これは通常、セキュリティ対策として、複数のサービス サイトで同じユーザー名とパスワードを使用する方法を推奨します。
組織 B のリソースが何らかの価値であると認識する組織が増えるにつれて、アーキテクチャはスケーリングされません。
前述の欠点に対処する別の方法は、フェデレーション セキュリティを採用することです。 このアプローチでは、組織 A と B が信頼関係を確立し、セキュリティ トークン サービス (STS) を使用して確立された信頼の仲介を可能にします。
フェデレーション セキュリティ アーキテクチャでは、組織 A のユーザーは、組織 B の Web サービスにアクセスする場合、組織 B の STS から有効なセキュリティ トークンを提示する必要があることを知っています。このトークンは、特定のサービスへのアクセスを認証および承認します。
STS B に接続すると、ユーザーは STS に関連付けられているポリシーから別のレベルの間接参照を受け取ります。 STS B がセキュリティ トークンを発行する前に、STS A (つまり、クライアント信頼領域) から有効なセキュリティ トークンを提示する必要があります。 これは、2 つの組織間で確立された信頼関係の共同作成であり、組織 B が組織 A のユーザーの ID を管理する必要がないことを意味します。実際には、STS B には通常、null issuerAddress
と issuerMetadataAddress
があります。 詳細については、「 方法: ローカル発行者を構成する」を参照してください。 その場合、クライアントはローカル ポリシーを参照して STS A を見つけます。この構成は ホーム領域フェデレーション と呼ばれ、STS B は STS A に関する情報を保持する必要がないため、スケーリングが向上します。
その後、ユーザーは組織 A の STS に連絡し、組織 A 内の他のリソースへのアクセスに通常使用する認証資格情報を提示してセキュリティ トークンを取得します。これにより、ユーザーが複数の資格情報セットを維持したり、複数のサービス サイトで同じ資格情報のセットを使用したりする必要があるという問題も軽減されます。
ユーザーが STS A からセキュリティ トークンを取得すると、STS B にトークンを提示します。組織 B は、ユーザーの要求の承認を実行し、独自のセキュリティ トークンのセットからユーザーにセキュリティ トークンを発行します。 その後、ユーザーは組織 B のリソースにトークンを提示し、サービスにアクセスできます。
WCF でのフェデレーション セキュリティのサポート
WCF では、 <wsFederationHttpBinding> を介してフェデレーション セキュリティ アーキテクチャを展開するためのターンキー サポートが提供されます。
<wsFederationHttpBinding> 要素は、要求/応答通信スタイルの基になるトランスポート メカニズムとして HTTP を使用し、エンコード用のワイヤ形式としてテキストと XML を使用する、安全で信頼性の高い相互運用可能なバインディングを提供します。
フェデレーション セキュリティ シナリオでの <wsFederationHttpBinding> の使用は、次のセクションで説明するように、論理的に独立した 2 つのフェーズに分離できます。
フェーズ 1: 設計フェーズ
設計フェーズ中、クライアントは ServiceModel メタデータ ユーティリティ ツール (Svcutil.exe) を使用して、サービス エンドポイントが公開するポリシーを読み取り、サービスの認証と承認の要件を収集します。 適切なプロキシは、クライアントで次のフェデレーション セキュリティ通信パターンを作成するために構築されます。
クライアント信頼領域の STS からセキュリティ トークンを取得します。
サービス信頼領域の STS にトークンを提示します。
サービス信頼領域の STS からセキュリティ トークンを取得します。
サービスにアクセスするためのトークンをサービスに提示します。
第 2 フェーズ : 実行時
実行時フェーズでは、クライアントは WCF クライアント クラスのオブジェクトをインスタンス化し、WCF クライアントを使用して呼び出しを行います。 WCF の基になるフレームワークは、フェデレーション セキュリティ通信パターンで前述の手順を処理し、クライアントがサービスをシームレスに使用できるようにします。
WCF を使用したサンプル実装
次の図は、WCF からのネイティブ サポートを使用したフェデレーション セキュリティ アーキテクチャの実装例を示しています。
MyService の例
サービス MyService
は、 MyServiceEndpoint
を介して単一のエンドポイントを公開します。 次の図は、エンドポイントに関連付けられているアドレス、バインディング、およびコントラクトを示しています。
サービス エンドポイント MyServiceEndpoint
では、<wsFederationHttpBinding> を使用し、STS B によって発行されたaccessAuthorized
要求を含む有効なセキュリティ アサーション マークアップ言語 (SAML) トークンが必要です。これは、サービス構成で宣言によって指定されます。
<system.serviceModel>
<services>
<service type="FederationSample.MyService"
behaviorConfiguration='MyServiceBehavior'>
<endpoint address=""
binding=" wsFederationHttpBinding"
bindingConfiguration='MyServiceBinding'
contract="Federation.IMyService" />
</service>
</services>
<bindings>
<wsFederationHttpBinding>
<!-- This is the binding used by MyService. It redirects
clients to STS-B. -->
<binding name='MyServiceBinding'>
<security mode="Message">
<message issuedTokenType=
"http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1">
<issuer address="http://localhost/FederationSample/STS-B/STS.svc" />
<issuerMetadata
address=
"http://localhost/FederationSample/STS-B/STS.svc/mex" />
<requiredClaimTypes>
<add claimType="http://tempuri.org:accessAuthorized" />
</requiredClaimTypes>
</message>
</security>
</binding>
</wsFederationHttpBinding>
</bindings>
<behaviors>
<behavior name='MyServiceBehavior'>
<serviceAuthorization
operationRequirementType="FederationSample.MyServiceOperationRequirement, MyService" />
<serviceCredentials>
<serviceCertificate findValue="CN=FederationSample.com"
x509FindType="FindBySubjectDistinguishedName"
storeLocation='LocalMachine'
storeName='My' />
</serviceCredentials>
</behavior>
</behaviors>
</system.serviceModel>
注
MyService
に必要とされる要求については、慎重に注意を払うべき点があります。 2 番目の図は、 MyService
に accessAuthorized
要求を含む SAML トークンが必要であることを示しています。 より正確に言えば、これは MyService
に必要な要求の種類を指定します。 この要求の種類の完全修飾名は、(関連付けられた名前空間と共に) http://tempuri.org:accessAuthorized
され、サービス構成ファイルで使用されます。 この要求の値は、この要求の存在を示し、STS B によって true
に設定されていると見なされます。
実行時に、このポリシーは、MyServiceOperationRequirement
の一部として実装されるMyService
クラスによって適用されます。
using System.Collections.Generic;
using System.IdentityModel.Claims;
using System.IdentityModel.Policy;
using System.IdentityModel.Tokens;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
Imports System.Collections.Generic
Imports System.IdentityModel.Claims
Imports System.IdentityModel.Policy
Imports System.IdentityModel.Tokens
Imports System.Security.Cryptography.X509Certificates
Imports System.ServiceModel
Imports System.ServiceModel.Channels
Imports System.ServiceModel.Security.Tokens
Imports System.Text
public class myServiceAuthorizationManager : ServiceAuthorizationManager
{
// Override the CheckAccess method to enforce access control requirements.
public override bool CheckAccess(OperationContext operationContext)
{
AuthorizationContext authContext =
operationContext.ServiceSecurityContext.AuthorizationContext;
if (authContext.ClaimSets == null) return false;
if (authContext.ClaimSets.Count != 1) return false;
ClaimSet myClaimSet = authContext.ClaimSets[0];
if (!IssuedBySTS_B(myClaimSet)) return false;
if (myClaimSet.Count != 1) return false;
Claim myClaim = myClaimSet[0];
if (myClaim.ClaimType ==
"http://www.tmpuri.org:accessAuthorized")
{
string resource = myClaim.Resource as string;
if (resource == null) return false;
if (resource != "true") return false;
return true;
}
else
{
return false;
}
}
// This helper method checks whether SAML Token was issued by STS-B.
// It compares the Thumbprint Claim of the Issuer against the
// Certificate of STS-B.
private bool IssuedBySTS_B(ClaimSet myClaimSet)
{
ClaimSet issuerClaimSet = myClaimSet.Issuer;
if (issuerClaimSet == null) return false;
if (issuerClaimSet.Count != 1) return false;
Claim issuerClaim = issuerClaimSet[0];
if (issuerClaim.ClaimType != ClaimTypes.Thumbprint)
return false;
if (issuerClaim.Resource == null) return false;
byte[] claimThumbprint = (byte[])issuerClaim.Resource;
// It is assumed that stsB_Certificate is a variable of type
// X509Certificate2 that is initialized with the Certificate of
// STS-B.
X509Certificate2 stsB_Certificate = GetStsBCertificate();
byte[] certThumbprint = stsB_Certificate.GetCertHash();
if (claimThumbprint.Length != certThumbprint.Length)
return false;
for (int i = 0; i < claimThumbprint.Length; i++)
{
if (claimThumbprint[i] != certThumbprint[i]) return false;
}
return true;
}
Public Class myServiceAuthorizationManager
Inherits ServiceAuthorizationManager
' Override the CheckAccess method to enforce access control requirements.
Public Overloads Overrides Function CheckAccess(ByVal operationContext As OperationContext) As Boolean
Dim authContext = operationContext.ServiceSecurityContext.AuthorizationContext
If authContext.ClaimSets Is Nothing Then
Return False
End If
If authContext.ClaimSets.Count <> 1 Then
Return False
End If
Dim myClaimSet = authContext.ClaimSets(0)
If Not IssuedBySTS_B(myClaimSet) Then
Return False
End If
If myClaimSet.Count <> 1 Then
Return False
End If
Dim myClaim = myClaimSet(0)
If myClaim.ClaimType = "http://www.tmpuri.org:accessAuthorized" Then
Dim resource = TryCast(myClaim.Resource, String)
If resource Is Nothing Then
Return False
End If
If resource <> "true" Then
Return False
End If
Return True
Else
Return False
End If
End Function
' This helper method checks whether SAML Token was issued by STS-B.
' It compares the Thumbprint Claim of the Issuer against the
' Certificate of STS-B.
Private Function IssuedBySTS_B(ByVal myClaimSet As ClaimSet) As Boolean
Dim issuerClaimSet = myClaimSet.Issuer
If issuerClaimSet Is Nothing Then
Return False
End If
If issuerClaimSet.Count <> 1 Then
Return False
End If
Dim issuerClaim = issuerClaimSet(0)
If issuerClaim.ClaimType <> ClaimTypes.Thumbprint Then
Return False
End If
If issuerClaim.Resource Is Nothing Then
Return False
End If
Dim claimThumbprint() = CType(issuerClaim.Resource, Byte())
' It is assumed that stsB_Certificate is a variable of type
' X509Certificate2 that is initialized with the Certificate of
' STS-B.
Dim stsB_Certificate = GetStsBCertificate()
Dim certThumbprint() = stsB_Certificate.GetCertHash()
If claimThumbprint.Length <> certThumbprint.Length Then
Return False
End If
For i = 0 To claimThumbprint.Length - 1
If claimThumbprint(i) <> certThumbprint(i) Then
Return False
End If
Next i
Return True
End Function
STS B
次の図は STS B を示しています。前述のように、セキュリティ トークン サービス (STS) も Web サービスであり、エンドポイントやポリシーなどを関連付けることができます。
STS B は、セキュリティ トークンの要求に使用できる STSEndpoint
と呼ばれる単一のエンドポイントを公開します。 具体的には、STS B は accessAuthorized
要求を使用して SAML トークンを発行します。これは、サービスにアクセスするために MyService
サービス サイトで提示できます。 ただし、STS B では、 userAuthenticated
要求を含む STS A によって発行された有効な SAML トークンを提示する必要があります。 これは STS 構成で宣言によって指定されます。
<system.serviceModel>
<services>
<service type="FederationSample.STS_B" behaviorConfiguration=
"STS-B_Behavior">
<endpoint address=""
binding="wsFederationHttpBinding"
bindingConfiguration='STS-B_Binding'
contract="FederationSample.ISts" />
</service>
</services>
<bindings>
<wsFederationHttpBinding>
<!-- This is the binding used by STS-B. It redirects clients to
STS-A. -->
<binding name='STS-B_Binding'>
<security mode='Message'>
<message issuedTokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1">
<issuer address='http://localhost/FederationSample/STS-A/STS.svc' />
<issuerMetadata address='http://localhost/FederationSample/STS-A/STS.svc/mex'/>
<requiredClaimTypes>
<add claimType='http://tempuri.org:userAuthenticated'/>
</requiredClaimTypes>
</message>
</security>
</binding>
</wsFederationHttpBinding>
</bindings>
<behaviors>
<behavior name='STS-B_Behavior'>
<serviceAuthorization operationRequirementType='FederationSample.STS_B_OperationRequirement, STS_B' />
<serviceCredentials>
<serviceCertificate findValue='CN=FederationSample.com'
x509FindType='FindBySubjectDistinguishedName'
storeLocation='LocalMachine'
storeName='My' />
</serviceCredentials>
</behavior>
</behaviors>
</system.serviceModel>
注
ここでも、 userAuthenticated
要求は STS B で必要な要求の種類です。この要求の種類の完全修飾名は、(関連付けられた名前空間と共に) http://tempuri.org:userAuthenticated
され、STS 構成ファイルで使用されます。 この要求の値は、この要求の存在を示し、STS A によって true
に設定されていると見なされます。
実行時に、 STS_B_OperationRequirement
クラスはこのポリシーを適用します。このポリシーは STS B の一部として実装されます。
public class STS_B_AuthorizationManager : ServiceAuthorizationManager
{
// Override AccessCheck to enforce access control requirements.
public override bool CheckAccess(OperationContext operationContext)
{
AuthorizationContext authContext =
operationContext.ServiceSecurityContext.AuthorizationContext;
if (authContext.ClaimSets == null) return false;
if (authContext.ClaimSets.Count != 1) return false;
ClaimSet myClaimSet = authContext.ClaimSets[0];
if (!IssuedBySTS_A(myClaimSet)) return false;
if (myClaimSet.Count != 1) return false;
Claim myClaim = myClaimSet[0];
if (myClaim.ClaimType == "http://www.tmpuri.org:userAuthenticated")
{
string resource = myClaim.Resource as string;
if (resource == null) return false;
if (resource != "true") return false;
return true;
}
else
{
return false;
}
}
// This helper method checks whether SAML Token was issued by STS-A.
// It compares the Thumbprint Claim of the Issuer against the
// Certificate of STS-A.
private bool IssuedBySTS_A(ClaimSet myClaimSet)
{
ClaimSet issuerClaimSet = myClaimSet.Issuer;
if (issuerClaimSet == null) return false;
if (issuerClaimSet.Count != 1) return false;
Claim issuerClaim = issuerClaimSet[0];
if (issuerClaim.ClaimType != ClaimTypes.Thumbprint) return false;
if (issuerClaim.Resource == null) return false;
byte[] claimThumbprint = (byte[])issuerClaim.Resource;
// It is assumed that stsA_Certificate is a variable of type X509Certificate2
// that is initialized with the Certificate of STS-A.
X509Certificate2 stsA_Certificate = GetStsACertificate();
byte[] certThumbprint = stsA_Certificate.GetCertHash();
if (claimThumbprint.Length != certThumbprint.Length) return false;
for (int i = 0; i < claimThumbprint.Length; i++)
{
if (claimThumbprint[i] != certThumbprint[i]) return false;
}
return true;
}
Public Class STS_B_AuthorizationManager
Inherits ServiceAuthorizationManager
' Override AccessCheck to enforce access control requirements.
Public Overloads Overrides Function CheckAccess(ByVal operationContext As OperationContext) As Boolean
Dim authContext = operationContext.ServiceSecurityContext.AuthorizationContext
If authContext.ClaimSets Is Nothing Then
Return False
End If
If authContext.ClaimSets.Count <> 1 Then
Return False
End If
Dim myClaimSet = authContext.ClaimSets(0)
If Not IssuedBySTS_A(myClaimSet) Then
Return False
End If
If myClaimSet.Count <> 1 Then
Return False
End If
Dim myClaim = myClaimSet(0)
If myClaim.ClaimType = "http://www.tmpuri.org:userAuthenticated" Then
Dim resource = TryCast(myClaim.Resource, String)
If resource Is Nothing Then
Return False
End If
If resource <> "true" Then
Return False
End If
Return True
Else
Return False
End If
End Function
' This helper method checks whether SAML Token was issued by STS-A.
' It compares the Thumbprint Claim of the Issuer against the
' Certificate of STS-A.
Private Function IssuedBySTS_A(ByVal myClaimSet As ClaimSet) As Boolean
Dim issuerClaimSet = myClaimSet.Issuer
If issuerClaimSet Is Nothing Then
Return False
End If
If issuerClaimSet.Count <> 1 Then
Return False
End If
Dim issuerClaim = issuerClaimSet(0)
If issuerClaim.ClaimType <> ClaimTypes.Thumbprint Then
Return False
End If
If issuerClaim.Resource Is Nothing Then
Return False
End If
Dim claimThumbprint() = CType(issuerClaim.Resource, Byte())
' It is assumed that stsA_Certificate is a variable of type X509Certificate2
' that is initialized with the Certificate of STS-A.
Dim stsA_Certificate = GetStsACertificate()
Dim certThumbprint() = stsA_Certificate.GetCertHash()
If claimThumbprint.Length <> certThumbprint.Length Then
Return False
End If
For i = 0 To claimThumbprint.Length - 1
If claimThumbprint(i) <> certThumbprint(i) Then
Return False
End If
Next i
Return True
End Function
アクセス チェックが明確な場合、STS B は accessAuthorized
要求で SAML トークンを発行します。
// Create the list of SAML Attributes.
List<SamlAttribute> samlAttributes = new List<SamlAttribute>();
// Add the accessAuthorized claim.
List<string> strList = new List<string>();
strList.Add("true");
samlAttributes.Add(new SamlAttribute("http://www.tmpuri.org",
"accessAuthorized",
strList));
// Create the SAML token with the accessAuthorized claim. It is assumed that
// the method CreateSamlToken() is implemented as part of STS-B.
SamlSecurityToken samlToken = CreateSamlToken(
proofToken,
issuerToken,
samlConditions,
samlSubjectNameFormat,
samlSubjectEmailAddress,
samlAttributes);
' Create the list of SAML Attributes.
Dim samlAttributes As New List(Of SamlAttribute)()
' Add the accessAuthorized claim.
Dim strList As New List(Of String)()
strList.Add("true")
samlAttributes.Add(New SamlAttribute("http://www.tmpuri.org", "accessAuthorized", strList))
' Create the SAML token with the accessAuthorized claim. It is assumed that
' the method CreateSamlToken() is implemented as part of STS-B.
Dim samlToken = CreateSamlToken(proofToken, _
issuerToken, _
samlConditions, _
samlSubjectNameFormat, _
samlSubjectEmailAddress, _
samlAttributes)
STS A
次の図は STS A を示しています。
STS B と同様に、STS A もセキュリティ トークンを発行し、この目的のために単一のエンドポイントを公開する Web サービスです。 ただし、別のバインディング (wsHttpBinding
) を使用するため、ユーザーは有効な CardSpace に emailAddress
要求を提示する必要があります。 応答として、 userAuthenticated
要求で SAML トークンを発行します。 これは、サービス構成で宣言によって指定されます。
<system.serviceModel>
<services>
<service type="FederationSample.STS_A" behaviorConfiguration="STS-A_Behavior">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="STS-A_Binding"
contract="FederationSample.ISts">
<identity>
<certificateReference findValue="CN=FederationSample.com"
x509FindType="FindBySubjectDistinguishedName"
storeLocation="LocalMachine"
storeName="My" />
</identity>
</endpoint>
</service>
</services>
<bindings>
<wsHttpBinding>
<!-- This is the binding used by STS-A. It requires users to present
a CardSpace. -->
<binding name='STS-A_Binding'>
<security mode='Message'>
<message clientCredentialType="CardSpace" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<behavior name='STS-A_Behavior'>
<serviceAuthorization operationRequirementType=
"FederationSample.STS_A_OperationRequirement, STS_A" />
<serviceCredentials>
<serviceCertificate findValue="CN=FederationSample.com"
x509FindType='FindBySubjectDistinguishedName'
storeLocation='LocalMachine'
storeName='My' />
</serviceCredentials>
</behavior>
</behaviors>
</system.serviceModel>
実行時に、 STS_A_OperationRequirement
クラスはこのポリシーを適用します。このポリシーは STS A の一部として実装されます。
public class STS_A_AuthorizationManager : ServiceAuthorizationManager
{
// Override AccessCheck to enforce access control requirements.
public override bool CheckAccess(OperationContext operationContext)
{
AuthorizationContext authContext =
operationContext.ServiceSecurityContext.AuthorizationContext;
if (authContext.ClaimSets == null) return false;
if (authContext.ClaimSets.Count != 1) return false;
ClaimSet myClaimSet = authContext.ClaimSets[0];
if (myClaimSet.Count != 1) return false;
Claim myClaim = myClaimSet[0];
if ((myClaim.ClaimType ==
@"http://schemas.microsoft.com/ws/2005/05/identity/claims:EmailAddress") &&
(myClaim.Right == Rights.PossessProperty))
{
string emailAddress = myClaim.Resource as string;
if (emailAddress == null) return false;
if (!IsValidEmailAddress(emailAddress)) return false;
return true;
}
else
{
return false;
}
}
// This helper method performs a rudimentary check for whether
//a given email is valid.
private static bool IsValidEmailAddress(string emailAddress)
{
string[] splitEmail = emailAddress.Split('@');
if (splitEmail.Length != 2) return false;
if (!splitEmail[1].Contains(".")) return false;
return true;
}
}
Public Class STS_A_AuthorizationManager
Inherits ServiceAuthorizationManager
' Override AccessCheck to enforce access control requirements.
Public Overloads Overrides Function CheckAccess(ByVal operationContext As OperationContext) As Boolean
Dim authContext = operationContext.ServiceSecurityContext.AuthorizationContext
If authContext.ClaimSets Is Nothing Then
Return False
End If
If authContext.ClaimSets.Count <> 1 Then
Return False
End If
Dim myClaimSet = authContext.ClaimSets(0)
If myClaimSet.Count <> 1 Then
Return False
End If
Dim myClaim = myClaimSet(0)
If myClaim.ClaimType = "http://schemas.microsoft.com/ws/2005/05/identity/claims:EmailAddress" AndAlso myClaim.Right = Rights.PossessProperty Then
Dim emailAddress = TryCast(myClaim.Resource, String)
If emailAddress Is Nothing Then
Return False
End If
If Not IsValidEmailAddress(emailAddress) Then
Return False
End If
Return True
Else
Return False
End If
End Function
' This helper method performs a rudimentary check for whether
'a given email is valid.
Private Shared Function IsValidEmailAddress(ByVal emailAddress As String) As Boolean
Dim splitEmail() = emailAddress.Split("@"c)
If splitEmail.Length <> 2 Then
Return False
End If
If Not splitEmail(1).Contains(".") Then
Return False
End If
Return True
End Function
End Class
アクセスが true
されている場合、STS A は要求を含む SAML トークン userAuthenticated
発行します。
// Create the list of SAML Attributes.
List<SamlAttribute> samlAttributes = new List<SamlAttribute>();
// Add the userAuthenticated claim.
List<string> strList = new List<string>();
strList.Add("true");
SamlAttribute mySamlAttribute = new SamlAttribute("http://www.tmpuri.org",
"userAuthenticated", strList);
samlAttributes.Add(mySamlAttribute);
// Create the SAML token with the userAuthenticated claim. It is assumed that
// the method CreateSamlToken() is implemented as part of STS-A.
SamlSecurityToken samlToken = CreateSamlToken(
proofToken,
issuerToken,
samlConditions,
samlSubjectNameFormat,
samlSubjectEmailAddress,
samlAttributes);
' Create the list of SAML Attributes.
Dim samlAttributes As New List(Of SamlAttribute)()
' Add the userAuthenticated claim.
Dim strList As New List(Of String)()
strList.Add("true")
Dim mySamlAttribute As New SamlAttribute("http://www.tmpuri.org", _
"userAuthenticated", _
strList)
samlAttributes.Add(mySamlAttribute)
' Create the SAML token with the userAuthenticated claim. It is assumed that
' the method CreateSamlToken() is implemented as part of STS-A.
Dim samlToken = CreateSamlToken(proofToken, issuerToken, samlConditions, _
samlSubjectNameFormat, _
samlSubjectEmailAddress, _
samlAttributes)
組織 A のクライアント
次の図は、組織 A のクライアントと、 MyService
サービス呼び出しを行う手順を示しています。 その他の機能コンポーネントも完全のために含まれています。
概要
フェデレーション セキュリティは、責任を完全に分担し、セキュリティで保護されたスケーラブルなサービス アーキテクチャの構築に役立ちます。 WCF は、分散アプリケーションを構築および展開するためのプラットフォームとして、フェデレーション セキュリティを実装するためのネイティブ サポートを提供します。