Обновлен gradle и библиотеки
This commit is contained in:
24
build.gradle
24
build.gradle
@@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'org.springframework.boot' version '2.4.1'
|
id 'org.springframework.boot' version '2.6.3'
|
||||||
id 'java'
|
id 'java'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,19 +27,19 @@ dependencies {
|
|||||||
implementation "org.springframework.boot:spring-boot-starter-security"
|
implementation "org.springframework.boot:spring-boot-starter-security"
|
||||||
implementation "org.springframework.boot:spring-boot-starter-websocket"
|
implementation "org.springframework.boot:spring-boot-starter-websocket"
|
||||||
implementation 'org.springframework.session:spring-session-core'
|
implementation 'org.springframework.session:spring-session-core'
|
||||||
compile 'com.github.jmnarloch:modelmapper-spring-boot-starter:1.1.0'
|
implementation 'com.github.jmnarloch:modelmapper-spring-boot-starter:1.1.0'
|
||||||
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
|
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
|
||||||
compile group: 'commons-io', name: 'commons-io', version: '2.7'
|
implementation group: 'commons-io', name: 'commons-io', version: '2.11.0'
|
||||||
compile 'org.pcap4j:pcap4j-core:1.8.2'
|
implementation 'org.pcap4j:pcap4j-core:1.8.2'
|
||||||
compile 'org.pcap4j:pcap4j-packetfactory-static:1.8.2'
|
implementation 'org.pcap4j:pcap4j-packetfactory-static:1.8.2'
|
||||||
compile group: 'com.google.guava', name: 'guava', version: '30.1-jre'
|
implementation group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
|
||||||
compile group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.1'
|
implementation group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.1'
|
||||||
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.68'
|
implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69'
|
||||||
compile group: 'org.bouncycastle', name: 'bctls-jdk15on', version: '1.68'
|
implementation group: 'org.bouncycastle', name: 'bctls-jdk15on', version: '1.70'
|
||||||
compile group: 'org.modelmapper', name: 'modelmapper', version: '2.3.0'
|
implementation group: 'org.modelmapper', name: 'modelmapper', version: '2.4.5'
|
||||||
compileOnly 'org.projectlombok:lombok'
|
compileOnly 'org.projectlombok:lombok'
|
||||||
runtimeOnly 'org.springframework.boot:spring-boot-devtools'
|
runtimeOnly 'org.springframework.boot:spring-boot-devtools'
|
||||||
runtimeOnly 'org.postgresql:postgresql'
|
runtimeOnly 'org.postgresql:postgresql'
|
||||||
annotationProcessor 'org.projectlombok:lombok'
|
annotationProcessor 'org.projectlombok:lombok'
|
||||||
testCompile 'org.junit.jupiter:junit-jupiter:5.6.2'
|
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ RUN ./gradlew --no-daemon build -x test
|
|||||||
FROM adoptopenjdk/openjdk15:alpine-jre
|
FROM adoptopenjdk/openjdk15:alpine-jre
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apk --no-cache add libpcap
|
RUN apk --no-cache add libpcap
|
||||||
COPY --from=1 /tmp/compile/build/libs/packmate-*.jar app.jar
|
COPY --from=1 /tmp/compile/build/libs/packmate-*-SNAPSHOT.jar app.jar
|
||||||
EXPOSE 65000:65000
|
EXPOSE 65000:65000
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -1,25 +1,14 @@
|
|||||||
package ru.serega6531.packmate.configuration;
|
package ru.serega6531.packmate.configuration;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.pcap4j.core.PcapNativeException;
|
import org.pcap4j.core.PcapNativeException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.event.EventListener;
|
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.security.authentication.event.AuthenticationFailureBadCredentialsEvent;
|
|
||||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
|
||||||
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.configuration.WebSecurityConfigurerAdapter;
|
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
|
||||||
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
|
|
||||||
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
|
|
||||||
import ru.serega6531.packmate.WebSocketHandler;
|
|
||||||
import ru.serega6531.packmate.model.enums.CaptureMode;
|
import ru.serega6531.packmate.model.enums.CaptureMode;
|
||||||
import ru.serega6531.packmate.pcap.FilePcapWorker;
|
import ru.serega6531.packmate.pcap.FilePcapWorker;
|
||||||
import ru.serega6531.packmate.pcap.LivePcapWorker;
|
import ru.serega6531.packmate.pcap.LivePcapWorker;
|
||||||
@@ -32,25 +21,9 @@ import ru.serega6531.packmate.service.SubscriptionService;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@EnableWebSocket
|
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
@Slf4j
|
public class ApplicationConfiguration {
|
||||||
public class ApplicationConfiguration extends WebSecurityConfigurerAdapter implements WebSocketConfigurer {
|
|
||||||
|
|
||||||
@Value("${account-login}")
|
|
||||||
private String login;
|
|
||||||
|
|
||||||
@Value("${account-password}")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
private final WebSocketHandler webSocketHandler;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public ApplicationConfiguration(WebSocketHandler webSocketHandler) {
|
|
||||||
this.webSocketHandler = webSocketHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean(destroyMethod = "stop")
|
@Bean(destroyMethod = "stop")
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -64,48 +37,13 @@ public class ApplicationConfiguration extends WebSecurityConfigurerAdapter imple
|
|||||||
return switch (captureMode) {
|
return switch (captureMode) {
|
||||||
case LIVE -> new LivePcapWorker(servicesService, streamService, localIpString, interfaceName);
|
case LIVE -> new LivePcapWorker(servicesService, streamService, localIpString, interfaceName);
|
||||||
case FILE -> new FilePcapWorker(servicesService, streamService, subscriptionService, localIpString, filename);
|
case FILE -> new FilePcapWorker(servicesService, streamService, subscriptionService, localIpString, filename);
|
||||||
default -> new NoOpPcapWorker();
|
case VIEW -> new NoOpPcapWorker();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
|
||||||
auth.inMemoryAuthentication()
|
|
||||||
.withUser(login)
|
|
||||||
.password(passwordEncoder().encode(password))
|
|
||||||
.authorities("ROLE_USER");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
|
||||||
http.csrf()
|
|
||||||
.disable()
|
|
||||||
.authorizeRequests()
|
|
||||||
.antMatchers("/site.webmanifest")
|
|
||||||
.permitAll()
|
|
||||||
.anyRequest().authenticated()
|
|
||||||
.and()
|
|
||||||
.httpBasic()
|
|
||||||
.and()
|
|
||||||
.headers()
|
|
||||||
.frameOptions()
|
|
||||||
.sameOrigin();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public PasswordEncoder passwordEncoder() {
|
public PasswordEncoder passwordEncoder() {
|
||||||
return new BCryptPasswordEncoder();
|
return new BCryptPasswordEncoder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventListener
|
|
||||||
public void authenticationFailed(AuthenticationFailureBadCredentialsEvent e) {
|
|
||||||
log.info("Login failed for user {}, password {}",
|
|
||||||
e.getAuthentication().getPrincipal(), e.getAuthentication().getCredentials());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
|
|
||||||
registry.addHandler(webSocketHandler, "/api/ws")
|
|
||||||
.withSockJS();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package ru.serega6531.packmate.configuration;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.event.EventListener;
|
||||||
|
import org.springframework.security.authentication.event.AuthenticationFailureBadCredentialsEvent;
|
||||||
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||||
|
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.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableWebSecurity
|
||||||
|
@Slf4j
|
||||||
|
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
|
@Value("${account-login}")
|
||||||
|
private String login;
|
||||||
|
|
||||||
|
@Value("${account-password}")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private final PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public SecurityConfiguration(PasswordEncoder passwordEncoder) {
|
||||||
|
this.passwordEncoder = passwordEncoder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||||
|
auth.inMemoryAuthentication()
|
||||||
|
.withUser(login)
|
||||||
|
.password(passwordEncoder.encode(password))
|
||||||
|
.authorities("ROLE_USER");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
|
http.csrf()
|
||||||
|
.disable()
|
||||||
|
.authorizeRequests()
|
||||||
|
.antMatchers("/site.webmanifest")
|
||||||
|
.permitAll()
|
||||||
|
.anyRequest().authenticated()
|
||||||
|
.and()
|
||||||
|
.httpBasic()
|
||||||
|
.and()
|
||||||
|
.headers()
|
||||||
|
.frameOptions()
|
||||||
|
.sameOrigin();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventListener
|
||||||
|
public void authenticationFailed(AuthenticationFailureBadCredentialsEvent e) {
|
||||||
|
log.info("Login failed for user {}, password {}",
|
||||||
|
e.getAuthentication().getPrincipal(), e.getAuthentication().getCredentials());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package ru.serega6531.packmate.configuration;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
||||||
|
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
|
||||||
|
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
|
||||||
|
import ru.serega6531.packmate.WebSocketHandler;
|
||||||
|
|
||||||
|
@EnableWebSocket
|
||||||
|
@Configuration
|
||||||
|
public class WebSocketConfiguration implements WebSocketConfigurer {
|
||||||
|
|
||||||
|
private final WebSocketHandler webSocketHandler;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public WebSocketConfiguration(WebSocketHandler webSocketHandler) {
|
||||||
|
this.webSocketHandler = webSocketHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
|
||||||
|
registry.addHandler(webSocketHandler, "/api/ws")
|
||||||
|
.withSockJS();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user