Начинаем правки по примеру с LMS.

This commit is contained in:
Programmist73 2023-05-13 10:49:24 +04:00
parent 65800b9a6f
commit 6a83584f50
7 changed files with 20 additions and 40 deletions

View File

@ -33,8 +33,8 @@ dependencies {
implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5' implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5'
implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-security'
//implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6' implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6:3.1.1.RELEASE' //implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6:3.1.1.RELEASE'
implementation 'org.hibernate.validator:hibernate-validator' implementation 'org.hibernate.validator:hibernate-validator'
implementation 'org.springdoc:springdoc-openapi-ui:1.6.5' implementation 'org.springdoc:springdoc-openapi-ui:1.6.5'

View File

@ -1,17 +0,0 @@
package premium_store;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//отключение Cors фильтра - не позволяет организовавыть взаимодействие с разных доменов
@Configuration
public class WebConfiguration implements WebMvcConfigurer {
public static final String REST_API = "/api";
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("*");
}
}

View File

@ -10,6 +10,7 @@ import org.springframework.security.config.annotation.authentication.builders.Au
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
@ -41,8 +42,8 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
} }
} }
@Bean @Override
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { public void configure(HttpSecurity http) throws Exception {
http.headers().frameOptions().sameOrigin().and() http.headers().frameOptions().sameOrigin().and()
.cors().and() .cors().and()
.csrf().disable() .csrf().disable()
@ -55,23 +56,19 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
.loginPage(LOGIN_URL).permitAll() .loginPage(LOGIN_URL).permitAll()
.and() .and()
.logout().permitAll(); .logout().permitAll();
return http.userDetailsService(clientService).build();
} }
@Bean @Override
public AuthenticationManager authenticationManagerBean(HttpSecurity http) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
AuthenticationManagerBuilder authenticationManagerBuilder = http auth.userDetailsService(clientService);
.getSharedObject(AuthenticationManagerBuilder.class);
authenticationManagerBuilder.userDetailsService(clientService);
return authenticationManagerBuilder.build();
} }
/*@Bean @Override
public WebSecurityCustomizer webSecurityCustomizer() { public void configure(WebSecurity web) {
return (web) -> web.ignoring() web.ignoring()
.requestMatchers("/css/**") .antMatchers("/css/**")
.requestMatchers("/js/**") .antMatchers("/js/**")
.requestMatchers("/templates/**") .antMatchers("/templates/**")
.requestMatchers("/webjars/**"); .antMatchers("/webjars/**");
}*/ }
} }

View File

@ -1,7 +1,7 @@
package premium_store.controller.controller; package premium_store.controller.controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import premium_store.WebConfiguration; import premium_store.configuration.WebConfiguration;
import premium_store.controller.DTO.ClientDTO; import premium_store.controller.DTO.ClientDTO;
import premium_store.model.UserRole; import premium_store.model.UserRole;
import premium_store.service.GameClientService; import premium_store.service.GameClientService;

View File

@ -1,7 +1,7 @@
package premium_store.controller.controller; package premium_store.controller.controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import premium_store.WebConfiguration; import premium_store.configuration.WebConfiguration;
import premium_store.controller.DTO.FullNationDTO; import premium_store.controller.DTO.FullNationDTO;
import premium_store.service.NationService; import premium_store.service.NationService;
import premium_store.service.TankService; import premium_store.service.TankService;

View File

@ -1,7 +1,7 @@
package premium_store.controller.controller; package premium_store.controller.controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import premium_store.WebConfiguration; import premium_store.configuration.WebConfiguration;
import premium_store.controller.DTO.TankDTO; import premium_store.controller.DTO.TankDTO;
import premium_store.service.NationService; import premium_store.service.NationService;
import premium_store.service.TankLevelService; import premium_store.service.TankLevelService;

View File

@ -1,7 +1,7 @@
package premium_store.controller.controller; package premium_store.controller.controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import premium_store.WebConfiguration; import premium_store.configuration.WebConfiguration;
import premium_store.controller.DTO.LevelDTO; import premium_store.controller.DTO.LevelDTO;
import premium_store.service.TankLevelService; import premium_store.service.TankLevelService;