45 lines
1.4 KiB
Java
45 lines
1.4 KiB
Java
package ru.soune.nocopy.adminpanel.config;
|
|||
|
|
|
||
|
|
import org.springframework.context.annotation.Bean;
|
||
|
|
import org.springframework.context.annotation.Configuration;
|
||
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||
|
|
import org.springframework.web.cors.CorsConfiguration;
|
||
|
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||
|
|
import org.springframework.web.filter.CorsFilter;
|
||
|
|
import ru.soune.nocopy.adminpanel.handler.AdminUserHandler;
|
||
|
|
import ru.soune.nocopy.adminpanel.handler.RequestHandler;
|
||
|
|
|
||
|
|
import java.util.HashMap;
|
||
|
|
import java.util.Map;
|
||
|
|
|
||
|
|
@Configuration
|
||
|
|
public class AppConfig {
|
||
|
|
|
||
|
|
@Bean
|
||
|
|
PasswordEncoder passwordEncoder() {
|
||
|
|
return new BCryptPasswordEncoder();
|
||
|
|
}
|
||
|
|
|
||
|
|
@Bean
|
||
|
|
public CorsFilter corsFilter() {
|
||
|
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||
|
|
CorsConfiguration config = new CorsConfiguration();
|
||
|
|
config.addAllowedOrigin("*");
|
||
|
|
config.addAllowedMethod("*");
|
||
|
|
config.addAllowedHeader("*");
|
||
|
|
source.registerCorsConfiguration("/**", config);
|
||
|
|
|
||
|
|
return new CorsFilter(source);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Bean
|
||
|
|
public Map<Integer, RequestHandler> handlers(AdminUserHandler adminUserHandler) {
|
||
|
|
Map<Integer, RequestHandler> map = new HashMap<>();
|
||
|
|
map.put(100, adminUserHandler);
|
||
|
|
|
||
|
|
return map;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|