Explorar o código

优化OAuth2 server

zhouhao %!s(int64=7) %!d(string=hai) anos
pai
achega
33fb475f49

+ 0 - 2
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/OAuth2Granter.java

@@ -22,8 +22,6 @@ import org.hswebframework.web.authorization.oauth2.server.TokenRequest;
 import org.hswebframework.web.authorization.oauth2.server.OAuth2AccessToken;
 
 /**
- * TODO 完成注释
- *
  * @author zhouhao
  */
 public interface OAuth2Granter {

+ 0 - 2
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/implicit/DefaultImplicitGranter.java

@@ -34,8 +34,6 @@ import java.util.Set;
 import static org.hswebframework.web.oauth2.core.ErrorType.*;
 
 /**
- * TODO 完成注释
- *
  * @author zhouhao
  */
 public class DefaultImplicitGranter extends AbstractAuthorizationService implements ImplicitGranter {

+ 0 - 2
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/implicit/ImplicitRequest.java

@@ -23,8 +23,6 @@ import org.hswebframework.web.authorization.oauth2.server.TokenRequest;
 import java.util.Set;
 
 /**
- * TODO 完成注释
- *
  * @author zhouhao
  */
 public interface ImplicitRequest extends TokenRequest {

+ 0 - 2
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/password/DefaultPasswordGranter.java

@@ -31,8 +31,6 @@ import java.util.Set;
 import static org.hswebframework.web.oauth2.core.ErrorType.*;
 
 /**
- * TODO 完成注释
- *
  * @author zhouhao
  */
 public class DefaultPasswordGranter extends AbstractAuthorizationService implements PasswordGranter {

+ 0 - 2
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/refresh/DefaultRefreshTokenGranter.java

@@ -34,8 +34,6 @@ import java.util.Set;
 import static org.hswebframework.web.oauth2.core.ErrorType.*;
 
 /**
- * TODO 完成注释
- *
  * @author zhouhao
  */
 public class DefaultRefreshTokenGranter extends AbstractAuthorizationService implements RefreshTokenGranter {

+ 0 - 2
hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/src/main/java/org/hswebframework/web/authorization/oauth2/server/support/refresh/RefreshTokenGranter.java

@@ -22,8 +22,6 @@ import org.hswebframework.web.authorization.oauth2.server.AuthorizationService;
 import org.hswebframework.web.authorization.oauth2.server.OAuth2AccessToken;
 
 /**
- * TODO 完成注释
- *
  * @author zhouhao
  */
 public interface RefreshTokenGranter extends AuthorizationService {

+ 12 - 2
hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/java/org/hswebframework/web/oauth2/OAuth2GranterAutoConfiguration.java

@@ -31,6 +31,8 @@ import org.hswebframework.web.authorization.oauth2.server.support.implicit.Impli
 import org.hswebframework.web.authorization.oauth2.server.support.password.DefaultPasswordGranter;
 import org.hswebframework.web.authorization.oauth2.server.support.password.PasswordGranter;
 import org.hswebframework.web.authorization.oauth2.server.support.password.PasswordService;
+import org.hswebframework.web.authorization.oauth2.server.support.refresh.DefaultRefreshTokenGranter;
+import org.hswebframework.web.authorization.oauth2.server.support.refresh.RefreshTokenGranter;
 import org.hswebframework.web.authorization.oauth2.server.token.AccessTokenService;
 import org.hswebframework.web.commons.entity.factory.EntityFactory;
 import org.hswebframework.web.dao.oauth2.AuthorizationCodeDao;
@@ -42,14 +44,13 @@ import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.config.BeanPostProcessor;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 
 
 /**
- * TODO 完成注释
- *
  * @author zhouhao
  */
 @Configuration
@@ -136,6 +137,12 @@ public class OAuth2GranterAutoConfiguration {
             return setProperty(new DefaultImplicitGranter());
         }
 
+        @Bean
+        @ConditionalOnMissingBean(RefreshTokenGranter.class)
+        @ConfigurationProperties(prefix = "hsweb.oauth2.server")
+        public RefreshTokenGranter refreshTokenGranter() {
+            return setProperty(new DefaultRefreshTokenGranter());
+        }
     }
 
     @Bean
@@ -158,6 +165,9 @@ public class OAuth2GranterAutoConfiguration {
             if (bean instanceof ImplicitGranter) {
                 addImplicitSupport(((ImplicitGranter) bean));
             }
+            if (bean instanceof RefreshTokenGranter) {
+                addRefreshTokenSupport(((RefreshTokenGranter) bean));
+            }
             return bean;
         }