优化OAuth2 server

This commit is contained in:
zhouhao
2017-10-25 12:45:03 +08:00
parent 6fd6aa71aa
commit 33fb475f49
7 changed files with 12 additions and 14 deletions

View File

@@ -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 {

View File

@@ -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 {

View File

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

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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;
}