kawhii / sso

cas单点登录系统,其中包括cas认证服务,配置中心,监控平台,服务管理的高可用项目
https://kawhii.github.io/sso
MIT License
937 stars 428 forks source link

如何在CAS-Server系统定义自己的登录接口并能生成Ticket #58

Closed SpringStudent closed 6 years ago

SpringStudent commented 6 years ago

@RestController @RequestMapping("/rest/") public class LoginController{

@Resource
private LoginService loginService;

@RequestMapping(value = "/login", method = RequestMethod.POST)
public LoginResult login(@RequestBody LoginParam loginParam) throws Exception {
    try {
        return loginService.login(loginParam);
    } catch (Exception e) {
        throw e;
    }
}

}

public class LoginParam { /**

如上代码,我的接口是自己定义,登录入参也是自定义,请问怎么实现

kawhii commented 6 years ago

为什么要这么考虑,使用出场景是什么?

SpringStudent commented 6 years ago

为了做前后端分离或者说我们有客户端给客户端开登陆接口

kawhii commented 6 years ago

单点登录的情况下做前后端分离都是比较牵强的,没有找到一个很好的方案,目前方法可以采用rest在客户端进行调用,jwt在业务系统生成

SpringStudent commented 6 years ago

嗯,我目前的做法是开一个接口返回tgt实现,另外一个接口根据tgt和serviceId生成st,然后客户端或者浏览器铜鼓serviceId?ticket=st的方法

SpringStudent commented 6 years ago

不然只有改源码,rest接口模拟cas登录

kawhii commented 6 years ago

无需那么复杂,cas支持rest对接 官方文档地址:https://apereo.github.io/cas/5.1.x/protocol/REST-Protocol.html 客户端cas-client也支持这样的做法,而spring-security应该也是支持的,但我没尝试过

SpringStudent commented 6 years ago

如果是webservice方式的登录接口呢?

kawhii commented 6 years ago

webservice只是业务系统对外开放的一种方式,跟cas无关,只要对接上了cas。以什么方式都是一样

SpringStudent commented 6 years ago

嗯,我已经实现了

SpringStudent commented 6 years ago

感谢