feat(auth): 添加CAS单点登录功能
- 配置开发和生产环境的CAS登录URL和登出URL - 新增CacheHelper缓存工具类用于缓存操作 - 创建LideeUserDto用户数据传输对象 - 在SecurityConfig中允许CAS登录和登出接口匿名访问 - 添加SysLoginController中的logincas和outlogcas接口 - 实现SysLoginService中的CAS登录验证和登出逻辑 - 集成HttpUtils进行CAS服务器通信验证 Signed-off-by: NewName <1048783178@qq.com>
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
package iot.lidee.web.controller.system;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import iot.lidee.common.core.domain.model.LideeUserDto;
|
||||
import iot.lidee.system.domain.AppPreferences;
|
||||
import iot.lidee.system.service.IAppPreferencesService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -69,6 +72,29 @@ public class SysLoginController
|
||||
return ajax;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping({"/logincas"})
|
||||
public AjaxResult logincas(@RequestBody @Validated LideeUserDto dto) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
// 生成令牌
|
||||
String token = loginService.logincas(dto);
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
@PostMapping({"/outlogcas"})
|
||||
public AjaxResult outlogcas(@RequestBody @Validated LideeUserDto dto){
|
||||
// 生成令牌
|
||||
loginService.outlogcas(dto);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
|
||||
@@ -147,4 +147,9 @@ logging:
|
||||
swagger:
|
||||
enabled: true # 是否开启swagger
|
||||
pathMapping: /dev-api # 请求前缀
|
||||
cas:
|
||||
loginurl: http://127.0.0.1:48080/admin-api/system/auth/user-info
|
||||
outlogouturl: http://127.0.0.1:48080/admin-api/system/auth/logout-client
|
||||
# loginurl: http://192.168.1.241/admin-api/system/auth/user-info
|
||||
# outlogouturl: http://192.168.1.241/admin-api/system/auth/logout-client
|
||||
|
||||
|
||||
@@ -146,5 +146,10 @@ logging:
|
||||
# Swagger配置
|
||||
swagger:
|
||||
enabled: true # 是否开启swagger
|
||||
pathMapping: /dev-api # 请求前缀
|
||||
pathMapping: /dev-api # 请求前缀
|
||||
cas:
|
||||
# loginurl: http://127.0.0.1:48080/admin-api/system/auth/user-info
|
||||
# outlogouturl: http://127.0.0.1:48080/admin-api/system/auth/logout-client
|
||||
loginurl: http://192.168.1.241/admin-api/system/auth/user-info
|
||||
outlogouturl: http://192.168.1.241/admin-api/system/auth/logout-client
|
||||
|
||||
|
||||
Reference in New Issue
Block a user