I am developing according with documentation: https://codecentric.github.io/spring-boot-admin/2.0.2 , but i don't getting register a client in a secure application.
My configuration are:
application.yml
# Security config
spring.security.user:
name: admin
password: admin
# Actuator config
management:
endpoint:
shutdown.enabled: true
health.show-details: always
endpoints.web.exposure.include: '*'
# Spring boot admin config
spring.boot.admin:
context-path: /admin
client:
url: http://localhost:8080/admin
username: ${spring.security.user.name}
password: ${spring.security.user.password}
instance:
name: ${app.name}
metadata.user:
name: ${spring.security.user.name}
password: ${spring.security.user.password}
WebSecurityConfiguration
@Configuration
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
private final String adminContextPath;
public WebSecurityConfiguration(AdminServerProperties adminServerProperties) {
this.adminContextPath = adminServerProperties.getContextPath();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
successHandler.setTargetUrlParameter("redirectTo");
successHandler.setDefaultTargetUrl(adminContextPath + "/");
http.authorizeRequests()
.antMatchers(adminContextPath + "/assets/**").permitAll()
.antMatchers(adminContextPath + "/login").permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage(adminContextPath + "/login").successHandler(successHandler).and()
.logout().logoutUrl(adminContextPath + "/logout").and()
.httpBasic().and()
.csrf()
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
.ignoringAntMatchers("/instances", "/actuator/**");
}
}
And the error is occurring:
2018-08-22 00:44:21.770 DEBUG 9616 --- [gistrationTask1] dcbacrApplicationRegistrator: Failed to register application as Application(name=template-api, managementUrl=http://localhost:8080/actuator, healthUrl=http://localhost:8080/actuator/health, serviceUrl=http://localhost:8080/) at spring-boot-admin ([http://localhost:8080/admin/instances]): 401 null
Can someone please help with this 401
?
UPDATED 2018-09-01:
I tried separate configs and the same error occurs:
Server:
# Security config
spring.security.user:
name: test-name
password: test-password
# Spring boot admin config
spring.boot.admin:
context-path: /admin
Client:
# Spring boot admin config
spring.boot.admin:
client:
url: http://localhost:8080/admin
username: test-name
password: test-password
instance:
name: ${app.name}
metadata.user:
name: test-name
password: test-password
401 Unauthorized error is an HTTP status code that means the page you were trying to access cannot be loaded until you first log in with a valid user ID and password. Have you configured your client and admin server correctly??
You can take a look at my sample source code for server and client spring boot applications with and without security configurations here.
https://github.com/anandvarkeyphilips/spring-boot-admin/tree/master/spring-boot-admin-samples
There was a bug in the Spring Boot Admin documentation. It was fixed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.