我有一个 spring 靴应用与 spring 启动 Actuator .
登录http://localhost:9501(Spring管理应用程序)时,我会通知数据库中现有用户的用户和密码,即abc . 然后我得到错误:
Error: Internal Server Error", "exception":"io.jsonwebtoken.MalformedJwtException", "Error": "timestamp": "2018-02-02T20: 09: 55.004 + 0000" JWT strings must contain exactly 2 period characters Found: 0 "," path ":"/api/v3/manage/info"}
如果我使用带有基本身份验证的邮递员通知http://localhost:9501/ manage / health用户名和密码,我会得到正确的 endpoints 值 .
如何将此表单登录传递给受监控的应用程序?我试图从这里使用一些技巧,但我不能成功 . 谢谢!
在这个应用程序(客户端)的POM.xml中,我添加了依赖项:
<dependency>
<groupId> de.codecentric </ groupId>
<artifactId> spring-boot-admin-starter-client </ artifactId>
<version> 1.5.7 </ version>
</ dependency>
<dependency>
<groupId> org.jolokia </ groupId>
<artifactId> jolokia-core </ artifactId>
</ dependency>
在application.yml我有:
spring
boot:
admin:
url: http://localhost:8091
username: abc
password: abcdef
client:
metadata:
user.name: ${security.user.name}
user.password: ${security.user.password}
management:
context-path: /manage
security:
enabled: true
在Spring Boot Admin应用程序中,我有:
Application.properties:
spring.mvc.async.request-timeout = -1
management.security.enabled = true
server.port = 9501
management.context-path = / manage
security.user.name = abc
security.user.password = abcdef
spring.boot.admin.username = $ {security.user.name}
spring.boot.admin.password = $ {security.user.password}
spring.boot.admin.client.metadata.user.name = $ {security.user.name}
spring.boot.admin.client.metadata.user.password = $ {security.user.password}
spring.boot.admin.routes.endpoints = env, metrics, trace, dump, jolokia, info, configprops, trace, logfile, refresh, flyway, liquibase, heapdump, hystrix.stream
------------------------------------
In pom.xml:
<dependency>
<groupId>de.codecentric </groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>1.5.7</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>1.5.7</version>
</ dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-login</artifactId>
<version>1.5.7</version>
</ dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId> org.springframework.boot </ groupId>
<artifactId> spring-boot-starter-security </ artifactId>
</ dependency>
----------------------------------------------------
In the WebSecurityConfig class:
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure (HttpSecurity http) throws Exception {
http
.formLogin().loginPage("/login.html")
.loginProcessingUrl ("/ login")
.permitAll();
http
.logout().logoutUrl("/logout");
http
.csrf().disable();
http
.authorizeRequests()
.antMatchers("/login.html", "/**/*.css", "/ img / **", "/ third-party / **")
.permitAll();
http
.authorizeRequests()
.antMatchers("/**")
.authenticated();
http.httpBasic();
}
}