Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
civil-bigdata
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
civil
civil-bigdata
Commits
fd5e68ec
Commit
fd5e68ec
authored
Jun 20, 2023
by
wqc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
单点登录调整
parent
9b7e55b6
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
154 additions
and
7 deletions
+154
-7
api-server/src/main/java/com/zq/api/feign/SysFeign.java
+3
-0
api-server/src/main/java/com/zq/api/service/IApiLogic.java
+3
-0
api-server/src/main/java/com/zq/api/service/impl/ApiV100Logic.java
+5
-0
sys-server/pom.xml
+5
-0
sys-server/src/main/java/com/zq/system/modules/system/dao/SysInfoDao.java
+2
-0
sys-server/src/main/java/com/zq/system/modules/system/domain/User.java
+4
-0
sys-server/src/main/java/com/zq/system/modules/system/domain/vo/SsoLoginVo.java
+10
-0
sys-server/src/main/java/com/zq/system/modules/system/entity/SysInfo.java
+6
-0
sys-server/src/main/java/com/zq/system/modules/system/rest/SsoController.java
+20
-2
sys-server/src/main/java/com/zq/system/modules/system/service/SsoService.java
+49
-5
sys-server/src/main/resources/Mapper/SysInfoMapper.xml
+47
-0
No files found.
api-server/src/main/java/com/zq/api/feign/SysFeign.java
View file @
fd5e68ec
...
...
@@ -29,6 +29,9 @@ public interface SysFeign {
@PostMapping
(
"/api/user/modifyPasswd"
)
ResultVo
modifyPasswd
(
@RequestBody
Map
<
String
,
Object
>
paramsMap
);
@PostMapping
(
"/sso/verifyToken"
)
ResultVo
getVerifyToken
(
@RequestBody
Map
<
String
,
Object
>
paramsMap
);
@GetMapping
(
"/api/version/getAppVersion"
)
ResultVo
getAppVersion
(
@RequestParam
String
appName
);
...
...
api-server/src/main/java/com/zq/api/service/IApiLogic.java
View file @
fd5e68ec
...
...
@@ -112,6 +112,9 @@ public interface IApiLogic extends IApiCommon {
@ApiMethod
(
name
=
"单点登出"
,
service
=
"SYS-SERVER"
)
ApiResp
ssoLogout
(
ApiForm
form
);
@ApiMethod
(
name
=
"验证token有效"
,
service
=
"SYS-SERVER"
)
ApiResp
getVerifyToken
(
ApiForm
form
);
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓开放接口↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
...
...
api-server/src/main/java/com/zq/api/service/impl/ApiV100Logic.java
View file @
fd5e68ec
...
...
@@ -51,6 +51,11 @@ public class ApiV100Logic extends BaseApiLogic implements IApiLogic {
}
@Override
public
ApiResp
getVerifyToken
(
ApiForm
form
)
{
return
ApiUtils
.
toApiResp
(
form
,
sysFeign
.
getVerifyToken
(
form
.
getParamsMap
()));
}
@Override
public
ApiResp
modifyPasswd
(
ApiForm
form
)
{
return
ApiUtils
.
toApiResp
(
form
,
sysFeign
.
modifyPasswd
(
form
.
getParamsMap
()));
}
...
...
sys-server/pom.xml
View file @
fd5e68ec
...
...
@@ -177,6 +177,11 @@
<artifactId>
xercesImpl
</artifactId>
<version>
2.12.0
</version>
</dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
5.7.16
</version>
</dependency>
</dependencies>
<build>
...
...
sys-server/src/main/java/com/zq/system/modules/system/dao/SysInfoDao.java
View file @
fd5e68ec
...
...
@@ -6,4 +6,6 @@ import org.springframework.stereotype.Repository;
@Repository
public
interface
SysInfoDao
extends
BaseMapper
<
SysInfo
>
{
void
updateByappId
(
SysInfo
build
);
}
sys-server/src/main/java/com/zq/system/modules/system/domain/User.java
View file @
fd5e68ec
...
...
@@ -74,6 +74,10 @@ public class User extends BaseEntity implements Serializable {
@ApiModelProperty
(
value
=
"用户昵称"
)
private
String
nickName
;
@NotBlank
@ApiModelProperty
(
value
=
"用户所属区域"
)
private
String
userArea
;
@Email
//@NotBlank
@ApiModelProperty
(
value
=
"邮箱"
)
...
...
sys-server/src/main/java/com/zq/system/modules/system/domain/vo/SsoLoginVo.java
View file @
fd5e68ec
...
...
@@ -19,4 +19,14 @@ public class SsoLoginVo {
private
String
uuid
=
""
;
private
String
loginToken
;
private
String
loginKey
;
private
String
appId
;
private
String
systemName
;
private
String
systemTag
;
}
sys-server/src/main/java/com/zq/system/modules/system/entity/SysInfo.java
View file @
fd5e68ec
...
...
@@ -42,6 +42,12 @@ public class SysInfo {
@ApiModelProperty
(
"状态 0-禁用 1-启用"
)
private
Integer
state
;
@ApiModelProperty
(
"生成的token"
)
private
String
loginToken
;
@ApiModelProperty
(
"生成的key"
)
private
String
loginKey
;
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
...
...
sys-server/src/main/java/com/zq/system/modules/system/rest/SsoController.java
View file @
fd5e68ec
package
com
.
zq
.
system
.
modules
.
system
.
rest
;
import
cn.hutool.core.lang.tree.TreeUtil
;
import
com.zq.common.annotation.rest.AnonymousGetMapping
;
import
com.zq.common.annotation.rest.AnonymousPostMapping
;
import
com.zq.common.config.redis.RedisUtils
;
...
...
@@ -11,6 +12,7 @@ import com.zq.system.exception.BadRequestException;
import
com.zq.system.modules.system.domain.User
;
import
com.zq.system.modules.system.domain.vo.SsoLoginVo
;
import
com.zq.system.modules.system.domain.vo.SsoRegisterVo
;
import
com.zq.system.modules.system.entity.AreaCode
;
import
com.zq.system.modules.system.service.AuthUserDto
;
import
com.zq.system.modules.system.service.SsoService
;
import
io.swagger.annotations.Api
;
...
...
@@ -54,8 +56,8 @@ public class SsoController {
@ApiOperation
(
"token单点登录"
)
@PostMapping
(
value
=
"/tokenLogin"
)
public
ResultVo
tokenLogin
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
return
ResultVo
.
success
(
ssoService
.
tokenLogin
(
request
,
response
));
public
ResultVo
tokenLogin
(
@RequestBody
SsoLoginVo
vo
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
return
ResultVo
.
success
(
ssoService
.
tokenLogin
(
vo
,
request
,
response
));
}
@ApiOperation
(
"单点登出"
)
...
...
@@ -98,6 +100,15 @@ public class SsoController {
return
ResultVo
.
success
();
}
@ApiOperation
(
"验证token和key"
)
@PostMapping
(
value
=
"/verifyToken"
)
public
ResultVo
verifyToken
(
@RequestParam
String
loginToken
,
String
loginKey
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
AssertUtils
.
notNull
(
loginToken
,
"token不为空"
);
AssertUtils
.
notNull
(
loginKey
,
"key不为空"
);
return
ResultVo
.
success
(
ssoService
.
verifyToken
(
loginToken
,
loginKey
,
request
,
response
));
}
@ApiOperation
(
"用户绑定的系统列表"
)
@GetMapping
(
value
=
"/getBindSysList"
)
public
ResultVo
getBindSysList
()
{
...
...
@@ -127,4 +138,11 @@ public class SsoController {
AssertUtils
.
hasText
(
vo
.
getPassword
(),
"缺少密码"
);
return
ResultVo
.
success
(
ssoService
.
verifyPasswd
(
vo
));
}
@ApiOperation
(
"选择地区"
)
@AnonymousPostMapping
(
value
=
"/selectArea"
)
public
ResultVo
selectArea
()
{
return
ResultVo
.
success
(
ssoService
.
selectArea
());
}
}
sys-server/src/main/java/com/zq/system/modules/system/service/SsoService.java
View file @
fd5e68ec
package
com
.
zq
.
system
.
modules
.
system
.
service
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.RandomUtil
;
import
cn.hutool.http.HttpRequest
;
...
...
@@ -17,6 +18,7 @@ import com.zq.common.vo.ResultVo;
import
com.zq.system.config.CacheKeys
;
import
com.zq.system.config.RsaProperties
;
import
com.zq.system.config.security.TokenProvider
;
import
com.zq.system.modules.system.dao.AreaCodeDao
;
import
com.zq.system.modules.system.dao.BlindUserInfoDao
;
import
com.zq.system.modules.system.dao.SysInfoDao
;
import
com.zq.system.modules.system.domain.Job
;
...
...
@@ -24,6 +26,7 @@ import com.zq.system.modules.system.domain.Role;
import
com.zq.system.modules.system.domain.User
;
import
com.zq.system.modules.system.domain.vo.SsoLoginVo
;
import
com.zq.system.modules.system.domain.vo.SsoRegisterVo
;
import
com.zq.system.modules.system.entity.AreaCode
;
import
com.zq.system.modules.system.entity.BindUserInfo
;
import
com.zq.system.modules.system.entity.SysInfo
;
import
com.zq.system.modules.system.repository.DeptRepository
;
...
...
@@ -70,6 +73,7 @@ public class SsoService {
private
final
RedisUtils
redisUtils
;
private
final
AuthenticationManagerBuilder
authenticationManagerBuilder
;
private
final
TokenProvider
tokenProvider
;
private
final
AreaCodeDao
areaCodeDao
;
public
void
register
(
SsoRegisterVo
vo
)
{
String
passwd
=
null
;
...
...
@@ -90,6 +94,7 @@ public class SsoService {
resources
.
setNickName
(
vo
.
getNickName
());
resources
.
setPhone
(
vo
.
getPhone
());
resources
.
setUsername
(
vo
.
getUsername
());
resources
.
setUserArea
(
vo
.
getUserArea
());
List
<
Role
>
roleList
=
roleRepository
.
findAllById
(
Collections
.
singletonList
(
8L
));
resources
.
setRoles
(
new
HashSet
<>(
roleList
));
...
...
@@ -164,10 +169,6 @@ public class SsoService {
String
toUrl
=
request
.
getParameter
(
"service"
);
AssertUtils
.
hasText
(
toUrl
,
"跳转地址为空"
);
/* SysInfo sysInfo = sysInfoDao.selectOne(Wrappers.lambdaQuery(SysInfo.builder().appId(appId).build()));
AssertUtils.notNull(sysInfo, "APPID不存在");
AssertUtils.hasText(sysInfo.getHomeUrl(), "业务系统主页地址未配置");*/
String
passwd
=
RsaUtils
.
decryptByPrivateKey
(
RsaProperties
.
privateKey
,
vo
.
getPasswd
());
UsernamePasswordAuthenticationToken
authenticationToken
=
...
...
@@ -186,6 +187,20 @@ public class SsoService {
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"toUrl"
,
toUrl
+
"?"
+
properties
.
getHeader
()
+
"="
+
token
+
"&key="
+
key
);
data
.
put
(
properties
.
getHeader
(),
properties
.
getTokenStartWith
()
+
token
);
//
// SysInfo sysInfo = sysInfoDao.selectOne(Wrappers.lambdaQuery(SysInfo.builder().appId(vo.getAppId()).build()));
// AssertUtils.hasText(sysInfo.getAppId(), "APPID不存在");
// AssertUtils.hasText(sysInfo.getHomeUrl(), "业务系统主页地址未配置");
// SysInfo build =SysInfo.builder()
// .appId(sysInfo.getAppId())
// .loginKey(key)
// .loginToken(token)
// .systemName(vo.getSystemName())
// .systemTag(vo.getSystemTag())
// .state(1)
// .createTime(DateUtil.date())
// .build();
// sysInfoDao.update(build,Wrappers.lambdaQuery(SysInfo.class));
return
data
;
// response.sendRedirect(sysInfo.getHomeUrl() + "?" + properties.getHeader() + "=" + token + "&key=" + key);
}
catch
(
Exception
e
)
{
...
...
@@ -195,7 +210,7 @@ public class SsoService {
}
public
Object
tokenLogin
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
Object
tokenLogin
(
SsoLoginVo
vo
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
String
toUrl
=
request
.
getParameter
(
"service"
);
AssertUtils
.
hasText
(
toUrl
,
"跳转地址为空"
);
...
...
@@ -209,6 +224,21 @@ public class SsoService {
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"toUrl"
,
toUrl
+
"?"
+
properties
.
getHeader
()
+
"="
+
token
+
"&key="
+
key
);
data
.
put
(
properties
.
getHeader
(),
properties
.
getTokenStartWith
()
+
token
);
// if () {
SysInfo
sysInfo
=
sysInfoDao
.
selectOne
(
Wrappers
.
lambdaQuery
(
SysInfo
.
builder
().
appId
(
vo
.
getAppId
()).
build
()));
AssertUtils
.
hasText
(
sysInfo
.
getAppId
(),
"APPID不存在"
);
AssertUtils
.
hasText
(
sysInfo
.
getHomeUrl
(),
"业务系统主页地址未配置"
);
SysInfo
build
=
SysInfo
.
builder
()
.
appId
(
sysInfo
.
getAppId
())
.
loginKey
(
key
)
.
loginToken
(
token
)
.
systemName
(
vo
.
getSystemName
())
.
systemTag
(
vo
.
getSystemTag
())
.
state
(
1
)
.
createTime
(
DateUtil
.
date
())
.
build
();
sysInfoDao
.
updateByappId
(
build
);
// }
return
data
;
// response.sendRedirect(sysInfo.getHomeUrl() + "?" + properties.getHeader() + "=" + token + "&key=" + key);
}
...
...
@@ -262,4 +292,18 @@ public class SsoService {
AssertUtils
.
isTrue
(
StringUtils
.
isNotBlank
(
cacheCode
)
&&
cacheCode
.
equalsIgnoreCase
(
code
),
"验证码错误"
);
redisUtils
.
deleteStr
(
CacheKeys
.
authCodeKey
(
phone
));
}
public
ResultVo
verifyToken
(
String
loginToken
,
String
loginKey
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
SysInfo
sysInfo
=
sysInfoDao
.
selectOne
(
Wrappers
.
lambdaQuery
(
SysInfo
.
builder
().
loginToken
(
loginToken
).
loginKey
(
loginKey
).
build
()));
if
(
sysInfo
==
null
){
return
ResultVo
.
success
(
sysInfo
.
getAppId
());
}
else
{
return
ResultVo
.
fail
(
"校验失败"
);
}
}
public
Object
selectArea
()
{
return
areaCodeDao
.
selectList
(
Wrappers
.
lambdaQuery
(
AreaCode
.
builder
().
admindivLevel
(
"5"
).
build
()));
}
}
sys-server/src/main/resources/Mapper/SysInfoMapper.xml
0 → 100644
View file @
fd5e68ec
<?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.zq.system.modules.system.dao.SysInfoDao"
>
<resultMap
id=
"BaseResultMap"
type=
"com.zq.system.modules.system.entity.SysInfo"
>
<!--@Table DATA_TABLE-->
<result
property=
"id"
column=
"id"
jdbcType=
"OTHER"
/>
<result
property=
"appId"
column=
"app_id"
jdbcType=
"OTHER"
/>
<result
property=
"systemTag"
column=
"system_tag"
jdbcType=
"OTHER"
/>
<result
property=
"systemName"
column=
"system_name"
jdbcType=
"OTHER"
/>
<result
property=
"systemLogo"
column=
"system_logo"
jdbcType=
"OTHER"
/>
<result
property=
"homeUrl"
column=
"home_url"
jdbcType=
"OTHER"
/>
<result
property=
"loginUrl"
column=
"login_url"
jdbcType=
"OTHER"
/>
<result
property=
"state"
column=
"state"
jdbcType=
"OTHER"
/>
<result
property=
"loginToken"
column=
"login_token"
jdbcType=
"OTHER"
/>
<result
property=
"loginKey"
column=
"login_key"
jdbcType=
"OTHER"
/>
<result
property=
"createTime"
column=
"create_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"updateTime"
column=
"update_time"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<update
id=
"updateByappId"
>
update sys_info
<set>
<if
test=
"appId != null"
>
app_id = #{appId, jdbcType=OTHER},
</if>
<if
test=
"systemName != null"
>
system_name = #{systemName, jdbcType=OTHER},
</if>
<if
test=
"systemTag != null"
>
system_tag = #{systemTag, jdbcType=OTHER},
</if>
<if
test=
"loginToken != null"
>
login_token = #{loginToken, jdbcType=OTHER},
</if>
<if
test=
"loginKey != null"
>
login_key = #{loginKey, jdbcType=OTHER},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime, jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime, jdbcType=TIMESTAMP},
</if>
</set>
WHERE app_id = #{appId}
</update>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment