This commit is contained in:
parent
a0fafcc2dc
commit
72e7af7a35
@ -7,6 +7,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.authentication.AuthenticationProvider;
|
||||
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;
|
||||
@ -34,18 +35,20 @@ public class SecurityConfiguration
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
http.csrf()
|
||||
.disable()
|
||||
.authorizeHttpRequests()
|
||||
|
||||
http.csrf(AbstractHttpConfigurer::disable);
|
||||
|
||||
http.authorizeHttpRequests(authorizationManagerRequestMatcherRegistry -> authorizationManagerRequestMatcherRegistry
|
||||
.requestMatchers("/api/v1/auth/**")
|
||||
.permitAll()
|
||||
.anyRequest()
|
||||
.authenticated()
|
||||
.and()
|
||||
.sessionManagement()
|
||||
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
||||
.and()
|
||||
.authenticationProvider(authenticationProvider)
|
||||
.authenticated());
|
||||
|
||||
http.sessionManagement(httpSecuritySessionManagementConfigurer -> {
|
||||
httpSecuritySessionManagementConfigurer.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
|
||||
});
|
||||
|
||||
http.authenticationProvider(authenticationProvider)
|
||||
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
|
||||
return http.build();
|
||||
|
@ -1,18 +1,14 @@
|
||||
package wtf.beatrice.releasehive.service;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import wtf.beatrice.releasehive.db.HibernateManager;
|
||||
import wtf.beatrice.releasehive.dto.LoginUserDto;
|
||||
import wtf.beatrice.releasehive.dto.RegisterUserDto;
|
||||
import wtf.beatrice.releasehive.model.User;
|
||||
import wtf.beatrice.releasehive.repository.UserRepository;
|
||||
import wtf.beatrice.releasehive.util.JsonUtil;
|
||||
|
||||
@Service
|
||||
public class AccountServiceImpl implements AccountService {
|
||||
|
Loading…
Reference in New Issue
Block a user