All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.infusers.core.config.InfusersConfiguration Maven / Gradle / Ivy

package com.infusers.core.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

@Configuration
public class InfusersConfiguration {
	@Bean
	public static BCryptPasswordEncoder passwordEncoder() {
		return new BCryptPasswordEncoder();
	}
	
	@Bean
	public CorsFilter corsFilter() {
		
		/*
		final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
		source.registerCorsConfiguration("/**", new CorsConfiguration().applyPermitDefaultValues());
		
        return new CorsFilter(source);
		*/
        
		final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
		
		CorsConfiguration config = new CorsConfiguration();
		//config.setAllowCredentials(true);
		//config.addAllowedOrigin("/**");
		//config.addAllowedOrigin("http://localhost:4201/");
		//config.addAllowedHeader("*");
		config.addAllowedMethod("*");
		config.applyPermitDefaultValues();
		
		source.registerCorsConfiguration("/**", config);
		//source.registerCorsConfiguration("http://localhost:4201/", config);
		
        return new CorsFilter(source);
        
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy