Guest User

Untitled

a guest
Feb 12th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. spring.security.user.name=admin
  2. spring.security.user.password=secret
  3.  
  4. spring.boot.admin.discovery.enabled=true
  5.  
  6. management.endpoints.web.exposure.include=*
  7. management.endpoints.web.cors.allowed-methods=GET,POST
  8.  
  9. @EnableWebSecurity
  10. @Configuration
  11. public class SecuritySecureConfig extends WebSecurityConfigurerAdapter {
  12.  
  13. private static final Logger logger = (Logger) LoggerFactory.getLogger(SecuritySecureConfig.class);
  14.  
  15. private final String adminContextPath;
  16.  
  17. public SecuritySecureConfig(AdminServerProperties adminServerProperties) {
  18. this.adminContextPath = adminServerProperties.getContextPath();
  19. }
  20.  
  21. @Override
  22. protected void configure(HttpSecurity http) throws Exception {
  23.  
  24. SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
  25. successHandler.setTargetUrlParameter("redirectTo");
  26. successHandler.setDefaultTargetUrl(adminContextPath + "/");
  27.  
  28. http.authorizeRequests()
  29. .antMatchers(adminContextPath + "/assets/**").permitAll()
  30. .antMatchers(adminContextPath + "/login").permitAll()
  31. .anyRequest().authenticated()
  32. .and()
  33. .formLogin().loginPage(adminContextPath + "/login").successHandler(successHandler).and()
  34. .logout().logoutUrl(adminContextPath + "/logout").and()
  35. .httpBasic().and()
  36. .csrf()
  37. .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
  38. .ignoringAntMatchers(
  39. adminContextPath + "/instances",
  40. adminContextPath + "/actuator/**"
  41. );
  42.  
  43. }
  44.  
  45. }
  46.  
  47. <dependencies>
  48. <dependency>
  49. <groupId>org.springframework.boot</groupId>
  50. <artifactId>spring-boot-starter-security</artifactId>
  51. </dependency>
  52. <dependency>
  53. <groupId>de.codecentric</groupId>
  54. <artifactId>spring-boot-admin-starter-server</artifactId>
  55. </dependency>
  56.  
  57. <dependency>
  58. <groupId>de.codecentric</groupId>
  59. <artifactId>spring-boot-admin-server-ui</artifactId>
  60. </dependency>
  61.  
  62. <dependency>
  63. <groupId>org.springframework.boot</groupId>
  64. <artifactId>spring-boot-starter-tomcat</artifactId>
  65. </dependency>
  66.  
  67. </dependencies>
  68.  
  69. spring.security.user.name=joe
  70. spring.security.user.password=my-secret-password
  71.  
  72. spring.boot.admin.client.username=admin
  73. spring.boot.admin.client.password=secret
  74.  
  75. spring.boot.admin.client.instance.metadata.user.name=admin
  76. spring.boot.admin.client.instance.metadata.user.password=secret
  77.  
  78.  
  79. spring.boot.admin.client.enabled=true
  80.  
  81. spring.boot.admin.client.auto-registration=true
  82. spring.boot.admin.client.auto-deregistration=true
  83.  
  84. <dependency>
  85. <groupId>org.springframework.boot</groupId>
  86. <artifactId>spring-boot-starter-security</artifactId>
  87. </dependency>
Add Comment
Please, Sign In to add comment