(window.webpackJsonp=window.webpackJsonp||[]).push([[268],{694:function(t,e,r){"use strict";r.r(e);var a=r(56),n=Object(a.a)({},(function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[r("h1",{attrs:{id:"http"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#http"}},[t._v("#")]),t._v(" HTTP")]),t._v(" "),r("p",[t._v("All HTTP based communication should be protected "),r("RouterLink",{attrs:{to:"/features/exploits/http.html#http"}},[t._v("using TLS")]),t._v(".")],1),t._v(" "),r("p",[t._v("Below you can find details around Servlet specific features that assist with HTTPS usage.")]),t._v(" "),r("h2",{attrs:{id:"redirect-to-https"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#redirect-to-https"}},[t._v("#")]),t._v(" Redirect to HTTPS")]),t._v(" "),r("p",[t._v("If a client makes a request using HTTP rather than HTTPS, Spring Security can be configured to redirect to HTTPS.")]),t._v(" "),r("p",[t._v("For example, the following Java configuration will redirect any HTTP requests to HTTPS:")]),t._v(" "),r("p",[t._v("Example 1. Redirect to HTTPS")]),t._v(" "),r("p",[t._v("Java")]),t._v(" "),r("div",{staticClass:"language- extra-class"},[r("pre",{pre:!0,attrs:{class:"language-text"}},[r("code",[t._v("@Configuration\n@EnableWebSecurity\npublic class WebSecurityConfig extends\n\t\tWebSecurityConfigurerAdapter {\n\n\t@Override\n\tprotected void configure(HttpSecurity http) {\n\t\thttp\n\t\t\t// ...\n\t\t\t.requiresChannel(channel -> channel\n\t\t\t\t.anyRequest().requiresSecure()\n\t\t\t);\n\t}\n}\n")])])]),r("p",[t._v("Kotlin")]),t._v(" "),r("div",{staticClass:"language- extra-class"},[r("pre",{pre:!0,attrs:{class:"language-text"}},[r("code",[t._v('@Configuration\n@EnableWebSecurity\nclass SecurityConfig : WebSecurityConfigurerAdapter() {\n\n override fun configure(http: HttpSecurity) {\n http {\n // ...\n requiresChannel {\n secure(AnyRequestMatcher.INSTANCE, "REQUIRES_SECURE_CHANNEL")\n }\n }\n }\n}\n')])])]),r("p",[t._v("The following XML configuration will redirect all HTTP requests to HTTPS")]),t._v(" "),r("p",[t._v("Example 2. Redirect to HTTPS with XML Configuration")]),t._v(" "),r("div",{staticClass:"language- extra-class"},[r("pre",{pre:!0,attrs:{class:"language-text"}},[r("code",[t._v('\n\t\n...\n\n')])])]),r("h2",{attrs:{id:"strict-transport-security"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#strict-transport-security"}},[t._v("#")]),t._v(" Strict Transport Security")]),t._v(" "),r("p",[t._v("Spring Security provides support for "),r("RouterLink",{attrs:{to:"/en/spring-security/headers.html#servlet-headers-hsts"}},[t._v("Strict Transport Security")]),t._v(" and enables it by default.")],1),t._v(" "),r("h2",{attrs:{id:"proxy-server-configuration"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#proxy-server-configuration"}},[t._v("#")]),t._v(" Proxy Server Configuration")]),t._v(" "),r("p",[t._v("Spring Security "),r("RouterLink",{attrs:{to:"/features/exploits/http.html#http-proxy-server"}},[t._v("integrates with proxy servers")]),t._v(".")],1),t._v(" "),r("p",[r("RouterLink",{attrs:{to:"/en/spring-security/headers.html"}},[t._v("Security HTTP Response Headers")]),r("RouterLink",{attrs:{to:"/en/spring-security/firewall.html"}},[t._v("HttpFirewall")])],1)])}),[],!1,null,null,null);e.default=n.exports}}]);