nodejs 使用CAS 实现 单点登录(SSO) 【开源库实现,简单】

大部分企业使用 java 开发业务系统, 针对java cas的认证 demo 比较多 ,还有PHPCAS ,标准的参考这里:

phpCAS 的使用

整理登录流程如下图,图片来自网络

找了不少资料,nodejs 实现的比较少,npm 上库很多,试用了好几个才成功。

推荐这里库 connect-cas

注意参数解析

Many of these options are borrowed from node's url documentation. You may set global options through the .configure() method or override them with any of the exposed middleware.

  • procotol :The protocol to communicate with the CAS Server. Defaults to 'https'.
  • host : CAS server hostname
  • port :CAS server port number. Defaults to 443.
  • gateway : Send all validation requests through the CAS gateway feature. Defaults to false.
  • paths
    - serviceValidate Path to validate TGT
    - proxyValidate Path to validate PGT (not implemented)
    - proxy Path to obtain a proxy ticket
    - login Path to the CAS login

示例代码

原文地址:https://www.cnblogs.com/jiuyuehe/p/7495106.html