From a2ce42c0f31f4dc417a5b1e35fc67c44c074277b Mon Sep 17 00:00:00 2001 From: "Yangkai.Shen" <237497819@qq.com> Date: Wed, 9 Oct 2019 15:46:26 +0800 Subject: [PATCH] =?UTF-8?q?:truck:=20=E7=A7=BB=E5=8A=A8=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 21 +++++++------------ .../xkcoding/justauth/AuthRequestFactory.java | 4 ++-- .../CacheProperties.java | 2 +- .../ExtendProperties.java | 2 +- .../JustAuthAutoConfiguration.java | 4 ++-- .../JustAuthProperties.java | 2 +- .../JustAuthStateCacheConfiguration.java | 5 ++--- .../{ => support}/cache/RedisStateCache.java | 4 ++-- ...itional-spring-configuration-metadata.json | 4 ++-- src/main/resources/META-INF/spring.factories | 2 +- 10 files changed, 21 insertions(+), 29 deletions(-) rename src/main/java/com/xkcoding/justauth/{properties => autoconfigure}/CacheProperties.java (97%) rename src/main/java/com/xkcoding/justauth/{properties => autoconfigure}/ExtendProperties.java (96%) rename src/main/java/com/xkcoding/justauth/{ => autoconfigure}/JustAuthAutoConfiguration.java (95%) rename src/main/java/com/xkcoding/justauth/{properties => autoconfigure}/JustAuthProperties.java (97%) rename src/main/java/com/xkcoding/justauth/{ => autoconfigure}/JustAuthStateCacheConfiguration.java (96%) rename src/main/java/com/xkcoding/justauth/{ => support}/cache/RedisStateCache.java (96%) diff --git a/README.md b/README.md index ac427a0..c753a41 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ https://github.com/xkcoding/justauth-spring-boot-starter-demo com.xkcoding justauth-spring-boot-starter - 1.1.0 + 1.2.0 ``` @@ -65,25 +65,18 @@ public class TestController { @GetMapping("/login/{type}") public void login(@PathVariable String type, HttpServletResponse response) throws IOException { - AuthRequest authRequest = factory.get(getAuthSource(type)); + AuthRequest authRequest = factory.get(type); response.sendRedirect(authRequest.authorize(AuthStateUtils.createState())); } @RequestMapping("/{type}/callback") public AuthResponse login(@PathVariable String type, AuthCallback callback) { - AuthRequest authRequest = factory.get(getAuthSource(type)); + AuthRequest authRequest = factory.get(type); AuthResponse response = authRequest.login(callback); log.info("【response】= {}", JSONUtil.toJsonStr(response)); return response; } - private AuthSource getAuthSource(String type) { - if (StrUtil.isNotBlank(type)) { - return AuthSource.valueOf(type.toUpperCase()); - } else { - throw new RuntimeException("不支持的类型"); - } - } } ``` @@ -250,7 +243,7 @@ public class AuthStateConfiguration { | ------------------ | ------------------------------------------------------------ | ------ | ---------- | ----------------- | | `justauth.enabled` | `boolean` | true | true/false | 是否启用 JustAuth | | `justauth.type` | `java.util.Map` | 无 | | JustAuth 配置 | -| `justauth.cache` | `com.xkcoding.justauth.properties.CacheProperties` | | | JustAuth缓存配置 | +| `justauth.cache` | `com.xkcoding.justauth.autoconfigure.CacheProperties` | | | JustAuth缓存配置 | `justauth.type` 配置列表 @@ -263,7 +256,7 @@ public class AuthStateConfiguration { | 属性名 | 类型 | 默认值 | 可选项 | 描述 | | ------------------------ | ------------------------------------------------------------ | ----------------- | -------------------- | ------------------------------------------------------------ | -| `justauth.cache.type` | `com.xkcoding.justauth.properties.CacheProperties.CacheType` | default | default/redis/custom | 缓存类型,default使用JustAuth默认的缓存实现,redis使用默认的redis缓存实现,custom用户自定义缓存实现 | +| `justauth.cache.type` | `com.xkcoding.justauth.autoconfigure.CacheProperties.CacheType` | default | default/redis/custom | 缓存类型,default使用JustAuth默认的缓存实现,redis使用默认的redis缓存实现,custom用户自定义缓存实现 | | `justauth.cache.prefix` | `string` | JUSTAUTH::STATE:: | | 缓存前缀,目前只对redis缓存生效,默认 JUSTAUTH::STATE:: | | `justauth.cache.timeout` | `java.time.Duration` | 3分钟 | | 超时时长,目前只对redis缓存生效,默认3分钟 | @@ -281,8 +274,8 @@ public class AuthStateConfiguration { - xkcoding-nexus - xkcoding nexus + oss + oss http://oss.sonatype.org/content/repositories/snapshots true diff --git a/src/main/java/com/xkcoding/justauth/AuthRequestFactory.java b/src/main/java/com/xkcoding/justauth/AuthRequestFactory.java index 43083d1..ab29d1f 100644 --- a/src/main/java/com/xkcoding/justauth/AuthRequestFactory.java +++ b/src/main/java/com/xkcoding/justauth/AuthRequestFactory.java @@ -21,8 +21,8 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.EnumUtil; import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.StrUtil; -import com.xkcoding.justauth.properties.ExtendProperties; -import com.xkcoding.justauth.properties.JustAuthProperties; +import com.xkcoding.justauth.autoconfigure.ExtendProperties; +import com.xkcoding.justauth.autoconfigure.JustAuthProperties; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.zhyd.oauth.cache.AuthStateCache; diff --git a/src/main/java/com/xkcoding/justauth/properties/CacheProperties.java b/src/main/java/com/xkcoding/justauth/autoconfigure/CacheProperties.java similarity index 97% rename from src/main/java/com/xkcoding/justauth/properties/CacheProperties.java rename to src/main/java/com/xkcoding/justauth/autoconfigure/CacheProperties.java index a1a610e..67b5441 100644 --- a/src/main/java/com/xkcoding/justauth/properties/CacheProperties.java +++ b/src/main/java/com/xkcoding/justauth/autoconfigure/CacheProperties.java @@ -15,7 +15,7 @@ * */ -package com.xkcoding.justauth.properties; +package com.xkcoding.justauth.autoconfigure; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/xkcoding/justauth/properties/ExtendProperties.java b/src/main/java/com/xkcoding/justauth/autoconfigure/ExtendProperties.java similarity index 96% rename from src/main/java/com/xkcoding/justauth/properties/ExtendProperties.java rename to src/main/java/com/xkcoding/justauth/autoconfigure/ExtendProperties.java index 30a912d..303a795 100644 --- a/src/main/java/com/xkcoding/justauth/properties/ExtendProperties.java +++ b/src/main/java/com/xkcoding/justauth/autoconfigure/ExtendProperties.java @@ -15,7 +15,7 @@ * */ -package com.xkcoding.justauth.properties; +package com.xkcoding.justauth.autoconfigure; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/xkcoding/justauth/JustAuthAutoConfiguration.java b/src/main/java/com/xkcoding/justauth/autoconfigure/JustAuthAutoConfiguration.java similarity index 95% rename from src/main/java/com/xkcoding/justauth/JustAuthAutoConfiguration.java rename to src/main/java/com/xkcoding/justauth/autoconfigure/JustAuthAutoConfiguration.java index 824f7dc..6dbdb8f 100644 --- a/src/main/java/com/xkcoding/justauth/JustAuthAutoConfiguration.java +++ b/src/main/java/com/xkcoding/justauth/autoconfigure/JustAuthAutoConfiguration.java @@ -15,9 +15,9 @@ * */ -package com.xkcoding.justauth; +package com.xkcoding.justauth.autoconfigure; -import com.xkcoding.justauth.properties.JustAuthProperties; +import com.xkcoding.justauth.AuthRequestFactory; import lombok.extern.slf4j.Slf4j; import me.zhyd.oauth.cache.AuthStateCache; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; diff --git a/src/main/java/com/xkcoding/justauth/properties/JustAuthProperties.java b/src/main/java/com/xkcoding/justauth/autoconfigure/JustAuthProperties.java similarity index 97% rename from src/main/java/com/xkcoding/justauth/properties/JustAuthProperties.java rename to src/main/java/com/xkcoding/justauth/autoconfigure/JustAuthProperties.java index 93fd932..213c9b8 100644 --- a/src/main/java/com/xkcoding/justauth/properties/JustAuthProperties.java +++ b/src/main/java/com/xkcoding/justauth/autoconfigure/JustAuthProperties.java @@ -15,7 +15,7 @@ * */ -package com.xkcoding.justauth.properties; +package com.xkcoding.justauth.autoconfigure; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/xkcoding/justauth/JustAuthStateCacheConfiguration.java b/src/main/java/com/xkcoding/justauth/autoconfigure/JustAuthStateCacheConfiguration.java similarity index 96% rename from src/main/java/com/xkcoding/justauth/JustAuthStateCacheConfiguration.java rename to src/main/java/com/xkcoding/justauth/autoconfigure/JustAuthStateCacheConfiguration.java index 6a19c55..51352a0 100644 --- a/src/main/java/com/xkcoding/justauth/JustAuthStateCacheConfiguration.java +++ b/src/main/java/com/xkcoding/justauth/autoconfigure/JustAuthStateCacheConfiguration.java @@ -15,10 +15,9 @@ * */ -package com.xkcoding.justauth; +package com.xkcoding.justauth.autoconfigure; -import com.xkcoding.justauth.cache.RedisStateCache; -import com.xkcoding.justauth.properties.JustAuthProperties; +import com.xkcoding.justauth.support.cache.RedisStateCache; import lombok.extern.slf4j.Slf4j; import me.zhyd.oauth.cache.AuthDefaultStateCache; import me.zhyd.oauth.cache.AuthStateCache; diff --git a/src/main/java/com/xkcoding/justauth/cache/RedisStateCache.java b/src/main/java/com/xkcoding/justauth/support/cache/RedisStateCache.java similarity index 96% rename from src/main/java/com/xkcoding/justauth/cache/RedisStateCache.java rename to src/main/java/com/xkcoding/justauth/support/cache/RedisStateCache.java index 6a8ddab..44cbfa6 100644 --- a/src/main/java/com/xkcoding/justauth/cache/RedisStateCache.java +++ b/src/main/java/com/xkcoding/justauth/support/cache/RedisStateCache.java @@ -15,9 +15,9 @@ * */ -package com.xkcoding.justauth.cache; +package com.xkcoding.justauth.support.cache; -import com.xkcoding.justauth.properties.CacheProperties; +import com.xkcoding.justauth.autoconfigure.CacheProperties; import lombok.RequiredArgsConstructor; import me.zhyd.oauth.cache.AuthStateCache; import org.springframework.data.redis.core.RedisTemplate; diff --git a/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/src/main/resources/META-INF/additional-spring-configuration-metadata.json index e0c7c4e..b241307 100644 --- a/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -4,7 +4,7 @@ "name": "justauth.type", "type": "java.util.Map", "description": "JustAuth 配置.", - "sourceType": "com.xkcoding.justauth.properties.JustAuthProperties" + "sourceType": "com.xkcoding.justauth.autoconfigure.JustAuthProperties" } ], "hints": [ @@ -129,4 +129,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories index 2341e0f..ea0d979 100644 --- a/src/main/resources/META-INF/spring.factories +++ b/src/main/resources/META-INF/spring.factories @@ -1,2 +1,2 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - com.xkcoding.justauth.JustAuthAutoConfiguration + com.xkcoding.justauth.autoconfigure.JustAuthAutoConfiguration