Browse Source
Update `ManagementServerProperties` so that `security.sessions` no longer uses `SessionCreationPolicy` from Spring Security. We now use our own enun which allows `management.security.*` properties to be set without the risk of a `ClassNotFoundException`. Fixes gh-3888pull/7336/head
10 changed files with 277 additions and 15 deletions
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<parent> |
||||
<!-- Your own application should inherit from spring-boot-starter-parent --> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-samples</artifactId> |
||||
<version>1.4.2.BUILD-SNAPSHOT</version> |
||||
</parent> |
||||
<artifactId>spring-boot-sample-actuator-no-security</artifactId> |
||||
<name>Spring Boot Actuator UI Sample</name> |
||||
<description>Spring Boot Actuator UI Sample</description> |
||||
<url>http://projects.spring.io/spring-boot/</url> |
||||
<organization> |
||||
<name>Pivotal Software, Inc.</name> |
||||
<url>http://www.spring.io</url> |
||||
</organization> |
||||
<properties> |
||||
<main.basedir>${basedir}/../..</main.basedir> |
||||
</properties> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-actuator</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-freemarker</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-test</artifactId> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
</project> |
||||
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
/* |
||||
* Copyright 2012-2016 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package sample.actuator.nosecurity; |
||||
|
||||
import java.util.Date; |
||||
import java.util.Map; |
||||
|
||||
import org.springframework.boot.SpringApplication; |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
||||
@SpringBootApplication |
||||
@Controller |
||||
public class SampleActuatorNoSecurityApplication { |
||||
|
||||
@GetMapping("/") |
||||
public String home(Map<String, Object> model) { |
||||
model.put("message", "Hello World"); |
||||
model.put("title", "Hello Home"); |
||||
model.put("date", new Date()); |
||||
return "home"; |
||||
} |
||||
|
||||
@RequestMapping("/foo") |
||||
public String foo() { |
||||
throw new RuntimeException("Expected exception in controller"); |
||||
} |
||||
|
||||
public static void main(String[] args) throws Exception { |
||||
SpringApplication.run(SampleActuatorNoSecurityApplication.class, args); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
health.diskspace.enabled=false |
||||
management.security.role=superuser |
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
<#import "/spring.ftl" as spring /> |
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<title>Error</title> |
||||
<#assign home><@spring.url relativeUrl="/"/></#assign> |
||||
<#assign bootstrap><@spring.url relativeUrl="/css/bootstrap.min.css"/></#assign> |
||||
<link rel="stylesheet" href="${bootstrap}" /> |
||||
</head> |
||||
<body> |
||||
<div class="container"> |
||||
<div class="navbar"> |
||||
<div class="navbar-inner"> |
||||
<a class="brand" href="http://freemarker.org/"> FreeMarker - |
||||
Plain </a> |
||||
<ul class="nav"> |
||||
<li><a href="${home}"> Home </a></li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<h1>Error Page</h1> |
||||
<div id="created">${timestamp?datetime}</div> |
||||
<div> |
||||
There was an unexpected error (type=${error}, status=${status}). |
||||
</div> |
||||
<div>${message}</div> |
||||
<div> |
||||
Please contact the operator with the above information. |
||||
</div> |
||||
</div> |
||||
</body> |
||||
</html> |
||||
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
<#import "/spring.ftl" as spring /> |
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<title>${title}</title> |
||||
<#assign home><@spring.url relativeUrl="/"/></#assign> |
||||
<#assign bootstrap><@spring.url relativeUrl="/css/bootstrap.min.css"/></#assign> |
||||
<link rel="stylesheet" href="${bootstrap}" /> |
||||
</head> |
||||
<body> |
||||
<div class="container"> |
||||
<div class="navbar"> |
||||
<div class="navbar-inner"> |
||||
<a class="brand" href="http://freemarker.org/"> FreeMarker - |
||||
Plain </a> |
||||
<ul class="nav"> |
||||
<li><a href="${home}"> Home </a></li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<h1>${title}</h1> |
||||
<div>${message}</div> |
||||
<div id="created">${date?datetime}</div> |
||||
</div> |
||||
</body> |
||||
</html> |
||||
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
/* |
||||
* Copyright 2012-2016 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package sample.actuator.nosecurity; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.Map; |
||||
|
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; |
||||
import org.springframework.boot.test.web.client.TestRestTemplate; |
||||
import org.springframework.http.HttpEntity; |
||||
import org.springframework.http.HttpHeaders; |
||||
import org.springframework.http.HttpMethod; |
||||
import org.springframework.http.HttpStatus; |
||||
import org.springframework.http.MediaType; |
||||
import org.springframework.http.ResponseEntity; |
||||
import org.springframework.test.annotation.DirtiesContext; |
||||
import org.springframework.test.context.junit4.SpringRunner; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
/** |
||||
* Basic integration tests for demo application. |
||||
* |
||||
* @author Phillip Webb |
||||
*/ |
||||
@RunWith(SpringRunner.class) |
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) |
||||
@DirtiesContext |
||||
public class SampleActuatorNoSecurityApplicationTests { |
||||
|
||||
@Autowired |
||||
private TestRestTemplate restTemplate; |
||||
|
||||
@Test |
||||
public void testHome() throws Exception { |
||||
HttpHeaders headers = new HttpHeaders(); |
||||
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); |
||||
ResponseEntity<String> entity = this.restTemplate.exchange("/", HttpMethod.GET, |
||||
new HttpEntity<Void>(headers), String.class); |
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); |
||||
assertThat(entity.getBody()).contains("<title>Hello"); |
||||
} |
||||
|
||||
@Test |
||||
public void testMetrics() throws Exception { |
||||
@SuppressWarnings("rawtypes") |
||||
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/metrics", |
||||
Map.class); |
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue