Добавлена http авторизация
This commit is contained in:
@@ -22,6 +22,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
|
implementation "org.springframework.boot:spring-boot-starter-security"
|
||||||
implementation 'org.springframework.session:spring-session-core'
|
implementation 'org.springframework.session:spring-session-core'
|
||||||
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
|
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
|
||||||
compile 'org.pcap4j:pcap4j-core:1.+'
|
compile 'org.pcap4j:pcap4j-core:1.+'
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package ru.serega6531.packmate;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
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.password.PasswordEncoder;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableWebSecurity
|
||||||
|
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
|
@Value("${account-login}")
|
||||||
|
private String login;
|
||||||
|
|
||||||
|
@Value("${account-password}")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@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.authorizeRequests()
|
||||||
|
.anyRequest().authenticated()
|
||||||
|
.and()
|
||||||
|
.httpBasic();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PasswordEncoder passwordEncoder() {
|
||||||
|
return new BCryptPasswordEncoder();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,4 +12,6 @@ spring:
|
|||||||
temp:
|
temp:
|
||||||
use_jdbc_metadata_defaults: false
|
use_jdbc_metadata_defaults: false
|
||||||
interface-name: enp0s31f6
|
interface-name: enp0s31f6
|
||||||
local-ip: "192.168.0.125"
|
local-ip: "192.168.0.125"
|
||||||
|
account-login: BinaryBears
|
||||||
|
account-password: 123456
|
||||||
Reference in New Issue
Block a user