8

F5 BIG-IP デバイスを使用して SSL 接続を終了し、Spring 対応アプリケーションを使用してプレーン HTTP でアプリケーション サーバーに接続しています。また、値として http または https を含む X-Forwarded-Proto ヘッダーを送信するように F5 を構成しました。

次に、インターセプト URL を構成して HTTPS を強制します。

<security:intercept-url pattern="/login.action" requires-channel="https" />

ただし、これはサーブレット コンテナーのプロトコル スキームが HTTPS の場合にのみ機能するため、HTTP ヘッダーを解釈する必要があります。

これを行う方法はありますか?

ありがとうサイモン

4

3 に答える 3

8

サブクラスの SecureChannelProcessorおよびInsecureChannelProcessorのオーバーライドdecide()。たとえばセキュアの場合、いくつかのコードをコピーして貼り付ける必要があります。

    @Override
    public void decide(FilterInvocation invocation, Collection<ConfigAttribute> config) throws IOException, ServletException {
      Assert.isTrue((invocation != null) && (config != null), 
                       "Nulls cannot be provided");

      for (ConfigAttribute attribute : config) {
          if (supports(attribute)) {
              if (invocation.getHttpRequest().
                      getHeader("X-Forwarded-Proto").equals("http")) {
                  entryPoint.commence(invocation.getRequest(),
                      invocation.getResponse());
              }
          }
      }
    }

次に、BeanPostProcessor を使用してChannelDecisionManagerImpl Bean にこれらの ChannelProcessors を設定します。

于 2011-07-18T13:48:18.963 に答える