diff --git a/kernel-d-security/pom.xml b/kernel-d-security/pom.xml index 21085ed9b..8e5942396 100644 --- a/kernel-d-security/pom.xml +++ b/kernel-d-security/pom.xml @@ -19,6 +19,7 @@ security-api security-sdk-black-white security-sdk-captcha + security-sdk-cors security-sdk-count security-sdk-xss security-sdk-request-encrypt-and-decode diff --git a/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/BlackListService.java b/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/BlackListService.java similarity index 97% rename from kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/BlackListService.java rename to kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/BlackListService.java index 958206759..58f754300 100644 --- a/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/BlackListService.java +++ b/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/BlackListService.java @@ -22,7 +22,7 @@ * 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns * 6.若您的项目无法满足以上几点,可申请商业授权 */ -package cn.stylefeng.roses.kemel.security.blackwhite; +package cn.stylefeng.roses.kernel.security.blackwhite; import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi; import cn.stylefeng.roses.kernel.security.api.BlackListApi; diff --git a/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/WhiteListService.java b/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/WhiteListService.java similarity index 97% rename from kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/WhiteListService.java rename to kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/WhiteListService.java index 434230525..e9a0900f4 100644 --- a/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/WhiteListService.java +++ b/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/WhiteListService.java @@ -22,7 +22,7 @@ * 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns * 6.若您的项目无法满足以上几点,可申请商业授权 */ -package cn.stylefeng.roses.kemel.security.blackwhite; +package cn.stylefeng.roses.kernel.security.blackwhite; import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi; import cn.stylefeng.roses.kernel.security.api.WhiteListApi; diff --git a/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/cache/BlackListMemoryCache.java b/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/cache/BlackListMemoryCache.java similarity index 96% rename from kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/cache/BlackListMemoryCache.java rename to kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/cache/BlackListMemoryCache.java index d3d30ed03..7386f24da 100644 --- a/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/cache/BlackListMemoryCache.java +++ b/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/cache/BlackListMemoryCache.java @@ -22,7 +22,7 @@ * 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns * 6.若您的项目无法满足以上几点,可申请商业授权 */ -package cn.stylefeng.roses.kemel.security.blackwhite.cache; +package cn.stylefeng.roses.kernel.security.blackwhite.cache; import cn.hutool.cache.impl.TimedCache; import cn.stylefeng.roses.kernel.cache.memory.AbstractMemoryCacheOperator; diff --git a/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/cache/BlackListRedisCache.java b/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/cache/BlackListRedisCache.java similarity index 96% rename from kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/cache/BlackListRedisCache.java rename to kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/cache/BlackListRedisCache.java index 985d7603a..4ceb60905 100644 --- a/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/cache/BlackListRedisCache.java +++ b/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/cache/BlackListRedisCache.java @@ -22,7 +22,7 @@ * 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns * 6.若您的项目无法满足以上几点,可申请商业授权 */ -package cn.stylefeng.roses.kemel.security.blackwhite.cache; +package cn.stylefeng.roses.kernel.security.blackwhite.cache; import cn.stylefeng.roses.kernel.cache.redis.AbstractRedisCacheOperator; import cn.stylefeng.roses.kernel.security.api.constants.CounterConstants; diff --git a/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/cache/WhiteListMemoryCache.java b/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/cache/WhiteListMemoryCache.java similarity index 96% rename from kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/cache/WhiteListMemoryCache.java rename to kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/cache/WhiteListMemoryCache.java index 896e6e12f..0e974e80e 100644 --- a/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/cache/WhiteListMemoryCache.java +++ b/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/cache/WhiteListMemoryCache.java @@ -22,7 +22,7 @@ * 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns * 6.若您的项目无法满足以上几点,可申请商业授权 */ -package cn.stylefeng.roses.kemel.security.blackwhite.cache; +package cn.stylefeng.roses.kernel.security.blackwhite.cache; import cn.hutool.cache.impl.TimedCache; import cn.stylefeng.roses.kernel.cache.memory.AbstractMemoryCacheOperator; diff --git a/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/cache/WhiteListRedisCache.java b/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/cache/WhiteListRedisCache.java similarity index 96% rename from kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/cache/WhiteListRedisCache.java rename to kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/cache/WhiteListRedisCache.java index cb71a4a7e..d98038d28 100644 --- a/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kemel/security/blackwhite/cache/WhiteListRedisCache.java +++ b/kernel-d-security/security-sdk-black-white/src/main/java/cn/stylefeng/roses/kernel/security/blackwhite/cache/WhiteListRedisCache.java @@ -22,7 +22,7 @@ * 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns * 6.若您的项目无法满足以上几点,可申请商业授权 */ -package cn.stylefeng.roses.kemel.security.blackwhite.cache; +package cn.stylefeng.roses.kernel.security.blackwhite.cache; import cn.stylefeng.roses.kernel.cache.redis.AbstractRedisCacheOperator; import cn.stylefeng.roses.kernel.security.api.constants.CounterConstants; diff --git a/kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kemel/security/captcha/CaptchaService.java b/kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kernel/security/captcha/CaptchaService.java similarity index 98% rename from kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kemel/security/captcha/CaptchaService.java rename to kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kernel/security/captcha/CaptchaService.java index 8ae7e63da..d3bd6db87 100644 --- a/kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kemel/security/captcha/CaptchaService.java +++ b/kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kernel/security/captcha/CaptchaService.java @@ -22,7 +22,7 @@ * 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns * 6.若您的项目无法满足以上几点,可申请商业授权 */ -package cn.stylefeng.roses.kemel.security.captcha; +package cn.stylefeng.roses.kernel.security.captcha; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; diff --git a/kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kemel/security/captcha/cache/CaptchaMemoryCache.java b/kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kernel/security/captcha/cache/CaptchaMemoryCache.java similarity index 96% rename from kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kemel/security/captcha/cache/CaptchaMemoryCache.java rename to kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kernel/security/captcha/cache/CaptchaMemoryCache.java index d015c90ca..e494d6101 100644 --- a/kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kemel/security/captcha/cache/CaptchaMemoryCache.java +++ b/kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kernel/security/captcha/cache/CaptchaMemoryCache.java @@ -22,7 +22,7 @@ * 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns * 6.若您的项目无法满足以上几点,可申请商业授权 */ -package cn.stylefeng.roses.kemel.security.captcha.cache; +package cn.stylefeng.roses.kernel.security.captcha.cache; import cn.hutool.cache.impl.TimedCache; import cn.stylefeng.roses.kernel.cache.memory.AbstractMemoryCacheOperator; diff --git a/kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kemel/security/captcha/cache/CaptchaRedisCache.java b/kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kernel/security/captcha/cache/CaptchaRedisCache.java similarity index 96% rename from kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kemel/security/captcha/cache/CaptchaRedisCache.java rename to kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kernel/security/captcha/cache/CaptchaRedisCache.java index ced3af495..ba5a21371 100644 --- a/kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kemel/security/captcha/cache/CaptchaRedisCache.java +++ b/kernel-d-security/security-sdk-captcha/src/main/java/cn/stylefeng/roses/kernel/security/captcha/cache/CaptchaRedisCache.java @@ -22,7 +22,7 @@ * 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns * 6.若您的项目无法满足以上几点,可申请商业授权 */ -package cn.stylefeng.roses.kemel.security.captcha.cache; +package cn.stylefeng.roses.kernel.security.captcha.cache; import cn.stylefeng.roses.kernel.cache.redis.AbstractRedisCacheOperator; import cn.stylefeng.roses.kernel.security.api.constants.CaptchaConstants; diff --git a/kernel-d-security/security-sdk-cors/README.md b/kernel-d-security/security-sdk-cors/README.md new file mode 100644 index 000000000..880a4ee38 --- /dev/null +++ b/kernel-d-security/security-sdk-cors/README.md @@ -0,0 +1 @@ +CORS跨域过滤器 \ No newline at end of file diff --git a/kernel-d-security/security-sdk-cors/pom.xml b/kernel-d-security/security-sdk-cors/pom.xml new file mode 100644 index 000000000..92dbe6d57 --- /dev/null +++ b/kernel-d-security/security-sdk-cors/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + + cn.stylefeng.roses + kernel-d-security + 7.0.4 + ../pom.xml + + + security-sdk-cors + + jar + + + + + + org.springframework.boot + spring-boot-starter-web + + + + + diff --git a/kernel-d-security/security-sdk-cors/src/main/java/cn/stylefeng/roses/kernel/security/cors/CorsFilterConfiguration.java b/kernel-d-security/security-sdk-cors/src/main/java/cn/stylefeng/roses/kernel/security/cors/CorsFilterConfiguration.java new file mode 100644 index 000000000..ab2bd40bc --- /dev/null +++ b/kernel-d-security/security-sdk-cors/src/main/java/cn/stylefeng/roses/kernel/security/cors/CorsFilterConfiguration.java @@ -0,0 +1,36 @@ +package cn.stylefeng.roses.kernel.security.cors; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; + +/** + * 跨域过滤器的配置 + * + * @author fengshuonan + * @date 2021/6/8 15:11 + */ +@Configuration +public class CorsFilterConfiguration { + + /** + * 开启跨域访问拦截器 + * + * @author fengshuonan + * @date 2021/6/8 15:12 + */ + @Bean + public CorsFilter corsFilter() { + CorsConfiguration corsConfiguration = new CorsConfiguration(); + corsConfiguration.addAllowedOrigin("*"); + corsConfiguration.addAllowedHeader("*"); + corsConfiguration.addAllowedMethod("*"); + + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + source.registerCorsConfiguration("/**", corsConfiguration); + return new CorsFilter(source); + } + +} diff --git a/kernel-d-security/security-sdk-count/src/main/java/cn/stylefeng/roses/kemel/security/count/DefaultCountValidator.java b/kernel-d-security/security-sdk-count/src/main/java/cn/stylefeng/roses/kernel/security/count/DefaultCountValidator.java similarity index 98% rename from kernel-d-security/security-sdk-count/src/main/java/cn/stylefeng/roses/kemel/security/count/DefaultCountValidator.java rename to kernel-d-security/security-sdk-count/src/main/java/cn/stylefeng/roses/kernel/security/count/DefaultCountValidator.java index 1b6605413..1ca2da657 100644 --- a/kernel-d-security/security-sdk-count/src/main/java/cn/stylefeng/roses/kemel/security/count/DefaultCountValidator.java +++ b/kernel-d-security/security-sdk-count/src/main/java/cn/stylefeng/roses/kernel/security/count/DefaultCountValidator.java @@ -22,7 +22,7 @@ * 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns * 6.若您的项目无法满足以上几点,可申请商业授权 */ -package cn.stylefeng.roses.kemel.security.count; +package cn.stylefeng.roses.kernel.security.count; import cn.hutool.core.convert.Convert; import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi; diff --git a/kernel-d-security/security-sdk-count/src/main/java/cn/stylefeng/roses/kemel/security/count/cache/DefaultCountValidateCache.java b/kernel-d-security/security-sdk-count/src/main/java/cn/stylefeng/roses/kernel/security/count/cache/DefaultCountValidateCache.java similarity index 96% rename from kernel-d-security/security-sdk-count/src/main/java/cn/stylefeng/roses/kemel/security/count/cache/DefaultCountValidateCache.java rename to kernel-d-security/security-sdk-count/src/main/java/cn/stylefeng/roses/kernel/security/count/cache/DefaultCountValidateCache.java index defac48bd..4557cee6a 100644 --- a/kernel-d-security/security-sdk-count/src/main/java/cn/stylefeng/roses/kemel/security/count/cache/DefaultCountValidateCache.java +++ b/kernel-d-security/security-sdk-count/src/main/java/cn/stylefeng/roses/kernel/security/count/cache/DefaultCountValidateCache.java @@ -22,7 +22,7 @@ * 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns * 6.若您的项目无法满足以上几点,可申请商业授权 */ -package cn.stylefeng.roses.kemel.security.count.cache; +package cn.stylefeng.roses.kernel.security.count.cache; import cn.hutool.cache.impl.TimedCache; import cn.stylefeng.roses.kernel.cache.memory.AbstractMemoryCacheOperator; diff --git a/kernel-d-security/security-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/security/starter/CaptchaAutoConfiguration.java b/kernel-d-security/security-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/security/starter/CaptchaAutoConfiguration.java index e0b2b08cd..1a976d0d4 100644 --- a/kernel-d-security/security-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/security/starter/CaptchaAutoConfiguration.java +++ b/kernel-d-security/security-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/security/starter/CaptchaAutoConfiguration.java @@ -26,10 +26,10 @@ package cn.stylefeng.roses.kernel.security.starter; import cn.hutool.cache.CacheUtil; import cn.hutool.cache.impl.TimedCache; -import cn.stylefeng.roses.kemel.security.captcha.CaptchaService; -import cn.stylefeng.roses.kemel.security.captcha.cache.CaptchaMemoryCache; import cn.stylefeng.roses.kernel.cache.api.constants.CacheConstants; import cn.stylefeng.roses.kernel.security.api.CaptchaApi; +import cn.stylefeng.roses.kernel.security.captcha.CaptchaService; +import cn.stylefeng.roses.kernel.security.captcha.cache.CaptchaMemoryCache; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/kernel-d-security/security-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/security/starter/CounterAutoConfiguration.java b/kernel-d-security/security-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/security/starter/CounterAutoConfiguration.java index dfb748888..a40298637 100644 --- a/kernel-d-security/security-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/security/starter/CounterAutoConfiguration.java +++ b/kernel-d-security/security-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/security/starter/CounterAutoConfiguration.java @@ -26,16 +26,16 @@ package cn.stylefeng.roses.kernel.security.starter; import cn.hutool.cache.CacheUtil; import cn.hutool.cache.impl.TimedCache; -import cn.stylefeng.roses.kemel.security.blackwhite.BlackListService; -import cn.stylefeng.roses.kemel.security.blackwhite.WhiteListService; -import cn.stylefeng.roses.kemel.security.blackwhite.cache.BlackListMemoryCache; -import cn.stylefeng.roses.kemel.security.blackwhite.cache.WhiteListMemoryCache; -import cn.stylefeng.roses.kemel.security.count.DefaultCountValidator; -import cn.stylefeng.roses.kemel.security.count.cache.DefaultCountValidateCache; import cn.stylefeng.roses.kernel.cache.api.constants.CacheConstants; import cn.stylefeng.roses.kernel.security.api.BlackListApi; import cn.stylefeng.roses.kernel.security.api.CountValidatorApi; import cn.stylefeng.roses.kernel.security.api.WhiteListApi; +import cn.stylefeng.roses.kernel.security.blackwhite.BlackListService; +import cn.stylefeng.roses.kernel.security.blackwhite.WhiteListService; +import cn.stylefeng.roses.kernel.security.blackwhite.cache.BlackListMemoryCache; +import cn.stylefeng.roses.kernel.security.blackwhite.cache.WhiteListMemoryCache; +import cn.stylefeng.roses.kernel.security.count.DefaultCountValidator; +import cn.stylefeng.roses.kernel.security.count.cache.DefaultCountValidateCache; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;