Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8d168bf

Browse files
adding actuator/health endpoints
1 parent 740905a commit 8d168bf

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

‎pom.xml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@
9292
<version>2.1.1</version>
9393
</dependency>
9494

95-
95+
<dependency>
96+
<groupId>org.springframework.boot</groupId>
97+
<artifactId>spring-boot-starter-actuator</artifactId>
98+
</dependency>
99+
96100

97101
</dependencies>
98102

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
package com.example.devopsapp.security;
22

3-
import com.example.devopsapp.service.UserService;
43
import com.example.devopsapp.model.User;
54
import com.example.devopsapp.repository.UserRepository;
65
import org.springframework.beans.factory.annotation.Autowired;
76
import org.springframework.context.annotation.Bean;
87
import org.springframework.context.annotation.Configuration;
98

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;
149
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;
2010
import org.springframework.security.core.userdetails.UserDetailsService;
21-
2211
import org.springframework.security.core.userdetails.UsernameNotFoundException;
2312
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
24-
2513
import org.springframework.security.web.SecurityFilterChain;
2614

2715
@Configuration
@@ -51,21 +39,24 @@ public BCryptPasswordEncoder passwordEncoder() {
5139
@Bean
5240
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
5341
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+
);
6960
return http.build();
7061
}
7162
}

‎src/main/resources/application-docker.properties‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@ spring.rabbitmq.password=guest
88
memcached.host=memcached
99
memcached.port=11211
1010

11+
management.endpoints.web.exposure.include=health
12+
management.endpoint.health.show-details=always
13+
management.health.mongo.enabled=true
14+
management.health.rabbit.enabled=true
15+
management.health.memcached.enabled=true
1116
#for docker compose

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /