feat(security): add frontend host configuration property
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
	
		
	
		
			All checks were successful
		
		
	
	
This commit is contained in:
		
					parent
					
						
							
								2ff25f9897
							
						
					
				
			
			
				commit
				
					
						237005a7bd
					
				
			
		
					 1 changed files with 5 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
package de.szut.casino.security;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.annotation.Value;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
import org.springframework.security.config.Customizer;
 | 
			
		||||
| 
						 | 
				
			
			@ -17,6 +18,9 @@ import java.util.List;
 | 
			
		|||
@EnableWebSecurity
 | 
			
		||||
public class SecurityConfig {
 | 
			
		||||
 | 
			
		||||
    @Value("${app.frontend-host}")
 | 
			
		||||
    private String frontendHost;
 | 
			
		||||
 | 
			
		||||
    @Bean
 | 
			
		||||
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
 | 
			
		||||
        http
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +40,7 @@ public class SecurityConfig {
 | 
			
		|||
    @Bean
 | 
			
		||||
    public CorsConfigurationSource corsConfigurationSource() {
 | 
			
		||||
        CorsConfiguration configuration = new CorsConfiguration();
 | 
			
		||||
        configuration.setAllowedOrigins(List.of("http://localhost:4200"));
 | 
			
		||||
        configuration.setAllowedOrigins(List.of(this.frontendHost));
 | 
			
		||||
        configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"));
 | 
			
		||||
        configuration.setAllowedHeaders(Arrays.asList("authorization", "content-type", "x-auth-token", "Access-Control-Allow-Origin"));
 | 
			
		||||
        configuration.setExposedHeaders(List.of("x-auth-token"));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue