Browse Source

新增查询租户列表接口

tags/v2.4.0
xiaoying 1 year ago
parent
commit
57fb010bec
100 changed files with 1658 additions and 22 deletions
  1. +19
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/common/BaseQuery.java
  2. +1
    -1
      tuoheng_oidc_admin/src/main/java/com/tuoheng/controller/PlatformController.java
  3. +4
    -4
      tuoheng_oidc_admin/src/main/java/com/tuoheng/controller/TenantController.java
  4. +3
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/AuthoritiesMapper.java
  5. +3
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/ClientUserMapper.java
  6. +20
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/Oauth2RegisteredClientMapper.java
  7. +7
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/TenantMapper.java
  8. +81
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/model/dto/Oauth2RegisteredClient.java
  9. +16
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/model/query/TenantQuery.java
  10. +21
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/model/vo/BusinessSystemVo.java
  11. +31
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/model/vo/TenantVo.java
  12. +2
    -1
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/ClientUserSevice.java
  13. +13
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/Oauth2RegisteredClientService.java
  14. +1
    -1
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/PlatformService.java
  15. +44
    -8
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java
  16. +22
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/Oauth2RegisteredClientServiceImpl.java
  17. +1
    -1
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/PlatformServiceImpl.java
  18. +7
    -2
      tuoheng_oidc_admin/src/main/resources/mapper/AuthoritiesMapper.xml
  19. +19
    -4
      tuoheng_oidc_admin/src/main/resources/mapper/ClientUserMapper.xml
  20. +28
    -0
      tuoheng_oidc_admin/src/main/resources/mapper/Oauth2RegisteredClientMapper.xml
  21. +9
    -0
      tuoheng_oidc_admin/src/main/resources/mapper/TenantMapper.xml
  22. +68
    -0
      tuoheng_oidc_admin/target/classes/WEB-INF/classes/application-dev.yml
  23. +68
    -0
      tuoheng_oidc_admin/target/classes/application-dev.yml
  24. +67
    -0
      tuoheng_oidc_admin/target/classes/application-local.yml
  25. +67
    -0
      tuoheng_oidc_admin/target/classes/application-prod.yml
  26. +67
    -0
      tuoheng_oidc_admin/target/classes/application-test.yml
  27. +13
    -0
      tuoheng_oidc_admin/target/classes/application.yml
  28. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/TuohengOidcAdminApplication.class
  29. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/common/ExceptionInterface.class
  30. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/common/ServiceException.class
  31. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/config/LoginUserHandler.class
  32. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/config/WebConfig.class
  33. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/config/http/HeadClientHttpRequestInterceptor.class
  34. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/config/http/RestProperties.class
  35. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/config/http/RestTemplateConfig$1.class
  36. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/config/http/RestTemplateConfig.class
  37. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/constant/HhzUrlConstant.class
  38. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/controller/ClientController.class
  39. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/controller/DemoController.class
  40. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/controller/PlatformController.class
  41. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/controller/TenantController.class
  42. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/controller/UserController.class
  43. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/mapper/AuthoritiesMapper.class
  44. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/mapper/ClientMapper.class
  45. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/mapper/ClientUserMapper.class
  46. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/mapper/ClientUserRoleMapper.class
  47. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/mapper/PlatformMapper.class
  48. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/mapper/TenantMapper.class
  49. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/dto/ClientDto.class
  50. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/dto/ClientRoleInfoDto.class
  51. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/dto/LoginUser.class
  52. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/dto/OidcTenantDto.class
  53. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/dto/Platform.class
  54. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/dto/TTenant.class
  55. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/dto/UserBaseInfoDto.class
  56. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/param/ClientRoleDto.class
  57. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/param/CreateClientTenantDto.class
  58. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/param/CreateClientUserDto.class
  59. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/param/GetClientTenantRoleDto.class
  60. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/param/GetUserInfoDto.class
  61. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/param/UpdateUserClientRoleDto.class
  62. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/param/UpdateUserPassDto.class
  63. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/po/AuthoritiesPo.class
  64. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/po/BasePo.class
  65. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/po/ClientUserRolePo.class
  66. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/po/TenantPo.class
  67. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/model/po/UserPo.class
  68. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/service/ClientSevice.class
  69. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/service/ClientUserSevice.class
  70. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/service/CurrentUser.class
  71. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/service/impl/ClientServiceImpl.class
  72. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/service/impl/ClientUserServiceImpl.class
  73. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/service/impl/PlatformServiceImpl.class
  74. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/until/CryptoUtil.class
  75. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/until/EncryptUtil.class
  76. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/until/JsonResult.class
  77. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/until/RedisUtils.class
  78. +69
    -0
      tuoheng_oidc_admin/target/classes/logback.xml
  79. +18
    -0
      tuoheng_oidc_admin/target/classes/mapper/AuthoritiesMapper.xml
  80. +9
    -0
      tuoheng_oidc_admin/target/classes/mapper/ClientMapper.xml
  81. +47
    -0
      tuoheng_oidc_admin/target/classes/mapper/ClientUserMapper.xml
  82. +31
    -0
      tuoheng_oidc_admin/target/classes/mapper/ClientUserRoleMapper.xml
  83. +24
    -0
      tuoheng_oidc_admin/target/classes/mapper/PlatformMapper.xml
  84. +24
    -0
      tuoheng_oidc_admin/target/classes/mapper/TenantMapper.xml
  85. +62
    -0
      tuoheng_oidc_server/target/classes/WEB-INF/classes/application-dev.yml
  86. +60
    -0
      tuoheng_oidc_server/target/classes/WEB-INF/classes/application-local.yml
  87. +60
    -0
      tuoheng_oidc_server/target/classes/WEB-INF/classes/application-prod.yml
  88. +61
    -0
      tuoheng_oidc_server/target/classes/WEB-INF/classes/application-test.yml
  89. +12
    -0
      tuoheng_oidc_server/target/classes/WEB-INF/classes/application.yml
  90. +69
    -0
      tuoheng_oidc_server/target/classes/WEB-INF/classes/logback.xml
  91. +13
    -0
      tuoheng_oidc_server/target/classes/WEB-INF/classes/mapper/AuthoritiesMapper.xml
  92. +39
    -0
      tuoheng_oidc_server/target/classes/WEB-INF/classes/mapper/UserMapper.xml
  93. BIN
      tuoheng_oidc_server/target/classes/WEB-INF/classes/static/back.png
  94. BIN
      tuoheng_oidc_server/target/classes/WEB-INF/classes/static/form.png
  95. +2
    -0
      tuoheng_oidc_server/target/classes/WEB-INF/classes/static/jquery-3.5.1.min.js
  96. +174
    -0
      tuoheng_oidc_server/target/classes/WEB-INF/classes/templates/login.html
  97. +62
    -0
      tuoheng_oidc_server/target/classes/application-dev.yml
  98. +60
    -0
      tuoheng_oidc_server/target/classes/application-local.yml
  99. +60
    -0
      tuoheng_oidc_server/target/classes/application-prod.yml
  100. +0
    -0
      tuoheng_oidc_server/target/classes/application-test.yml

