Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- spring.security.user.name=admin
- spring.security.user.password=secret
- spring.boot.admin.discovery.enabled=true
- management.endpoints.web.exposure.include=*
- management.endpoints.web.cors.allowed-methods=GET,POST
- @EnableWebSecurity
- @Configuration
- public class SecuritySecureConfig extends WebSecurityConfigurerAdapter {
- private static final Logger logger = (Logger) LoggerFactory.getLogger(SecuritySecureConfig.class);
- private final String adminContextPath;
- public SecuritySecureConfig(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(
- adminContextPath + "/instances",
- adminContextPath + "/actuator/**"
- );
- }
- }
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-security</artifactId>
- </dependency>
- <dependency>
- <groupId>de.codecentric</groupId>
- <artifactId>spring-boot-admin-starter-server</artifactId>
- </dependency>
- <dependency>
- <groupId>de.codecentric</groupId>
- <artifactId>spring-boot-admin-server-ui</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-tomcat</artifactId>
- </dependency>
- </dependencies>
- spring.security.user.name=joe
- spring.security.user.password=my-secret-password
- spring.boot.admin.client.username=admin
- spring.boot.admin.client.password=secret
- spring.boot.admin.client.instance.metadata.user.name=admin
- spring.boot.admin.client.instance.metadata.user.password=secret
- spring.boot.admin.client.enabled=true
- spring.boot.admin.client.auto-registration=true
- spring.boot.admin.client.auto-deregistration=true
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-security</artifactId>
- </dependency>
Add Comment
Please, Sign In to add comment