Fix code a bit

This commit is contained in:
hou27
2022-06-09 19:00:28 +09:00
parent 06a5352fb9
commit b54514acab
2 changed files with 2 additions and 4 deletions

View File

@@ -17,9 +17,6 @@ import org.springframework.security.web.SecurityFilterChain;
@EnableWebSecurity @EnableWebSecurity
@RequiredArgsConstructor @RequiredArgsConstructor
public class SecurityConfig { public class SecurityConfig {
// private final UserRepository userRepository;
// https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter
// https://github.com/spring-projects/spring-security/issues/10822
@Bean @Bean
public UserDetailsService userDetailsService() { public UserDetailsService userDetailsService() {
return new UserDetailsServiceImpl(); return new UserDetailsServiceImpl();
@@ -43,6 +40,7 @@ public class SecurityConfig {
.authorizeRequests() .authorizeRequests()
.antMatchers("/", "/user/signUp", "/user/userList", "/user/signIn*").permitAll() .antMatchers("/", "/user/signUp", "/user/userList", "/user/signIn*").permitAll()
.anyRequest().authenticated(); .anyRequest().authenticated();
return http.build(); return http.build();
} }
} }

View File

@@ -23,7 +23,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
public UserDetails loadUserByUsername(String email) throws UserNotFoundException { public UserDetails loadUserByUsername(String email) throws UserNotFoundException {
User user = userRepository.findByEmail(email) User user = userRepository.findByEmail(email)
.orElseThrow(() -> new UserNotFoundException()); .orElseThrow(UserNotFoundException::new);
Set<GrantedAuthority> grantedAuthorities = new HashSet<>(); Set<GrantedAuthority> grantedAuthorities = new HashSet<>();
return new org return new org