Spring Security: requires-channel=“https” behind SSL accelerator

前端 未结 3 849
礼貌的吻别
礼貌的吻别 2020-12-15 11:54

We\'re using an F5 BIG-IP device to terminate SSL connections and connecting by plain HTTP to the application server with an spring enabled application. Also we configured F

相关标签:
3条回答
  • 2020-12-15 12:29

    I know this question/answer is 4 years old, but it help me to find the solution to my problem. But in modern Spring Boot applications, the fix is easier. Just add the following entry in your application.yaml:

    server.tomcat.protocol_header: x-forwarded-proto

    Mor information here: http://docs.spring.io/spring-boot/docs/current/reference/html/howto-security.html#howto-enable-https

    0 讨论(0)
  • 2020-12-15 12:30

    Subclass SecureChannelProcessor and InsecureChannelProcessor overriding decide(). You'll need to copy and paste some code, for example for Secure:

        @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());
                  }
              }
          }
        }
    

    Then set these ChannelProcessors on the ChannelDecisionManagerImpl bean using a BeanPostProcessor.

    0 讨论(0)
  • 2020-12-15 12:30

    Even simpler nowadays :

    server.use-forward-headers: true
    

    Enabled by default for Cloud Foundry and Heroku, but not for others such as AWS.

    Documentation (section 73.7) : https://docs.spring.io/spring-boot/docs/1.5.x/reference/html/howto-embedded-servlet-containers.html

    0 讨论(0)
提交回复
热议问题