@@ -26,10 +26,6 @@ import java.util.concurrent.TimeUnit;
|
||||
@EnableCaching
|
||||
public class ApplicationConfig {
|
||||
|
||||
// private final FileEntityRepository fileEntityRepository;
|
||||
|
||||
// private final FileUtil fileUtil;
|
||||
|
||||
@Bean
|
||||
PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
@@ -46,9 +42,6 @@ public class ApplicationConfig {
|
||||
AudioFilePathProvider audioFilePathProvider,
|
||||
DocumentLocalSearch documentLocalSearch) {
|
||||
|
||||
// List<FileProtector.FileInfo> initialFiles = loadProcessingFile();
|
||||
|
||||
//TODO инициализация файлов при создании
|
||||
return new com.vrt.NoCopyFileService(
|
||||
Collections.emptyList(),
|
||||
fileProvider,
|
||||
@@ -76,12 +69,5 @@ public class ApplicationConfig {
|
||||
|
||||
return cacheManager;
|
||||
}
|
||||
// private List<FileProtector.FileInfo> loadProcessingFile() {
|
||||
// List<FileEntity> byProtectionStatus =
|
||||
// fileEntityRepository.findByProtectionStatus(ProtectionStatus.PROCESSING);
|
||||
//
|
||||
// return byProtectionStatus.stream().map(fileEntity ->
|
||||
// fileUtil.createFileInfo(fileEntity, null)).toList();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -9,14 +9,33 @@ import java.util.Map;
|
||||
|
||||
@Configuration
|
||||
public class HandlerConfig {
|
||||
/*
|
||||
RegRequestHandler
|
||||
LoginRequestHandler
|
||||
FileUploadHandler
|
||||
FileEntityHandler
|
||||
ImageFoundRequestHandler
|
||||
VerifyRegisterUserHandler
|
||||
TariffHandler
|
||||
ReferralHandler
|
||||
ResetPasswordHandler
|
||||
MonitoringHandler
|
||||
GlobalSearchHandler
|
||||
ComplaintEntityHandler
|
||||
ViolationNotionHandler
|
||||
NotificationHandler
|
||||
TokenOperationHandler
|
||||
DockViewFileHandler
|
||||
*/
|
||||
|
||||
/*
|
||||
Убрать
|
||||
LogoutRequestHandler logoutHandler
|
||||
*/
|
||||
@Bean
|
||||
public Map<Integer, RequestHandler> handlers(
|
||||
RegRequestHandler reg,
|
||||
LoginRequestHandler login,
|
||||
FileUploadHandler upload,
|
||||
FileEntityHandler file,
|
||||
LogoutRequestHandler logoutHandler,
|
||||
ImageFoundRequestHandler imageFoundRequestHandler,
|
||||
VerifyRegisterUserHandler verifyRegisterUser,
|
||||
AuthRequestHandler authRequestHandler,
|
||||
@@ -42,11 +61,8 @@ public class HandlerConfig {
|
||||
DockViewFileHandler dockViewFileHandler
|
||||
) {
|
||||
Map<Integer, RequestHandler> map = new HashMap<>();
|
||||
map.put(20001, login);
|
||||
map.put(20002, reg);
|
||||
map.put(20004, upload);
|
||||
map.put(20005, file);
|
||||
map.put(20006, logoutHandler);
|
||||
map.put(20007, imageFoundRequestHandler);
|
||||
map.put(20008, authRequestHandler);
|
||||
map.put(20009, verifyRegisterUser);
|
||||
@@ -125,4 +141,17 @@ public class HandlerConfig {
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Map<Integer, RequestHandler> authHandler(
|
||||
RegRequestHandler reg,
|
||||
LoginRequestHandler login
|
||||
)
|
||||
{
|
||||
Map<Integer, RequestHandler> map = new HashMap<>();
|
||||
map.put(20001, login);
|
||||
map.put(20002, reg);
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package ru.soune.nocopy.configuration.security;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
import ru.soune.nocopy.util.JwtAuthFilter;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@RequiredArgsConstructor
|
||||
public class SecurityConfig {
|
||||
|
||||
private final JwtAuthFilter jwtAuthFilter;
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.csrf(AbstractHttpConfigurer::disable)
|
||||
.sessionManagement(session ->
|
||||
session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||
.authorizeHttpRequests(auth -> auth
|
||||
.requestMatchers("api/v{version}/files/public-download/**").permitAll() // логин, регистрация
|
||||
.requestMatchers("/api/files/public/**").permitAll()
|
||||
.requestMatchers("/api/auth/**").permitAll()
|
||||
.requestMatchers("/api/file/link/**").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
)
|
||||
.addFilterBefore(jwtAuthFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user