|
1 | 1 | package com.example.devopsapp.security;
|
2 | 2 |
|
3 | | -import com.example.devopsapp.service.UserService; |
4 | 3 | import com.example.devopsapp.model.User;
|
5 | 4 | import com.example.devopsapp.repository.UserRepository;
|
6 | 5 | import org.springframework.beans.factory.annotation.Autowired;
|
7 | 6 | import org.springframework.context.annotation.Bean;
|
8 | 7 | import org.springframework.context.annotation.Configuration;
|
9 | 8 |
|
10 | | -import org.springframework.security.authentication.AuthenticationManager; |
11 | | -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
12 | | - |
13 | | -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; |
14 | 9 | import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
15 | | - |
16 | | -import org.springframework.security.core.Authentication; |
17 | | -import org.springframework.security.core.AuthenticationException; |
18 | | - |
19 | | -import org.springframework.security.core.userdetails.UserDetails; |
20 | 10 | import org.springframework.security.core.userdetails.UserDetailsService;
|
21 | | - |
22 | 11 | import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
23 | 12 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
24 | | - |
25 | 13 | import org.springframework.security.web.SecurityFilterChain;
|
26 | 14 |
|
27 | 15 | @Configuration
|
@@ -51,21 +39,24 @@ public BCryptPasswordEncoder passwordEncoder() {
|
51 | 39 | @Bean
|
52 | 40 | public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
53 | 41 | http
|
54 | | - .csrf(csrf -> csrf.disable()) |
55 | | - .authorizeHttpRequests(auth -> auth |
56 | | - .requestMatchers("/register", "/css/**", "/js/**").permitAll() |
57 | | - .anyRequest().authenticated() |
58 | | - ) |
59 | | - .formLogin(form -> form |
60 | | - .loginPage("/login") |
61 | | - .defaultSuccessUrl("/dashboard", true) |
62 | | - .permitAll() |
63 | | - ) |
64 | | - .logout(logout -> logout |
65 | | - .logoutUrl("/logout") |
66 | | - .logoutSuccessUrl("/login?logout") |
67 | | - .permitAll() |
68 | | - ); |
| 42 | + .csrf(csrf -> csrf.disable()) |
| 43 | + .authorizeHttpRequests(auth -> auth |
| 44 | + .requestMatchers( |
| 45 | + "/register", "/css/**", "/js/**", |
| 46 | + "/actuator/health", "/actuator/health/**" |
| 47 | + ).permitAll() |
| 48 | + .anyRequest().authenticated() |
| 49 | + ) |
| 50 | + .formLogin(form -> form |
| 51 | + .loginPage("/login") |
| 52 | + .defaultSuccessUrl("/dashboard", true) |
| 53 | + .permitAll() |
| 54 | + ) |
| 55 | + .logout(logout -> logout |
| 56 | + .logoutUrl("/logout") |
| 57 | + .logoutSuccessUrl("/login?logout") |
| 58 | + .permitAll() |
| 59 | + ); |
69 | 60 | return http.build();
|
70 | 61 | }
|
71 | 62 | }
|
0 commit comments