3

コードで完全な AFDS ログイン アクションを実行する必要があります。ユーザーを ADFS ログイン ページにリダイレクトできません。ユーザーはカスタム認証メカニズムを使用して既に認証されており、同じ資格情報を使用して ADFS を認証します。これにより、SAP EP への SSO が有効になります。

ADFS から SAML トークンを正常に取得できますが、SAP はアウト オブ ボックス認証しか処理できないようです。したがって、セッション全体を認証する必要があります。

これは私が今持っているものです:

トークンを取得します。

            var binding = new WS2007HttpBinding();
            binding.Security.Message.EstablishSecurityContext = false;
            binding.Security.Message.NegotiateServiceCredential = false;
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
            binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
            binding.Security.Mode = SecurityMode.TransportWithMessageCredential;

            var trustChannelFactory = new WSTrustChannelFactory(binding, new EndpointAddress(AppSettings.AdfsUrl));
            trustChannelFactory.TrustVersion = TrustVersion.WSTrust13;
            trustChannelFactory.Credentials.UserName.UserName = user.UserName;
            trustChannelFactory.Credentials.UserName.Password = PasswordService.Decrypt(user.UserPassword, user.UserID.ToString(CultureInfo.InvariantCulture));
            trustChannelFactory.ConfigureChannelFactory();

            // Create issuance issuance and get security token
            var requestToken = new RequestSecurityToken(WSTrust13Constants.RequestTypes.Issue);
            requestToken.AppliesTo = new EndpointAddress(AppSettings.ServicePortalUrl);
            requestToken.KeyType = WSTrust13Constants.KeyTypes.Bearer;
            var tokenClient = (WSTrustChannel) trustChannelFactory.CreateChannel();
            var token = tokenClient.Issue(requestToken) as GenericXmlSecurityToken;

            return token;

そして、SAP ポータルにリダイレクトする前に、おそらくユーザー プリンシパルを HttpContext に入れることができるように、クレームを取得しようとしました。(ロングショット)

        var tokenHandlers = new SecurityTokenHandlerCollection(new SecurityTokenHandler[] { new SamlSecurityTokenHandler() });
        tokenHandlers.First().Configuration.AudienceRestriction.AudienceMode = AudienceUriMode.Never;
        tokenHandlers.First().Configuration.CertificateValidationMode = X509CertificateValidationMode.None;
        tokenHandlers.Configuration.CertificateValidationMode = X509CertificateValidationMode.None;

        var trusted = new TrustedIssuerNameRegistry("*.domain.com");
        tokenHandlers.Configuration.IssuerNameRegistry = trusted;

        var samlToken = tokenHandlers.ReadToken(new XmlTextReader(new StringReader(token.TokenXml.OuterXml)));
        var claimsPrincipal = new ClaimsPrincipal(tokenHandlers.ValidateToken(samlToken).First());
        HttpContext.Current.User = claimsPrincipal;     

X509 証明書の検証エラーが発生し続けるため、これは機能しません。

私が試したこと:

  • SAML 署名を MYSAPSSO2 トークンとして提供する (ロング ショット、機能しませんでした)
  • SAP が HTTP コンテキストで IPrincipal を検索することがわかったので、ユーザー プリンシパルを HTTP コンテキストに配置します。(実行できません)
  • MSISAuthenticated cookie を設定しますが、値を取得する方法がわかりません (認証の瞬間の base64 タイムスタンプ?)

私が監督している明白な方法はありますか?基本的に、ADFS ログイン ページと同じ認証をコードで実行したいだけなので、ユーザーには 2 番目のログイン ページが表示されません。

4

0 に答える 0