2012-04-19 34 views
0

次のシナリオでは、WCFで標準ソリューションを検索しようとしています。WCFカスタム認証 - トークン

2つのサービスがあります。 Service1はservice2に要求を送信します。私は彼の要求に対するservice2の応答の前に認証するために、service1が資格情報を送ることを望みます。

すべてのネットワークサービス間でsslを使用したり、証明書をコピーしたりする必要はありません。

これは私のソリューションです。

「セキュリティサービス」を1つ作成します。

Service1はセキュリティサービスに対して認証されます。

認証に成功すると、このセキュリティサービスはセキュリティサービスによって署名されたカスタムトークンをservice1に提供します。

サービス1は、このトークンをそれぞれの要求に添付します。

Service2はこのトークンを検証し、成功すると要求を処理します。

答えは、このメカニズムを実装するC#(WCF)の方法がある場合です。

おかげ

+0

この質問を参照してください:http://stackoverflow.com/questions/964433/how-to-add-a-custom-header-to-every-wcf-calls – Jaapjan

答えて

0

あなたがWCFサービスについて話している場合は、セキュリティの種類を確認してくださいWCF supports。それはNone、Transport、Message、TransportWithMessageCredential、TransportCredentialOnly、両方です。あなたは交通安全に関心がないと言った。したがって、メッセージのセキュリティはリストに残っています。

WCF supports the following credential types when you are using message level security: 

Windows. The client uses a Windows token representing the logged in user’s Windows identity. The service uses the credentials of the process identity or an SSL certificate. You will use this in the sample application that demonstrates the first scenario (internal self-hosted service). 
UserName. The client passes a user name and password to the service. Typically, the user will enter the user name and password in a login dialog box. The service can validate the user name and password using a Windows account or the ASP.NET membership provider. You will use this in the sample application that demonstrates the third scenario (public Web-hosted service). 
Certificate. The client uses an X.509 certificate and the service uses either that certificate or an SSL certificate. 
IssueToken. The client and service use the Secure Token Service, which issues tokens the client and service trust. Windows CardSpace uses the Secure Token Service. 
None. The service does not validate the client. 

あなたは言わなかったが、認証の種類を決定することが重要です、それはあなたがあなたのサービスをホストしようとしている方法です、特にサービス2. Windows認証は、内部自己ホスト型サービスのために良いですが、私は」何次それがあなたの事件であるとは確信していません。したがって、サービスがIISでホストされる場合は、ユーザー名が適しています。 digest authenticationのサポートが必要です。 Digest Authentication on a WCF REST Serviceを読んでください。そして、IISホスティングサービスでないか、代替ソリューションが必要な場合は、Security Token Serviceを使用することができます。しかし、最新のより良い解決策は、クレームベースの認証、あなたが他の答えで見つけることができるリンクです。

+0

独自のカスタム認証タイプを使用したいと思います。認証は、service1が認証サービスからトークンを要求した場合にのみ実行されます。 – fransua