轻松搭建CAS 5.x系列(8)-在CAS Server增加双因素认证(DUO版)

时间:2022-04-27 20:44:44

概述说明


为了让系统更加安全,很多登录会加入双因素认证。何为双因素,如果把登陆作为开一扇门的话,那就是在原来的锁上再加一把锁,第二锁用新的钥匙,这样安全系数就更加高了。

CAS是通过账号名和密码来认证的,那如果账号名和密码泄密就会造成信息泄露。所以为了安全,CAS在账号名密码认证通过后,再给用户的手机发送消息验证码,用户输入验证码后才能真正的登录完成。

本章就是讲解怎么在CAS增加手机验证的双因素,需要特殊说明的是,CAS自身是不支持的,是将第三方的双因素认证系统整合进来的。本章是使用的是Duo Secret

搭建步骤


`1. 首先,您需要有个CAS Server端

如果您没有,可以按照我之前写的文章《轻松搭建CAS 5.x系列文章》系列的前3篇文章搭建好CAS Server。

`2. 在pom.xml增加依赖包

         <!-- Duo Security Authentication Begin -->
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-duo</artifactId>
<version>${cas.version}</version>
</dependency>
<!-- Duo Security Authentication End -->
<!-- Duo Security Authentication Begin -->
<repository>
<id>duo-unicon</id>
<url>https://dl.bintray.com/uniconiam/maven</url>
</repository>
<repository>
<id>duo-jitpack</id>
<url>https://jitpack.io</url>
</repository>
<!-- Duo Security Authentication End -->

·3 在Duo网站上注册管理账号

网站地址:https://signup.duo.com/ (需要*)

轻松搭建CAS 5.x系列(8)-在CAS Server增加双因素认证(DUO版)

·4. 登录到Duo后台,增加application

点击菜单:protect an application - 选择cas

轻松搭建CAS 5.x系列(8)-在CAS Server增加双因素认证(DUO版)

并增加登录策略

轻松搭建CAS 5.x系列(8)-在CAS Server增加双因素认证(DUO版)

创建完成后就有了 duoSecretKey、duoIntegrationKey、duoApiHost

`5. application.properties增加配置文件

 cas.authn.mfa.globalProviderId=mfa-duo
cas.authn.mfa.duo[].duoSecretKey=BRuiDVVHnK9iolBzoy1QTTK4q38Qkw0blkAutm3m
cas.authn.mfa.duo[].rank=0
cas.authn.mfa.duo[].duoApplicationKey=6e846c1eec420786716015bbb7c1e207b77d781e
cas.authn.mfa.duo[].duoIntegrationKey=DIZSC3XXIQ4EWEAOGUPN
cas.authn.mfa.duo[].duoApiHost=api-4cfedbe7.duosecurity.com
cas.authn.mfa.duo[].trustedDeviceEnabled=false
cas.authn.mfa.duo[].id=mfa-duo
cas.authn.mfa.duo[].registrationUrl=https://registration.example.org/duo-enrollment
cas.authn.mfa.duo[].name=duoname

其中cas.authn.mfa.duo[0].duoApplicationKey是自行生成的,这个是不少于40位的字符串

-6. 打包

mvn package

效果演示


-1. 首先需要手机下载Duo Mobile (APP)

-2. 启动tomcat,访问登录

轻松搭建CAS 5.x系列(8)-在CAS Server增加双因素认证(DUO版)

需要特殊说明的,
在视频中点击按钮“Send Me a Push" ,是在手机Duo APP显示登录确认,这个跟电脑登录微信端类似,具体见下图

轻松搭建CAS 5.x系列(8)-在CAS Server增加双因素认证(DUO版)

OK 大功告成

参考文章


1. CAS中文文档站点#代理认证

2. Duo Docuents#Central Authentication Server (CAS)     (需要*访问)

最后,大家想更多CAS了解的话,可以来CAS中文文档站点(http://www.cassso-china.cn)来瞅瞅

轻松搭建CAS 5.x系列(8)-在CAS Server增加双因素认证(DUO版)