Securing the backend
In Chapter 13, we implemented CRUD functionalities in our frontend using an unsecured backend. Now, it is time to switch on security for our backend and go back to the version that we created in Chapter 5, Securing Your Backend:
- Open your backend project with the Eclipse IDE and open the
SecurityConfig.java
file in the editor view. We have commented the security out and allowed everyone access to all endpoints. Now, we can remove that line and also remove the comments from the original version. Now, thefilterChain()
method of yourSecurityConfig.java
file should look like the following:@Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http.csrf((csrf) -> csrf.disable()) .cors(withDefaults()) .sessionManagement((sessionManagement) -> sessionManagement.sessionCreationPolicy( SessionCreationPolicy.STATELESS)) .authorizeHttpRequests( (authorizeHttpRequests) -> authorizeHttpRequests...