File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
example/src/main/java/eu/webeid/example/config Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 2424
2525import org .apache .tomcat .util .http .Rfc6265CookieProcessor ;
2626import org .springframework .boot .web .embedded .tomcat .TomcatContextCustomizer ;
27+ import org .springframework .boot .web .servlet .ServletContextInitializer ;
2728import org .springframework .context .annotation .Bean ;
2829import org .springframework .context .annotation .Configuration ;
29- import org .springframework .web .servlet .config .annotation .WebMvcConfigurer ;
3030
3131@ Configuration
32- public class SameSiteCookieConfiguration implements WebMvcConfigurer {
32+ public class SameSiteCookieConfiguration {
3333
3434 @ Bean
35- public TomcatContextCustomizer configureSameSiteCookies () {
35+ public TomcatContextCustomizer sameSiteCustomizer () {
3636 return context -> {
37- final Rfc6265CookieProcessor cookieProcessor = new Rfc6265CookieProcessor ();
37+ Rfc6265CookieProcessor cookieProcessor = new Rfc6265CookieProcessor ();
3838 cookieProcessor .setSameSiteCookies ("lax" );
3939 context .setCookieProcessor (cookieProcessor );
4040 };
4141 }
42+
43+ @ Bean
44+ public ServletContextInitializer cookieFlagsInitializer () {
45+ return servletContext -> {
46+ servletContext .getSessionCookieConfig ().setSecure (true );
47+ servletContext .getSessionCookieConfig ().setHttpOnly (true );
48+ };
49+ }
4250}
You can’t perform that action at this time.
0 commit comments