+ 19
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/common/BaseQuery.java View File

@@ -0,0 +1,19 @@
package com.tuoheng.common;

import lombok.Data;

/**
* 查询对象基类
*/
@Data
public class BaseQuery {
/**
* 页码
*/
private Integer page;

/**
* 每页数
*/
private Integer limit;
}

+ 1
- 1
tuoheng_oidc_admin/src/main/java/com/tuoheng/controller/PlatformController.java View File

@@ -1,6 +1,6 @@
package com.tuoheng.controller;

import com.tuoheng.model.service.PlatformService;
import com.tuoheng.service.PlatformService;
import com.tuoheng.until.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;

+ 4
- 4
tuoheng_oidc_admin/src/main/java/com/tuoheng/controller/TenantController.java View File

@@ -3,7 +3,7 @@ package com.tuoheng.controller;
import com.tuoheng.model.dto.LoginUser;
import com.tuoheng.model.dto.OidcTenantDto;
import com.tuoheng.model.param.CreateClientTenantDto;
import com.tuoheng.model.param.CreateClientUserDto;
import com.tuoheng.model.query.TenantQuery;
import com.tuoheng.service.ClientUserSevice;
import com.tuoheng.service.CurrentUser;
import com.tuoheng.until.JsonResult;
@@ -45,8 +45,8 @@ public class TenantController {
* @return
*/
@GetMapping("/list")
public JsonResult list(){
return clientUserSevice.findTenants();
public JsonResult list(TenantQuery query){
return clientUserSevice.findTenants(query);
}
}

+ 3
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/AuthoritiesMapper.java View File

@@ -2,6 +2,7 @@ package com.tuoheng.mapper;

import com.tuoheng.model.po.AuthoritiesPo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@@ -15,4 +16,6 @@ public interface AuthoritiesMapper {

int batchInsert(List<AuthoritiesPo> list);

List<AuthoritiesPo> selectByUserId(@Param("userId") Long userId);

}

+ 3
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/ClientUserMapper.java View File

@@ -2,6 +2,7 @@ package com.tuoheng.mapper;

import com.tuoheng.model.po.UserPo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
* @author chenjiandong
@@ -19,4 +20,6 @@ public interface ClientUserMapper {

int updatePass(UserPo userPo);

UserPo selectByUserId(@Param("userId") Long userId);

}

+ 20
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/Oauth2RegisteredClientMapper.java View File

@@ -0,0 +1,20 @@
package com.tuoheng.mapper;

import com.tuoheng.model.dto.Oauth2RegisteredClient;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

/**
* @author 小影
* @description 针对表【oauth2_registered_client】的数据库操作Mapper
* @createDate 2023-01-10 15:10:32
* @Entity com.tuoheng.model.dto.Oauth2RegisteredClient
*/
@Mapper
public interface Oauth2RegisteredClientMapper extends BaseMapper<Oauth2RegisteredClient> {

}





+ 7
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/TenantMapper.java View File

@@ -1,11 +1,16 @@
package com.tuoheng.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tuoheng.model.dto.TTenant;
import com.tuoheng.model.po.TenantPo;
import com.tuoheng.model.query.TenantQuery;
import com.tuoheng.model.vo.TenantVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author chenjiandong
* @description: TODO
@@ -17,4 +22,6 @@ public interface TenantMapper {
int insertTenant(TenantPo tenantPo);

TTenant getByCode(@Param("code") String code);

IPage<TenantPo> findList(@Param("page") IPage<TenantVo> page, TenantQuery query);
}

+ 81
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/model/dto/Oauth2RegisteredClient.java View File

@@ -0,0 +1,81 @@
package com.tuoheng.model.dto;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;

/**
*
* @TableName oauth2_registered_client
*/
@TableName(value ="oauth2_registered_client")
@Data
public class Oauth2RegisteredClient implements Serializable {
/**
*
*/
@TableId
private String id;

/**
*
*/
private String clientId;

/**
*
*/
private Date clientIdIssuedAt;

/**
*
*/
private String clientSecret;

/**
*
*/
private Date clientSecretExpiresAt;

/**
*
*/
private String clientName;

/**
*
*/
private String clientAuthenticationMethods;

/**
*
*/
private String authorizationGrantTypes;

/**
*
*/
private String redirectUris;

/**
*
*/
private String scopes;

/**
*
*/
private String clientSettings;

/**
*
*/
private String tokenSettings;

@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

+ 16
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/model/query/TenantQuery.java View File

@@ -0,0 +1,16 @@
package com.tuoheng.model.query;

import com.tuoheng.common.BaseQuery;
import lombok.Data;

/**
* @Author xiaoying
* @Date 2023/1/10 14:34
*/
@Data
public class TenantQuery extends BaseQuery {
/**
* 租户名称
*/
private String name;
}

+ 21
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/model/vo/BusinessSystemVo.java View File

@@ -0,0 +1,21 @@
package com.tuoheng.model.vo;

import lombok.Data;

/**
* 各业务系统的clientId及名称返回实体类
* @Author xiaoying
* @Date 2023/1/10 14:45
*/
@Data
public class BusinessSystemVo {
/**
* 系统标识
*/
private String clientId;
/**
* 系统名称
*/
private String name;

}

+ 31
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/model/vo/TenantVo.java View File

@@ -0,0 +1,31 @@
package com.tuoheng.model.vo;

import lombok.Data;

import java.util.List;

/**
* 租户列表展示返回类
* @Author xiaoying
* @Date 2023/1/10 14:39
*/
@Data
public class TenantVo {
/**
* 租户名称
*/
private String name;
/**
* 租户code
*/
private String code;
/**
* 用户名
*/
private String username;
/**
* 租户绑定的业务系统等
*/
private List<BusinessSystemVo> list;

}

+ 2
- 1
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/ClientUserSevice.java View File

@@ -6,6 +6,7 @@ import com.tuoheng.model.param.CreateClientTenantDto;
import com.tuoheng.model.param.CreateClientUserDto;
import com.tuoheng.model.param.UpdateUserClientRoleDto;
import com.tuoheng.model.param.UpdateUserPassDto;
import com.tuoheng.model.query.TenantQuery;
import com.tuoheng.until.JsonResult;

/**
@@ -32,6 +33,6 @@ public interface ClientUserSevice {
*/
JsonResult addTenant(OidcTenantDto dto,LoginUser loginUser);

JsonResult findTenants();
JsonResult findTenants(TenantQuery query);

}

+ 13
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/Oauth2RegisteredClientService.java View File

@@ -0,0 +1,13 @@
package com.tuoheng.service;

import com.tuoheng.model.dto.Oauth2RegisteredClient;
import com.baomidou.mybatisplus.extension.service.IService;

/**
* @author 小影
* @description 针对表【oauth2_registered_client】的数据库操作Service
* @createDate 2023-01-10 15:10:32
*/
public interface Oauth2RegisteredClientService extends IService<Oauth2RegisteredClient> {

}

tuoheng_oidc_admin/src/main/java/com/tuoheng/model/service/PlatformService.java → tuoheng_oidc_admin/src/main/java/com/tuoheng/service/PlatformService.java View File

@@ -1,4 +1,4 @@
package com.tuoheng.model.service;
package com.tuoheng.service;

import com.tuoheng.model.dto.Platform;
import com.baomidou.mybatisplus.extension.service.IService;

+ 44
- 8
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java View File

@@ -1,23 +1,25 @@
package com.tuoheng.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.common.ServiceException;
import com.tuoheng.constant.HhzUrlConstant;
import com.tuoheng.mapper.*;
import com.tuoheng.model.dto.LoginUser;
import com.tuoheng.model.dto.OidcTenantDto;
import com.tuoheng.model.dto.Platform;
import com.tuoheng.model.dto.TTenant;
import com.tuoheng.model.dto.*;
import com.tuoheng.model.param.*;
import com.tuoheng.model.po.AuthoritiesPo;
import com.tuoheng.model.po.ClientUserRolePo;
import com.tuoheng.model.po.TenantPo;
import com.tuoheng.model.po.UserPo;
import com.tuoheng.model.query.TenantQuery;
import com.tuoheng.model.vo.BusinessSystemVo;
import com.tuoheng.model.vo.TenantVo;
import com.tuoheng.service.ClientUserSevice;
import com.tuoheng.until.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
@@ -54,6 +56,8 @@ public class ClientUserServiceImpl implements ClientUserSevice {

@Autowired
private PlatformMapper platformMapper;
@Autowired
private Oauth2RegisteredClientMapper oauth2RegisteredClientMapper;

@Override
@Transactional(readOnly = true)
@@ -240,13 +244,45 @@ public class ClientUserServiceImpl implements ClientUserSevice {

/**
* 查询租户以及该租户对应绑定的系统等
*
* @return
*/
@Override
public JsonResult findTenants() {
return null;
}
public JsonResult findTenants(TenantQuery query) {
if (ObjectUtil.isNull(query.getPage()) || ObjectUtil.isNull(query.getLimit())) {
return JsonResult.error("分页参数不能为空");
}
IPage<TenantVo> page = new Page<>(query.getPage(), query.getLimit());
IPage<TenantPo> tenantList = tenantMapper.findList(page, query);
List<TenantPo> records = tenantList.getRecords();
List<TenantVo> list = new ArrayList<>();
for (TenantPo tenantPo : records) {
TenantVo vo = new TenantVo();
vo.setCode(tenantPo.getCode());
vo.setName(tenantPo.getName());
Long userId = tenantPo.getUserId();
List<AuthoritiesPo> poList = authoritiesMapper.selectByUserId(userId);
UserPo userPo = clientUserMapper.selectByUserId(userId);
if (null != userPo) {
vo.setUsername(userPo.getUsername());
}
List<BusinessSystemVo> businessSystemVoList = new ArrayList<>();
for (AuthoritiesPo authoritiesPo : poList) {
BusinessSystemVo businessSystemVo = new BusinessSystemVo();
Oauth2RegisteredClient oauth2RegisteredClient = oauth2RegisteredClientMapper.selectOne(Wrappers.<Oauth2RegisteredClient>lambdaQuery()
.eq(Oauth2RegisteredClient::getClientId, authoritiesPo.getAuthority()));
businessSystemVo.setClientId(authoritiesPo.getAuthority());
businessSystemVo.setName(oauth2RegisteredClient.getClientName());
businessSystemVoList.add(businessSystemVo);
}
vo.setList(businessSystemVoList);
list.add(vo);
}
page.setRecords(list);
page.setTotal(list.size());

return JsonResult.success(page);
}


private JsonResult getResult(OidcTenantDto dto, String code, LoginUser loginUser) {

+ 22
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/Oauth2RegisteredClientServiceImpl.java View File

@@ -0,0 +1,22 @@
package com.tuoheng.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tuoheng.model.dto.Oauth2RegisteredClient;
import com.tuoheng.service.Oauth2RegisteredClientService;
import com.tuoheng.mapper.Oauth2RegisteredClientMapper;
import org.springframework.stereotype.Service;

/**
* @author 小影
* @description 针对表【oauth2_registered_client】的数据库操作Service实现
* @createDate 2023-01-10 15:10:32
*/
@Service
public class Oauth2RegisteredClientServiceImpl extends ServiceImpl<Oauth2RegisteredClientMapper, Oauth2RegisteredClient>
implements Oauth2RegisteredClientService{

}





+ 1
- 1
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/PlatformServiceImpl.java View File

@@ -3,7 +3,7 @@ package com.tuoheng.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tuoheng.model.dto.Platform;
import com.tuoheng.model.service.PlatformService;
import com.tuoheng.service.PlatformService;
import com.tuoheng.mapper.PlatformMapper;
import com.tuoheng.until.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;

+ 7
- 2
tuoheng_oidc_admin/src/main/resources/mapper/AuthoritiesMapper.xml View File

@@ -5,9 +5,14 @@
<insert id="batchInsert" parameterType="java.util.List">
insert into authorities (user_id, username, authority, create_user)
VALUES
<foreach collection ="list" item="it" separator =",">
<foreach collection="list" item="it" separator=",">
(#{it.userId}, #{it.username}, #{it.authority}, #{it.createUser})
</foreach >
</foreach>
</insert>
<select id="selectByUserId" resultType="com.tuoheng.model.po.AuthoritiesPo">
SELECT id, user_id, username, authority
FROM authorities
WHERE user_id = #{userId}
</select>

</mapper>

+ 19
- 4
tuoheng_oidc_admin/src/main/resources/mapper/ClientUserMapper.xml View File

@@ -8,20 +8,35 @@
</insert>

<select id="judgeCreateByUserName" parameterType="java.lang.String" resultType="int">
select count(1) from users where username = #{username}
select count(1)
from users
where username = #{username}
</select>

<select id="getUserByUserName" parameterType="java.lang.String" resultType="com.tuoheng.model.po.UserPo">
select * from users where username = #{username}
select *
from users
where username = #{username}
</select>
<select id="selectByUserId" resultType="com.tuoheng.model.po.UserPo">
SELECT id,
username,
`password`,
enabled,
tenant_id,
is_tenant
FROM users
WHERE id = #{userId}
and enabled = 1
</select>

<update id="updatePass" parameterType="com.tuoheng.model.po.UserPo">
update users
<set>
<if test="password != null and password != ''" >
<if test="password != null and password != ''">
password = #{password},
</if>
<if test="updateUser != null" >
<if test="updateUser != null">
update_user = #{updateUser},
</if>
</set>

+ 28
- 0
tuoheng_oidc_admin/src/main/resources/mapper/Oauth2RegisteredClientMapper.xml View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.mapper.Oauth2RegisteredClientMapper">

<resultMap id="BaseResultMap" type="com.tuoheng.model.dto.Oauth2RegisteredClient">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="clientId" column="client_id" jdbcType="VARCHAR"/>
<result property="clientIdIssuedAt" column="client_id_issued_at" jdbcType="TIMESTAMP"/>
<result property="clientSecret" column="client_secret" jdbcType="VARCHAR"/>
<result property="clientSecretExpiresAt" column="client_secret_expires_at" jdbcType="TIMESTAMP"/>
<result property="clientName" column="client_name" jdbcType="VARCHAR"/>
<result property="clientAuthenticationMethods" column="client_authentication_methods" jdbcType="VARCHAR"/>
<result property="authorizationGrantTypes" column="authorization_grant_types" jdbcType="VARCHAR"/>
<result property="redirectUris" column="redirect_uris" jdbcType="VARCHAR"/>
<result property="scopes" column="scopes" jdbcType="VARCHAR"/>
<result property="clientSettings" column="client_settings" jdbcType="VARCHAR"/>
<result property="tokenSettings" column="token_settings" jdbcType="VARCHAR"/>
</resultMap>

<sql id="Base_Column_List">
id,client_id,client_id_issued_at,
client_secret,client_secret_expires_at,client_name,
client_authentication_methods,authorization_grant_types,redirect_uris,
scopes,client_settings,token_settings
</sql>
</mapper>

+ 9
- 0
tuoheng_oidc_admin/src/main/resources/mapper/TenantMapper.xml View File

@@ -12,4 +12,13 @@
from tuoheng_oidc.t_tenant
where code = #{code}
</select>
<select id="findList" resultType="com.tuoheng.model.po.TenantPo">
SELECT id, user_id, remark,enabled, code, name
FROM t_tenant
WHERE enabled = 1
<if test="query.name != null and query.name != ''">
and name LIKE concat('%',#{query.name},'%')
</if>
ORDER BY create_time desc
</select>
</mapper>

+ 68
- 0
tuoheng_oidc_admin/target/classes/WEB-INF/classes/application-dev.yml View File

@@ -0,0 +1,68 @@
spring:
# 注册中心consul地址
cloud:
consul:
host: 192.168.11.13 # consul 所在服务地址
port: 8500 # consul 服务端口
discovery:
## consul ip地址
hostname: 192.168.11.13
# 注册到consul的服务名称
service-name: ${spring.application.name} # 服务提供者名称
instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${server.port} #实例ID
heartbeat:
enabled: true
prefer-ip-address: true
health-check-path: /actuator/health #健康检查
health-check-interval: 10s
# 配置数据源
datasource:
# 使用阿里的Druid连接池
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# 填写你数据库的url、登录名、密码和数据库名
url: jdbc:mysql://192.168.11.13:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
username: root
password: idontcare
druid:
# 连接池的配置信息
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 5
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false

# Redis数据源
redis:
# 缓存库默认索引0
database: 0
# Redis服务器地址
host: 192.168.11.13
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
password:
# 连接超时时间(毫秒)
timeout: 6000
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接

+ 68
- 0
tuoheng_oidc_admin/target/classes/application-dev.yml View File

@@ -0,0 +1,68 @@
spring:
# 注册中心consul地址
cloud:
consul:
host: 192.168.11.13 # consul 所在服务地址
port: 8500 # consul 服务端口
discovery:
## consul ip地址
hostname: 192.168.11.13
# 注册到consul的服务名称
service-name: ${spring.application.name} # 服务提供者名称
instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${server.port} #实例ID
heartbeat:
enabled: true
prefer-ip-address: true
health-check-path: /actuator/health #健康检查
health-check-interval: 10s
# 配置数据源
datasource:
# 使用阿里的Druid连接池
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# 填写你数据库的url、登录名、密码和数据库名
url: jdbc:mysql://192.168.11.13:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
username: root
password: idontcare
druid:
# 连接池的配置信息
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 5
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false

# Redis数据源
redis:
# 缓存库默认索引0
database: 0
# Redis服务器地址
host: 192.168.11.13
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
password:
# 连接超时时间(毫秒)
timeout: 6000
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接

+ 67
- 0
tuoheng_oidc_admin/target/classes/application-local.yml View File

@@ -0,0 +1,67 @@
spring:
# 注册中心consul地址
cloud:
consul:
host: 127.0.0.1 # consul 所在服务地址
port: 8500 # consul 服务端口
discovery:
## consul ip地址
hostname: 127.0.0.1
# 注册到consul的服务名称
service-name: ${spring.application.name} # 服务提供者名称
instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${server.port} #实例ID
heartbeat:
enabled: true
prefer-ip-address: true
health-check-path: /actuator/health #健康检查
health-check-interval: 10s
# 配置数据源
datasource:
# 使用阿里的Druid连接池
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# 填写你数据库的url、登录名、密码和数据库名
url: jdbc:mysql://192.168.11.13:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
username: root
password: idontcare
druid:
# 连接池的配置信息
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 5
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# Redis数据源
redis:
# 缓存库默认索引0
database: 0
# Redis服务器地址
host: 192.168.11.13
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
password:
# 连接超时时间(毫秒)
timeout: 6000
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接

+ 67
- 0
tuoheng_oidc_admin/target/classes/application-prod.yml View File

@@ -0,0 +1,67 @@
spring:
# 注册中心consul地址
cloud:
consul:
host: 172.16.5.12 # consul 所在服务地址
port: 8500 # consul 服务端口
discovery:
## consul ip地址
hostname: 172.16.5.12
# 注册到consul的服务名称
service-name: ${spring.application.name} # 服务提供者名称
instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${server.port} #实例ID
heartbeat:
enabled: true
prefer-ip-address: true
health-check-path: /actuator/health #健康检查
health-check-interval: 10s
# 配置数据源
datasource:
# 使用阿里的Druid连接池
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# 填写你数据库的url、登录名、密码和数据库名
url: jdbc:mysql://rm-uf6x76i111rb1eo48.mysql.rds.aliyuncs.com:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
username: root
password: TH22#2022
druid:
# 连接池的配置信息
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 5
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# Redis数据源
redis:
# 缓存库默认索引0
database: 0
# Redis服务器地址
host: r-uf6r5lm7c7sfdv3ehb.redis.rds.aliyuncs.com
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
password:
# 连接超时时间(毫秒)
timeout: 6000
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接

+ 67
- 0
tuoheng_oidc_admin/target/classes/application-test.yml View File

@@ -0,0 +1,67 @@
spring:
# 注册中心consul地址
cloud:
consul:
host: 172.15.1.11 # consul 所在服务地址
port: 8500 # consul 服务端口
discovery:
## consul ip地址
hostname: 172.15.1.11
# 注册到consul的服务名称
service-name: ${spring.application.name} # 服务提供者名称
instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${server.port} #实例ID
heartbeat:
enabled: true
prefer-ip-address: true
health-check-path: /actuator/health #健康检查
health-check-interval: 10s
# 配置数据源
datasource:
# 使用阿里的Druid连接池
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# 填写你数据库的url、登录名、密码和数据库名
url: jdbc:mysql://rm-uf6z740323e8053pj.mysql.rds.aliyuncs.com:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
username: root
password: TH22#2022
druid:
# 连接池的配置信息
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 5
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# Redis数据源
redis:
# 缓存库默认索引0
database: 0
# Redis服务器地址
host: r-uf6cdzjifj20jszykr.redis.rds.aliyuncs.com
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
password:
# 连接超时时间(毫秒)
timeout: 6000
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接

+ 13
- 0
tuoheng_oidc_admin/target/classes/application.yml View File

@@ -0,0 +1,13 @@
server:
port: 8091

spring:
profiles:
active: dev
application:
name: tuoheng-oidc-admin
main:
allow-bean-definition-overriding: true

mybatis:
mapper-locations: classpath*:mapper/*Mapper.xml

BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/TuohengOidcAdminApplication.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/common/ExceptionInterface.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/common/ServiceException.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/config/LoginUserHandler.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/config/WebConfig.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/config/http/HeadClientHttpRequestInterceptor.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/config/http/RestProperties.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/config/http/RestTemplateConfig$1.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/config/http/RestTemplateConfig.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/constant/HhzUrlConstant.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/controller/ClientController.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/controller/DemoController.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/controller/PlatformController.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/controller/TenantController.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/controller/UserController.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/mapper/AuthoritiesMapper.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/mapper/ClientMapper.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/mapper/ClientUserMapper.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/mapper/ClientUserRoleMapper.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/mapper/PlatformMapper.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/mapper/TenantMapper.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/dto/ClientDto.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/dto/ClientRoleInfoDto.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/dto/LoginUser.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/dto/OidcTenantDto.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/dto/Platform.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/dto/TTenant.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/dto/UserBaseInfoDto.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/param/ClientRoleDto.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/param/CreateClientTenantDto.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/param/CreateClientUserDto.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/param/GetClientTenantRoleDto.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/param/GetUserInfoDto.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/param/UpdateUserClientRoleDto.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/param/UpdateUserPassDto.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/po/AuthoritiesPo.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/po/BasePo.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/po/ClientUserRolePo.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/po/TenantPo.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/model/po/UserPo.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/service/ClientSevice.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/service/ClientUserSevice.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/service/CurrentUser.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/service/impl/ClientServiceImpl.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/service/impl/ClientUserServiceImpl.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/service/impl/PlatformServiceImpl.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/until/CryptoUtil.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/until/EncryptUtil.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/until/JsonResult.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/until/RedisUtils.class View File


+ 69
- 0
tuoheng_oidc_admin/target/classes/logback.xml View File

@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
<!-- scan:当此属性设置为true时,配置文档如果发生改变,将会被重新加载,默认值为true -->
<!-- scanPeriod:设置监测配置文档是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。
当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!--
contextName说明:
每个logger都关联到logger上下文,默认上下文名称为“default”。但可以使用设置成其他名字,
用于区分不同应用程序的记录。一旦设置,不能修改,可以通过%contextName来打印日志上下文名称。
-->
<contextName>tuoheng_oidc_admin</contextName>

<!--定义日志变量-->
<!--<property name="logging.path" value="D:\\idealogs\\tuoheng_oidc"/>-->
<property name="logging.path" value="/data/java/logs/tuoheng_oidc"/>
<!--日志格式: [时间] [级别] [线程] [行号] [logger信息] - [日志信息]-->
<property name="logging.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%level][%thread][%L] %logger - %msg%n"/>
<property name="logging.charset" value="UTF-8"/>
<property name="logging.maxHistory" value="15"/>
<property name="logging.totalSizeCap" value="5GB"/>
<property name="logging.maxFileSize" value="40MB"/>

<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${logging.pattern}</pattern>
<charset>${logging.charset}</charset>
</encoder>
</appender>

<appender name="LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${logging.path}/admin/tuoheng_oidc_admin.log</File>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${logging.path}/admin/tuoheng_oidc_admin-%d-%i.log</fileNamePattern>
<!-- 最大保存天数-->
<maxHistory>${logging.maxHistory}</maxHistory>
<totalSizeCap>${logging.totalSizeCap}</totalSizeCap>
<maxFileSize>${logging.maxFileSize}</maxFileSize>
</rollingPolicy>
<!--编码器-->
<encoder>
<pattern>${logging.pattern}</pattern>
<charset>${logging.charset}</charset>
</encoder>
</appender>

<appender name="file.async" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>512</queueSize>
<includeCallerData>true</includeCallerData>
<appender-ref ref="LOG_FILE" />
</appender>

<logger name="com.tuoheng" level="DEBUG" additivity="false">
<appender-ref ref="console" />
<appender-ref ref="file.async" />
</logger>
<!--log4jdbc -->
<logger name="jdbc.sqltiming" level="DEBUG" additivity="false">
<appender-ref ref="file.async" />
</logger>

<root level="INFO">
<appender-ref ref="console" />
<appender-ref ref="file.async" />
</root>
</configuration>

+ 18
- 0
tuoheng_oidc_admin/target/classes/mapper/AuthoritiesMapper.xml View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.mapper.AuthoritiesMapper">

<insert id="batchInsert" parameterType="java.util.List">
insert into authorities (user_id, username, authority, create_user)
VALUES
<foreach collection="list" item="it" separator=",">
(#{it.userId}, #{it.username}, #{it.authority}, #{it.createUser})
</foreach>
</insert>
<select id="selectByUserId" resultType="com.tuoheng.model.po.AuthoritiesPo">
SELECT id, user_id, username, authority
FROM authorities
WHERE user_id = #{userId}
</select>

</mapper>

+ 9
- 0
tuoheng_oidc_admin/target/classes/mapper/ClientMapper.xml View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.mapper.ClientMapper">

<select id="getAllClient" resultType="com.tuoheng.model.dto.ClientDto">
select client_id as clientId, client_name as clientName from oauth2_registered_client
</select>

</mapper>

+ 47
- 0
tuoheng_oidc_admin/target/classes/mapper/ClientUserMapper.xml View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.mapper.ClientUserMapper">

<insert id="insertClientUser" parameterType="com.tuoheng.model.po.UserPo" keyProperty="id" useGeneratedKeys="true">
insert into users (username, password, create_user, tenant_id, is_tenant)
values (#{username}, #{password}, #{createUser}, #{tenantId}, #{isTenant})
</insert>

<select id="judgeCreateByUserName" parameterType="java.lang.String" resultType="int">
select count(1)
from users
where username = #{username}
</select>

<select id="getUserByUserName" parameterType="java.lang.String" resultType="com.tuoheng.model.po.UserPo">
select *
from users
where username = #{username}
</select>
<select id="selectByUserId" resultType="com.tuoheng.model.po.UserPo">
SELECT id,
username,
`password`,
enabled,
tenant_id,
is_tenant
FROM users
WHERE id = #{userId}
and enabled = 1
</select>

<update id="updatePass" parameterType="com.tuoheng.model.po.UserPo">
update users
<set>
<if test="password != null and password != ''">
password = #{password},
</if>
<if test="updateUser != null">
update_user = #{updateUser},
</if>
</set>
where username = #{username,jdbcType=VARCHAR}
</update>


</mapper>

+ 31
- 0
tuoheng_oidc_admin/target/classes/mapper/ClientUserRoleMapper.xml View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.mapper.ClientUserRoleMapper">

<insert id="batchInsert" parameterType="java.util.List">
insert into t_client_user_role (user_id, client_id, role_id, create_user)
VALUES
<foreach collection ="list" item="it" separator =",">
(#{it.userId}, #{it.clientId}, #{it.roleId}, #{it.createUser})
</foreach >
</insert>

<insert id="insert" parameterType="com.tuoheng.model.po.ClientUserRolePo">
insert into t_client_user_role (user_id, client_id, role_id, create_user)
VALUES (#{userId}, #{clientId}, #{roleId}, #{createUser})
</insert>

<update id="updateUserClientRole" parameterType="com.tuoheng.model.po.ClientUserRolePo">
update t_client_user_role
<set>
<if test="roleId != null" >
role_id = #{roleId},
</if>
<if test="updateUser != null" >
update_user = #{updateUser},
</if>
</set>
where user_id = #{userId} and client_id = #{clientId}
</update>

</mapper>

+ 24
- 0
tuoheng_oidc_admin/target/classes/mapper/PlatformMapper.xml View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.mapper.PlatformMapper">

<resultMap id="BaseResultMap" type="com.tuoheng.model.dto.Platform">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="platformCode" column="platform_code" jdbcType="VARCHAR"/>
<result property="platformName" column="platform_name" jdbcType="VARCHAR"/>
<result property="platformUrl" column="platform_url" jdbcType="VARCHAR"/>
<result property="createUser" column="create_user" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUser" column="update_user" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="mark" column="mark" jdbcType="TINYINT"/>
</resultMap>

<sql id="Base_Column_List">
id,platform_code,platform_name,
platform_url,create_user,create_time,
update_user,update_time,mark
</sql>
</mapper>

+ 24
- 0
tuoheng_oidc_admin/target/classes/mapper/TenantMapper.xml View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.mapper.TenantMapper">

<insert id="insertTenant" parameterType="com.tuoheng.model.po.TenantPo" keyProperty="id" useGeneratedKeys="true">
INSERT INTO t_tenant (user_id, remark, `code`, `name`)
VALUES (#{userId}, #{remark}, #{code}, #{name})
</insert>

<select id="getByCode" resultType="com.tuoheng.model.dto.TTenant">
select *
from tuoheng_oidc.t_tenant
where code = #{code}
</select>
<select id="findList" resultType="com.tuoheng.model.po.TenantPo">
SELECT id, user_id, remark,enabled, code, name
FROM t_tenant
WHERE enabled = 1
<if test="query.name != null and query.name != ''">
and name LIKE concat('%',#{query.name},'%')
</if>
ORDER BY create_time desc
</select>
</mapper>

+ 62
- 0
tuoheng_oidc_server/target/classes/WEB-INF/classes/application-dev.yml View File

@@ -0,0 +1,62 @@
spring:
security:
oauth2:
resource-server:
jwt:
issuer-uri: http://192.168.11.11:8090 #认证中心端点,作为资源端的配置
#issuer-uri: http://oidc.dev.t-aaron.com

# 配置数据源
datasource:
# 使用阿里的Druid连接池
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# 填写你数据库的url、登录名、密码和数据库名
url: jdbc:mysql://192.168.11.13:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
username: root
password: idontcare
druid:
# 连接池的配置信息
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 5
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false

# Redis数据源
redis:
# 缓存库默认索引0
database: 0
# Redis服务器地址
host: 192.168.11.13
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
password:
# 连接超时时间(毫秒)
timeout: 6000
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接
oauth2:
token:
issuer: http://192.168.11.11:8090

+ 60
- 0
tuoheng_oidc_server/target/classes/WEB-INF/classes/application-local.yml View File

@@ -0,0 +1,60 @@
spring:
security:
oauth2:
resource-server:
jwt:
issuer-uri: http://127.0.0.1:8090 #认证中心端点,作为资源端的配置、

# 配置数据源
datasource:
# 使用阿里的Druid连接池
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# 填写你数据库的url、登录名、密码和数据库名
url: jdbc:mysql://192.168.11.13:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
username: root
password: idontcare
druid:
# 连接池的配置信息
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 5
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# Redis数据源
redis:
# 缓存库默认索引0
database: 0
# Redis服务器地址
host: 192.168.11.13
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
password:
# 连接超时时间(毫秒)
timeout: 6000
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接
oauth2:
token:
issuer: http://127.0.0.1:8090

+ 60
- 0
tuoheng_oidc_server/target/classes/WEB-INF/classes/application-prod.yml View File

@@ -0,0 +1,60 @@
spring:
security:
oauth2:
resource-server:
jwt:
issuer-uri: https://oidc.t-aaron.com #认证中心端点,作为资源端的配置、

# 配置数据源
datasource:
# 使用阿里的Druid连接池
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# 填写你数据库的url、登录名、密码和数据库名
url: jdbc:mysql://rm-uf6x76i111rb1eo48.mysql.rds.aliyuncs.com:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
username: root
password: TH22#2022
druid:
# 连接池的配置信息
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 5
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# Redis数据源
redis:
# 缓存库默认索引0
database: 0
# Redis服务器地址
host: r-uf6r5lm7c7sfdv3ehb.redis.rds.aliyuncs.com
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
password:
# 连接超时时间(毫秒)
timeout: 6000
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接
oauth2:
token:
issuer: https://oidc.t-aaron.com

+ 61
- 0
tuoheng_oidc_server/target/classes/WEB-INF/classes/application-test.yml View File

@@ -0,0 +1,61 @@
spring:
security:
oauth2:
resource-server:
jwt:
#issuer-uri: http://192.168.11.241:8090 #认证中心端点,作为资源端的配置、
issuer-uri: https://login-test.t-aaron.com #认证中心端点,作为资源端的配置、

# 配置数据源
datasource:
# 使用阿里的Druid连接池
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# 填写你数据库的url、登录名、密码和数据库名
url: jdbc:mysql://rm-uf6z740323e8053pj.mysql.rds.aliyuncs.com:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
username: root
password: TH22#2022
druid:
# 连接池的配置信息
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 5
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# Redis数据源
redis:
# 缓存库默认索引0
database: 0
# Redis服务器地址
host: r-uf6cdzjifj20jszykr.redis.rds.aliyuncs.com
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
password:
# 连接超时时间(毫秒)
timeout: 6000
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接
oauth2:
token:
issuer: https://login-test.t-aaron.com

+ 12
- 0
tuoheng_oidc_server/target/classes/WEB-INF/classes/application.yml View File

@@ -0,0 +1,12 @@
server:
port: 8090

spring:
profiles:
active: dev
web:
resources:
static-locations: classpath:/

mybatis:
mapper-locations: classpath*:mapper/*Mapper.xml

+ 69
- 0
tuoheng_oidc_server/target/classes/WEB-INF/classes/logback.xml View File

@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
<!-- scan:当此属性设置为true时,配置文档如果发生改变,将会被重新加载,默认值为true -->
<!-- scanPeriod:设置监测配置文档是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。
当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!--
contextName说明:
每个logger都关联到logger上下文,默认上下文名称为“default”。但可以使用设置成其他名字,
用于区分不同应用程序的记录。一旦设置,不能修改,可以通过%contextName来打印日志上下文名称。
-->
<contextName>tuoheng_oidc_server</contextName>

<!--定义日志变量-->
<!--<property name="logging.path" value="D:\\idealogs\\tuoheng_oidc"/>-->
<property name="logging.path" value="/data/java/logs/tuoheng_oidc"/>
<!--日志格式: [时间] [级别] [线程] [行号] [logger信息] - [日志信息]-->
<property name="logging.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%level][%thread][%L] %logger - %msg%n"/>
<property name="logging.charset" value="UTF-8"/>
<property name="logging.maxHistory" value="15"/>
<property name="logging.totalSizeCap" value="5GB"/>
<property name="logging.maxFileSize" value="40MB"/>

<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${logging.pattern}</pattern>
<charset>${logging.charset}</charset>
</encoder>
</appender>

<appender name="LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${logging.path}/server/tuoheng_oidc_server.log</File>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${logging.path}/server/tuoheng_oidc_server-%d-%i.log</fileNamePattern>
<!-- 最大保存天数-->
<maxHistory>${logging.maxHistory}</maxHistory>
<totalSizeCap>${logging.totalSizeCap}</totalSizeCap>
<maxFileSize>${logging.maxFileSize}</maxFileSize>
</rollingPolicy>
<!--编码器-->
<encoder>
<pattern>${logging.pattern}</pattern>
<charset>${logging.charset}</charset>
</encoder>
</appender>

<appender name="file.async" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>512</queueSize>
<includeCallerData>true</includeCallerData>
<appender-ref ref="LOG_FILE" />
</appender>

<logger name="com.tuoheng" level="DEBUG" additivity="false">
<appender-ref ref="console" />
<appender-ref ref="file.async" />
</logger>
<!--log4jdbc -->
<logger name="jdbc.sqltiming" level="DEBUG" additivity="false">
<appender-ref ref="file.async" />
</logger>

<root level="INFO">
<appender-ref ref="console" />
<appender-ref ref="file.async" />
</root>
</configuration>

+ 13
- 0
tuoheng_oidc_server/target/classes/WEB-INF/classes/mapper/AuthoritiesMapper.xml View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.mapper.AuthoritiesMapper">

<insert id="batchInsert" parameterType="java.util.List">
insert into authorities (user_id, username, authority)
VALUES
<foreach collection ="list" item="it" separator =",">
(#{it.userId}, #{it.username}, #{it.authority})
</foreach >
</insert>

</mapper>

+ 39
- 0
tuoheng_oidc_server/target/classes/WEB-INF/classes/mapper/UserMapper.xml View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.mapper.UserMapper">

<resultMap type="com.tuoheng.model.dto.UserBaseInfoDto" id="UserBaseInfoMap">
<id column="userId" jdbcType="INTEGER" property="userId" />
<result column="userName" jdbcType="VARCHAR" property="userName" />
<result column="password" jdbcType="VARCHAR" property="password" />
<collection property="authorityList" ofType="java.lang.String" javaType="java.util.List">
<result column="authority" jdbcType="VARCHAR"/>
</collection>
<collection property="clientRoleDtoList" ofType="com.tuoheng.model.dto.ClientRoleDto" javaType="java.util.List">
<result column="clientId" jdbcType="VARCHAR" property="clientId" />
<result column="roleId" jdbcType="INTEGER" property="roleId" />
</collection>
</resultMap>

<insert id="insertUser" parameterType="com.tuoheng.model.po.UserPo" keyProperty="id" useGeneratedKeys="true">
insert into users (username, password)
values (#{username}, #{password})
</insert>

<select id="getUserBaseInfo" resultMap="UserBaseInfoMap">
select a.id as userId, a.username as userName, a.password , b.authority, c.client_id as clientId, c.role_id as roleId
from users a
left join authorities b on a.id = b.user_id
left join t_client_user_role c on a.id = c.user_id
where a.username = #{username}
</select>

<select id="getMpUserInfo" resultMap="UserBaseInfoMap">
select a.id as userId, a.username as userName, a.password , b.authority, c.client_id as clientId, c.role_id as roleId
from users a
left join authorities b on a.id = b.user_id
left join t_client_user_role c on a.id = c.user_id
where a.username = #{username}
</select>

</mapper>

BIN
tuoheng_oidc_server/target/classes/WEB-INF/classes/static/back.png View File

Before After
Width: 2195  |  Height: 1080  |  Size: 596KB

BIN
tuoheng_oidc_server/target/classes/WEB-INF/classes/static/form.png View File

Before After
Width: 572  |  Height: 564  |  Size: 54KB

+ 2
- 0
tuoheng_oidc_server/target/classes/WEB-INF/classes/static/jquery-3.5.1.min.js
File diff suppressed because it is too large
View File


+ 174
- 0
tuoheng_oidc_server/target/classes/WEB-INF/classes/templates/login.html View File

@@ -0,0 +1,174 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录页面</title>
</head>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>login</title>
<script src="../static/jquery-3.5.1.min.js"></script>
<style>
.login__back{
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: url('../static/back.png');
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
.login__form{
/* width: 460px;
height: 410px; */
width: 410px;
height: 350px;
background: url('../static/form.png');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
padding: 60px 30px;
color: rgba(255, 255, 255, 1);
position: relative;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
}
.login__form h2{
font-size: 28px;
line-height: 25px;
text-align: center;
margin-bottom: 10px;
}
.login__form p{
font-size: 12px;
text-align: center;
margin-bottom: 36px;
}
.login__form form{
padding: 0 40px;
display: flex;
flex-direction: column;
background: transparent;
}
form input{
height: 40px;
margin-bottom: 18px;
border-radius: 6px;
color: #FFFFFF;
padding: 0 16px;
border: 1px solid rgba(255, 255, 255, 0.5);
background: transparent;
}
form input:focus-within{
outline: 0;
border: 1px solid #08EBFE;
}
button{
height: 46px;
border: none;
border-radius: 6px;
background: linear-gradient(0deg, #08EBFE 0%, #28BAC1 100%);
margin-top: 20px;
color: #FFFFFF;
font-size: 16px;
}
.form__code{
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 18px;
}
.form__code input{
width: calc(100% - 152px);
margin-bottom: 0;
}
.form__code img{
width: 100px;
height: 42px;
cursor: pointer;
}
.login__form .form__tips{
margin: 0;
height: 0;
position: relative;
top: -14px;
}
.form__tips.is--error{
color: red
}
</style>
</head>
<body>
<div class="login__back">
<div class="login__form">
<h2>拓恒统一登录平台</h2>
<p>TUOHENG LOGIN PLATFORM</p>
<form th:action="@{/login}" method="post">
<input name="username" placeholder="请输入用户名" type="text"/>
<input name="password" placeholder="请输入密码" type="password"/>
<div class="form__code">
<input name="validateCode" placeholder="请输入验证码" />
<input id="codekey" name="codekey" type="hidden"/>
<img class="code__img" src="" />
</div>
<div class="form__tips is--error" th:if="${param.error}">
用户名密码错误,请重新输入!
</div>
<div class="form__tips is--error" th:if="${param.validerror}">
验证码错误,请重新输入!
</div>
<div class="form__tips is--error" th:if="${param.expirecode}">
验证码已过期,请重新输入!
</div>
<button type="submit">登 录</button>
</form>
</div>
</div>
<!--绑定点击事件 -->
<script>
const imgDom = document.querySelector('.code__img')
imgDom.onclick = function() {
$.ajax({
url : "/vercode",//后台请求的数据
dataType: 'json', //数据格式
type : "post",//请求方式
async : true,//是否异步请求
success : function(data) { //如果请求成功,返回数据。
var tt = data.data; //第一个data代表json,第二个data代表json里的数组或对象
$('.code__img').attr('src', tt.captcha);
$('#codekey').val(tt.codeKey);
},
error : function (arg1) {
alert("加载数据失败");
console.log(arg1);
}
})
}

$(document).ready(function() {
$.ajax({
url : "/vercode",//后台请求的数据
dataType: 'json', //数据格式
type : "post",//请求方式
async : true,//是否异步请求
success : function(data) { //如果请求成功,返回数据。
var tt = data.data; //第一个data代表json,第二个data代表json里的数组或对象
$('.code__img').attr('src', tt.captcha);
$('#codekey').val(tt.codeKey);
},
error : function (arg1) {
alert("加载数据失败");
console.log(arg1);
}
})
})


</script>
</body>
</html>

+ 62
- 0
tuoheng_oidc_server/target/classes/application-dev.yml View File

@@ -0,0 +1,62 @@
spring:
security:
oauth2:
resource-server:
jwt:
issuer-uri: http://192.168.11.11:8090 #认证中心端点,作为资源端的配置
#issuer-uri: http://oidc.dev.t-aaron.com

# 配置数据源
datasource:
# 使用阿里的Druid连接池
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# 填写你数据库的url、登录名、密码和数据库名
url: jdbc:mysql://192.168.11.13:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
username: root
password: idontcare
druid:
# 连接池的配置信息
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 5
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false

# Redis数据源
redis:
# 缓存库默认索引0
database: 0
# Redis服务器地址
host: 192.168.11.13
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
password:
# 连接超时时间(毫秒)
timeout: 6000
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接
oauth2:
token:
issuer: http://192.168.11.11:8090

+ 60
- 0
tuoheng_oidc_server/target/classes/application-local.yml View File

@@ -0,0 +1,60 @@
spring:
security:
oauth2:
resource-server:
jwt:
issuer-uri: http://127.0.0.1:8090 #认证中心端点,作为资源端的配置、

# 配置数据源
datasource:
# 使用阿里的Druid连接池
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# 填写你数据库的url、登录名、密码和数据库名
url: jdbc:mysql://192.168.11.13:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
username: root
password: idontcare
druid:
# 连接池的配置信息
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 5
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# Redis数据源
redis:
# 缓存库默认索引0
database: 0
# Redis服务器地址
host: 192.168.11.13
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
password:
# 连接超时时间(毫秒)
timeout: 6000
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接
oauth2:
token:
issuer: http://127.0.0.1:8090

+ 60
- 0
tuoheng_oidc_server/target/classes/application-prod.yml View File

@@ -0,0 +1,60 @@
spring:
security:
oauth2:
resource-server:
jwt:
issuer-uri: https://oidc.t-aaron.com #认证中心端点,作为资源端的配置、

# 配置数据源
datasource:
# 使用阿里的Druid连接池
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# 填写你数据库的url、登录名、密码和数据库名
url: jdbc:mysql://rm-uf6x76i111rb1eo48.mysql.rds.aliyuncs.com:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
username: root
password: TH22#2022
druid:
# 连接池的配置信息
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 5
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# Redis数据源
redis:
# 缓存库默认索引0
database: 0
# Redis服务器地址
host: r-uf6r5lm7c7sfdv3ehb.redis.rds.aliyuncs.com
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
password:
# 连接超时时间(毫秒)
timeout: 6000
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接
oauth2:
token:
issuer: https://oidc.t-aaron.com

+ 0
- 0
tuoheng_oidc_server/target/classes/application-test.yml View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save