BladeConfiguration.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * Neither the name of the dreamlu.net developer nor the names of its
  13. * contributors may be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. * Author: Chill 庄骞 (smallchill@163.com)
  16. */
  17. package org.springblade.common.config;
  18. import org.springblade.core.secure.registry.SecureRegistry;
  19. import org.springframework.context.annotation.Bean;
  20. import org.springframework.context.annotation.Configuration;
  21. import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
  22. import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  23. /**
  24. * Blade配置
  25. *
  26. * @author Chill
  27. */
  28. @Configuration
  29. public class BladeConfiguration implements WebMvcConfigurer {
  30. @Bean
  31. public SecureRegistry secureRegistry() {
  32. SecureRegistry secureRegistry = new SecureRegistry();
  33. secureRegistry.excludePathPatterns("/blade-auth/**");
  34. secureRegistry.excludePathPatterns("/blade-log/**");
  35. secureRegistry.excludePathPatterns("/blade-system/menu/auth-routes");
  36. secureRegistry.excludePathPatterns("/doc.html");
  37. secureRegistry.excludePathPatterns("/js/**");
  38. secureRegistry.excludePathPatterns("/webjars/**");
  39. secureRegistry.excludePathPatterns("/swagger-resources/**");
  40. return secureRegistry;
  41. }
  42. @Override
  43. public void addResourceHandlers(ResourceHandlerRegistry registry) {
  44. registry.addResourceHandler("/js/**").addResourceLocations("classpath:/js/");
  45. registry.addResourceHandler("doc.html")
  46. .addResourceLocations("classpath:/META-INF/resources/");
  47. registry.addResourceHandler("/webjars/**")
  48. .addResourceLocations("classpath:/META-INF/resources/webjars/");
  49. }
  50. }