2011-07-18 30 views
7

私たちはF5 BIG-IPデバイスを使用して、SSL接続を終了し、プレーンHTTPによってアプリケーションサーバーに接続します。また、F5を設定して、値がhttpまたはhttpsのX-Forwarded-Protoヘッダーを送信します。Springセキュリティ:SSLアクセラレータの背後にあるrequire-channel = "https"

今、私たちは、インターセプトURLを設定することで、HTTPSを強制したいと思います:

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

しかし、これだけ作品サーブレットcontainterにおけるプロトコル方式がHTTPSであるので、我々は、HTTPヘッダを解釈する必要がある場合。

これを行うにはどのように任意のアイデア?

おかげdecide()をオーバーライド サイモン

答えて

8

サブクラスSecureChannelProcessorInsecureChannelProcessor。あなたはセキュアなため、たとえば、いくつかのコードをコピーして貼り付ける必要があります:

@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豆の上にこれらのChannelProcessorsを設定します。

1

私はこの質問/回答が4歳であることを知っていますが、私の問題の解決策を見つけるのに役立ちます。しかし、現代のSpring Bootアプリケーションでは、修正が簡単です。ここ

server.tomcat.protocol_header: x-forwarded-proto

Morの情報:ちょうどあなたのapplication.yamlに次のエントリを追加し、今日http://docs.spring.io/spring-boot/docs/current/reference/html/howto-security.html#howto-enable-https

+1

私はこれを試してみましたが、あなたが埋め込まれたTomcatインスタンスを使用して、外部のTomcatインスタンスへのWARとしてアプリケーションをデプロイしていない場合は機能しているようです。 –

関連する問題