Skip to content

Commit d7533de

Browse files
SteKoeandreasfritz
andauthored
feat(JMX): adapt JMX view from 2.7 (#2220)
* feat: add jmx view * chore: fix tests * chore: add tests and adapt changes from 2.7 * chore: ui adoptions * chore: ui adoptions * fix: add cursor pointer to mbean-headers * chore: explicitly check for null or undefined * chore: revert update of jest * chore: merge changes of master into package.json * added CustomCsrfFilter in SecurityPermitAllConfig * chore: fix checkstyle Co-authored-by: Andreas Fritz <[email protected]>
1 parent e6ec1bd commit d7533de

File tree

32 files changed

+4360
-1497
lines changed

32 files changed

+4360
-1497
lines changed

spring-boot-admin-samples/spring-boot-admin-sample-servlet/src/main/java/de/codecentric/boot/admin/SecurityPermitAllConfig.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@
1919
import org.springframework.context.annotation.Bean;
2020
import org.springframework.context.annotation.Configuration;
2121
import org.springframework.context.annotation.Profile;
22-
import org.springframework.http.HttpMethod;
2322
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
2423
import org.springframework.security.web.SecurityFilterChain;
24+
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
2525
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
26+
import org.springframework.security.web.csrf.CsrfTokenRequestAttributeHandler;
2627
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
2728

2829
import de.codecentric.boot.admin.server.config.AdminServerProperties;
2930

31+
import static org.springframework.http.HttpMethod.DELETE;
32+
import static org.springframework.http.HttpMethod.POST;
33+
3034
@Profile("insecure")
3135
@Configuration(proxyBeanMethods = false)
3236
public class SecurityPermitAllConfig {
@@ -39,13 +43,19 @@ public SecurityPermitAllConfig(AdminServerProperties adminServer) {
3943

4044
@Bean
4145
protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
42-
http.authorizeHttpRequests((authorizeRequest) -> authorizeRequest.anyRequest().permitAll()).csrf((csrf) -> csrf
43-
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()).ignoringRequestMatchers(
44-
new AntPathRequestMatcher(this.adminServer.path("/instances"), HttpMethod.POST.toString()),
45-
new AntPathRequestMatcher(this.adminServer.path("/instances/*"), HttpMethod.DELETE.toString()),
46-
new AntPathRequestMatcher(this.adminServer.path("/actuator/**"))));
46+
47+
http.authorizeHttpRequests((authorizeRequest) -> authorizeRequest.anyRequest().permitAll());
48+
49+
http.addFilterAfter(new CustomCsrfFilter(), BasicAuthenticationFilter.class)
50+
.csrf((csrf) -> csrf.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
51+
.csrfTokenRequestHandler(new CsrfTokenRequestAttributeHandler()).ignoringRequestMatchers(
52+
new AntPathRequestMatcher(this.adminServer.path("/instances"), POST.toString()),
53+
new AntPathRequestMatcher(this.adminServer.path("/instances/*"), DELETE.toString()),
54+
new AntPathRequestMatcher(this.adminServer.path("/actuator/**"))
55+
));
4756

4857
return http.build();
58+
4959
}
5060

5161
}
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import '@testing-library/jest-dom';
2-
import {server} from '@/mocks/server';
2+
3+
import { server } from '@/mocks/server';
34

45
beforeAll(async () => {
56
server.listen();
@@ -9,14 +10,16 @@ beforeAll(async () => {
910
mockIntersectionObserver.mockReturnValue({
1011
observe: () => null,
1112
unobserve: () => null,
12-
disconnect: () => null
13+
disconnect: () => null,
1314
});
1415
window.IntersectionObserver = mockIntersectionObserver;
15-
})
16+
});
1617

17-
afterAll(done => {
18+
afterAll((done) => {
1819
setTimeout(() => {
1920
server.close();
2021
done();
2122
}, 500);
22-
})
23+
});
24+
25+
afterEach(() => server.resetHandlers());

0 commit comments

Comments
 (0)