mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-06-20 19:46:05 +08:00
优化OAuth2 server
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -23,8 +23,6 @@ import org.hswebframework.web.authorization.oauth2.server.TokenRequest;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* TODO 完成注释
|
||||
*
|
||||
* @author zhouhao
|
||||
*/
|
||||
public interface ImplicitRequest extends TokenRequest {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user