3

ACSサンプル4( http://claimsid.codeplex.com/から)をADFSプロジェクトのテンプレートとして使用しようとしています。ADFS認証済みサービスへのパッシブリクエストには問題はありません。サンプルでは、​​フェデレーションプロバイダーはカスタムSTSであり、サンプルは正常に機能します。

ここで、カスタムフェデレーションプロバイダー(サンプルのAdatum FP)を独自のADFSに置き換えたいと思います。

現在の設定は次のとおりです(名前空間は非表示)

  • ServiceClient:コンソールアプリケーション、サービスを呼び出します
  • サービス:WCF Webサービス、文字列を返す単一のメソッド。これはデフォルトです[サンプルのOrdertracking.Services]
  • Services.Authentication:カスタムIDプロバイダー。これはデフォルトです[サンプルのLitware.SimulatedIssuer]
  • ADFS:フェデレーションプロバイダー[例ではFederationProvider.Adatum]

ServiceClientはServicesを呼び出したいと考えており、構成からIP(Services.Authentication)からトークンを取得する必要があることを認識しています。次に、トークンはADFSに渡され、ADFSはトークンを検証して、新しいトークンをServiceClientに送り返します。newクライアントはFPトークンをサービスに渡し、サービス(ADFSの依存側)はトークンをADFSに対して検証し、サービスメソッドを実行します。

問題:

例のSTSをADFSに置き換えると、統合が壊れているようです。IPからトークンを正しく取得しているようですが、IPトークンをADFSに渡すときに問題が発生しています。オーディエンスURIに問題があるようですが、追加しました

https://'adfs fqdn' / adfs / services / Trust / 13 / IssuedTokenMixedSymmetricBasic256

クライアント例外 このInnerExceptionInnerException{"ID3242:セキュリティトークンを認証または承認できませんでした。"}を使用して、クライアントでMessageSecurityExceptionを取得します。

[System.ServiceModel.FaultException]: {"ID3242: The security token could not be authenticated or authorized."}
Data: {System.Collections.ListDictionaryInternal}
HelpLink: null
InnerException: null
Message: "ID3242: The security token could not be authenticated or authorized."
Source: null
StackTrace: null
TargetSite: null

ADFSデバッグログ

<TraceRecord xmlns="http://schemas.microsoft.com/2009/10/IdentityModel/TraceRecord" Severity="Error">
    <Description>Handled exception.</Description>
    <AppDomain>Microsoft.IdentityServer.ServiceHost.exe</AppDomain>
    <Exception>
        <ExceptionType>Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</ExceptionType>
        <Message>ID1038: The AudienceRestrictionCondition was not valid because the specified Audience is not present in AudienceUris. Audience: 'https://<adfs fqdn>/adfs/services/Trust/13/IssuedTokenMixedSymmetricBasic256'</Message>
        <StackTrace>
  at Microsoft.IdentityModel.Tokens.SamlSecurityTokenRequirement.ValidateAudienceRestriction(IList`1 allowedAudienceUris, IList`1 tokenAudiences) at Microsoft.IdentityModel.Tokens.Saml2.Saml2SecurityTokenHandler.ValidateConditions(Saml2Conditions conditions, Boolean enforceAudienceRestriction) at Microsoft.IdentityModel.Tokens.Saml2.Saml2SecurityTokenHandler.ValidateToken(SecurityToken token) at Microsoft.IdentityServer.Service.Tokens.MSISSaml2TokenHandler.ValidateToken(SecurityToken token) at Microsoft.IdentityModel.Tokens.WrappedSaml2SecurityTokenAuthenticator.ValidateTokenCore(SecurityToken token) at System.IdentityModel.Selectors.SecurityTokenAuthenticator.ValidateToken(SecurityToken token) at Microsoft.IdentityModel.Tokens.WrappedSamlSecurityTokenAuthenticator.ValidateTokenCore(SecurityToken token) at System.IdentityModel.Selectors.SecurityTokenAuthenticator.ValidateToken(SecurityToken token) at System.ServiceModel.Security.ReceiveSecurityHeader.ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver, IList`1 allowedTokenAuthenticators, SecurityTokenAuthenticator&amp;amp; usedTokenAuthenticator) at
  ....
        </StackTrace>
    </Exception>
</TraceRecord>

IPWeb.configにオーディエンスURIを追加しました。

<audienceUris mode="Always">
    <add value="https://<adfs fqdn>/adfs/services/Trust/13/IssuedTokenMixedSymmetricBasic256" />
</audienceUris>

必要に応じて、追加の構成ファイルとADFS構成のスクリーンショットを投稿できます。

4

2 に答える 2

5

これには少し手間がかかりましたが、ようやく問題を解決しました。これを構成する代わりに、コードで接続を構築しました。クライアント構成のどこかにエラーがあったのではないかと思います。

これを試している人へのアドバイス-最初にコードで接続を構築します。XML構成は、操作が少し難しいです。

leastprivilege.comでいくつかのサンプルコードが見つかりました

private static SecurityToken GetIdPToken()
    {

        var factory = new WSTrustChannelFactory(
            new UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential),
            "https://systemidp.dk/Issuer.svc");
        factory.TrustVersion = TrustVersion.WSTrust13;

        factory.Credentials.UserName.UserName = "LITWARE\\rick";
        factory.Credentials.UserName.Password = "thisPasswordIsNotChecked";

        var rst = new RequestSecurityToken
        {
            RequestType = WSTrust13Constants.RequestTypes.Issue,
            AppliesTo = new EndpointAddress("https://adfsfqdn/adfs/services/trust"),
            KeyType = WSTrust13Constants.KeyTypes.Symmetric,
            ReplyTo = "https://adfsfqdn/adfs/services/trust/13/issuedtokenmixedsymmetricbasic256/"
        };
        factory.ConfigureChannelFactory();
        var channel = factory.CreateChannel();
        return channel.Issue(rst);
    }

    private static SecurityToken GetRSTSToken(SecurityToken idpToken)
    {
        var binding = new IssuedTokenWSTrustBinding();
        binding.SecurityMode = SecurityMode.TransportWithMessageCredential;

        var factory = new WSTrustChannelFactory(
            binding,
            "https://adfsfqdn/adfs/services/trust/13/issuedtokenmixedsymmetricbasic256/");
        factory.TrustVersion = TrustVersion.WSTrust13;
        factory.Credentials.SupportInteractive = false;

        var rst = new RequestSecurityToken
        {
            RequestType = WSTrust13Constants.RequestTypes.Issue,
            AppliesTo = new EndpointAddress("https://services.dk/WebService.svc"),
            KeyType = WSTrust13Constants.KeyTypes.Symmetric
        };

        factory.ConfigureChannelFactory();
        var channel = factory.CreateChannelWithIssuedToken(idpToken);
        return channel.Issue(rst);
    }

トークンを使用してWCF呼び出しを作成する

var ipdtoken = GetIdPToken();
var stsToken = GetRSTSToken(ipdtoken);
var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);
binding.Security.Message.EstablishSecurityContext = false;
var factory = new ChannelFactory<IWebService>(binding, "https://services.dk/WebService.svc");

factory.ConfigureChannelFactory();
factory.Credentials.SupportInteractive = false;

var serviceChannel = factory.CreateChannelWithIssuedToken(stsToken);

var s = serviceChannel.GetUserInformation();
于 2011-10-25T08:46:31.490 に答える
0

IPのaudienceUri構成は正常に見えます。ADFSはID3242障害を引き起こしているものだと思います。ADFSサーバーのClaimProviderTrustsでIPが正しく構成されていることを確認できますか?

IPのフェデレーションメタデータが手元にある場合は、ADFSで再作成することもできます。

于 2011-10-24T00:34:00.593 に答える