制定 OAuth2 协议的表结构与 API 设计

pull/2/head
YunaiV 2022-05-08 17:43:24 +08:00
parent 5e8648508e
commit ebee4ddb7c
12 changed files with 203 additions and 14 deletions

View File

@ -0,0 +1,12 @@
package cn.iocoder.yudao.module.system.api.auth;
/**
* OAuth2.0 API
*
* @author
*/
public interface OAuth2Api {
}

View File

@ -40,7 +40,7 @@ import static java.util.Collections.singleton;
@Api(tags = "管理后台 - 认证")
@RestController
@RequestMapping("/system/auth") // 暂时不跟 /auth 结尾
@RequestMapping("/system/auth")
@Validated
@Slf4j
public class AuthController {

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.system.controller.admin.auth;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "管理后台 - OAuth2.0 授权")
@RestController
@RequestMapping("/system/oauth2")
@Validated
@Slf4j
public class OAuth2Controller {
// POST oauth/token TokenEndpointPassword、Implicit、Code、Refresh Token
// POST oauth/check_token CheckTokenEndpoint
// DELETE oauth/token ConsumerTokenServices#revokeToken
// GET oauth/authorize AuthorizationEndpoint
}

View File

@ -10,8 +10,9 @@ import lombok.experimental.Accessors;
import java.util.Date;
/**
* OAuth2 访
* OAuth2 访 DO
*
* @author
*/
@TableName("system_oauth2_access_token")
@Data
@ -20,7 +21,7 @@ import java.util.Date;
public class OAuth2AccessTokenDO extends BaseDO {
/**
*
*
*/
private Long id;
/**
@ -38,18 +39,14 @@ public class OAuth2AccessTokenDO extends BaseDO {
*/
private Integer userType;
/**
*
*
*
* {@link OAuth2RefreshTokenDO#getRefreshToken()}
* {@link OAuth2ApplicationDO#getId()}
*/
private String refreshToken;
private Long applicationId;
/**
*
*/
private Date expiresTime;
/**
* IP
*/
private String createIp;
}

View File

@ -0,0 +1,65 @@
package cn.iocoder.yudao.module.system.dal.dataobject.auth;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* OAuth2 DO
*
* 使 Client
* 1. clientId id
* 2. GithubGitee
*
* 使
* authorized_grant_typesauthoritiesaccess_token_validityrefresh_token_validityadditional_informationautoapproveresource_idsscope
*
* @author
*/
@TableName("system_oauth2_application")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class OAuth2ApplicationDO extends BaseDO {
/**
*
*/
private Long id;
/**
*
*/
private String clientId;
/**
*
*/
private String clientSecret;
/**
* URI
*/
private List<String> redirectUris;
/**
*
*/
private String name;
/**
*
*/
private String logo;
/**
*
*/
private String description;
/**
*
*
* {@link CommonStatusEnum}
*/
private Integer status;
}

View File

@ -0,0 +1,62 @@
package cn.iocoder.yudao.module.system.dal.dataobject.auth;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* OAuth2 DO
*
* @author
*/
@TableName("system_oauth2_code")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class OAuth2CodeDO extends BaseDO {
/**
*
*/
private Long id;
/**
*
*/
private String code;
/**
*
*/
private Long userId;
/**
*
*
* {@link UserTypeEnum}
*/
private Integer userType;
/**
*
*
* {@link OAuth2ApplicationDO#getId()}
*/
private Long applicationId;
/**
*
*
* {@link OAuth2RefreshTokenDO#getRefreshToken()}
*/
private String refreshToken;
/**
*
*/
private Date expiresTime;
/**
* IP
*/
private String createIp;
}

View File

@ -24,6 +24,7 @@ import java.util.Date;
@Data
@Builder
@EqualsAndHashCode(callSuper = true)
@Deprecated
public class UserSessionDO extends BaseDO {
/**

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.system.service.auth;
import cn.iocoder.yudao.framework.security.core.service.SecurityAuthFrameworkService;
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.auth.*;
import javax.validation.Valid;

View File

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.system.service.auth;
/**
* OAuth2 Service
*
* AdminUser OAuth2.0
*
*
* Implicit 使OAuth2.0
*
* @author
*/
public interface AdminOAuth2Service {
}

View File

@ -0,0 +1,11 @@
package cn.iocoder.yudao.module.system.service.auth;
/**
* OAuth2.0 Service
*
* Spring Security OAuth JdbcAuthorizationCodeServices
*
* @author
*/
public class OAuth2CodeService {
}

View File

@ -5,10 +5,12 @@ import org.springframework.stereotype.Service;
/**
* OAuth2.0 Service
*
*
*
* @author
*/
@Service
public class OAuth2ServiceImpl implements OAuth2Service {
public class OAuth2ServiceImpl implements OAuth2TokenService {
// @Autowired
// private SystemBizProperties systemBizProperties;

View File

@ -1,11 +1,13 @@
package cn.iocoder.yudao.module.system.service.auth;
/**
* OAuth2.0 Service
* OAuth2.0 Token Service
*
* Spring Security OAuth JdbcTokenStore 访
*
* @author
*/
public interface OAuth2Service {
public interface OAuth2TokenService {
// OAuth2AccessTokenDO createAccessToken(Long userId, Integer userType, String createIp);
//