Skip to content

Commit

Permalink
Set HttpOnly and Secure response
Browse files Browse the repository at this point in the history
#186292877
  • Loading branch information
enyia21 committed Oct 20, 2023
1 parent b66d205 commit 2fbf19a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package formflow.library.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.session.web.http.DefaultCookieSerializer;


/**
* Security features managed by Form-flow library
*/
@Configuration
@EnableWebSecurity
public class WebSecurityConfiguration {

/**
* Sets session cookies to HttpOny and Secure
* @return serializer with updated cookie settings
*/
@Bean
public DefaultCookieSerializer setDefaultSecurityCookie(){
DefaultCookieSerializer serializer = new DefaultCookieSerializer();
serializer.setUseSecureCookie(true);
serializer.setUseHttpOnlyCookie(true);
return serializer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,11 @@
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.session.web.http.DefaultCookieSerializer;
import org.springframework.web.filter.ForwardedHeaderFilter;

@Configuration
@EnableWebSecurity
public class SecurityConfiguration {

@Bean
public DefaultCookieSerializer setDefaultSecurityCookie(){
DefaultCookieSerializer serializer = new DefaultCookieSerializer();
serializer.setUseSecureCookie(true);
serializer.setUseHttpOnlyCookie(true);
return serializer;
}
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception {
httpSecurity.formLogin(AbstractHttpConfigurer::disable);
Expand Down

0 comments on commit 2fbf19a

Please sign in to comment.