File tree Expand file tree Collapse file tree 3 files changed +22
-6
lines changed
src/main/java/hexlet/code Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change 11package hexlet .code .config ;
22
3- import lombok .AllArgsConstructor ;
43import org .springframework .context .annotation .Bean ;
54import org .springframework .context .annotation .Configuration ;
65import org .springframework .http .HttpMethod ;
2524@ EnableMethodSecurity (prePostEnabled = true )
2625//@EnableMethodSecurity
2726@ EnableWebSecurity
28- @ AllArgsConstructor
2927public class SecurityConfig {
3028 private final JwtDecoder jwtDecoder ;
3129 private final PasswordEncoder passwordEncoder ;
3230 private final CustomUserDetailsService userService ;
3331
32+
33+ public SecurityConfig (JwtDecoder jwtDecoder ,
34+ PasswordEncoder passwordEncoder ,
35+ CustomUserDetailsService userService ) {
36+ this .jwtDecoder = jwtDecoder ;
37+ this .passwordEncoder = passwordEncoder ;
38+ this .userService = userService ;
39+ }
40+
41+
3442 /**
3543 * @param http
3644 * @param introspector
Original file line number Diff line number Diff line change 22
33import hexlet .code .dto .AuthRequest ;
44import hexlet .code .util .JWTUtils ;
5- import lombok .AllArgsConstructor ;
65import org .springframework .security .authentication .AuthenticationManager ;
76import org .springframework .security .authentication .UsernamePasswordAuthenticationToken ;
87import org .springframework .web .bind .annotation .PostMapping ;
1211
1312@ RestController
1413@ RequestMapping ("/api/login" )
15- @ AllArgsConstructor
1614public class AuthenticationController {
1715 private final JWTUtils jwtUtils ;
1816 private final AuthenticationManager authenticationManager ;
1917
18+ public AuthenticationController (JWTUtils jwtUtils ,
19+ AuthenticationManager authenticationManager ) {
20+ this .jwtUtils = jwtUtils ;
21+ this .authenticationManager = authenticationManager ;
22+ }
23+
2024 /**
2125 *
2226 * @param authRequest
Original file line number Diff line number Diff line change 22
33import hexlet .code .model .User ;
44import hexlet .code .repository .UserRepository ;
5- import lombok .AllArgsConstructor ;
65import org .springframework .security .core .userdetails .UserDetails ;
76import org .springframework .security .core .userdetails .UsernameNotFoundException ;
87import org .springframework .security .crypto .password .PasswordEncoder ;
98import org .springframework .security .provisioning .UserDetailsManager ;
109import org .springframework .stereotype .Service ;
1110
1211@ Service
13- @ AllArgsConstructor
1412public class CustomUserDetailsService implements UserDetailsManager {
1513 private final UserRepository userRepository ;
1614 private final PasswordEncoder passwordEncoder ;
1715
16+ public CustomUserDetailsService (UserRepository userRepository ,
17+ PasswordEncoder passwordEncoder ) {
18+ this .userRepository = userRepository ;
19+ this .passwordEncoder = passwordEncoder ;
20+ }
21+
1822 /**
1923 * @param email
2024 * @return UserDetails
You can’t perform that action at this time.
0 commit comments