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

概述说明


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

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

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

 

搭建步骤


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

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

 

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

 1         <!-- Duo Security Authentication Begin -->   
 2         <dependency>
 3              <groupId>org.apereo.cas</groupId>
 4              <artifactId>cas-server-support-duo</artifactId>
 5              <version>${cas.version}</version>
 6         </dependency>
 7         <!-- Duo Security Authentication End -->
 8         <!-- Duo Security Authentication Begin -->   
 9         <repository>
10             <id>duo-unicon</id>
11             <url>https://dl.bintray.com/uniconiam/maven</url>
12         </repository>
13         <repository>
14             <id>duo-jitpack</id>
15             <url>https://jitpack.io</url>
16         </repository>     
17         <!-- Duo Security Authentication End -->   

 

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

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

 

 

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

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

并增加登录策略

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

 

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

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

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

 

-6. 打包

mvn package

 

效果演示


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

 

-2. 启动tomcat,访问登录

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

OK 大功告成

 

参考文章


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

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

 

 

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

 

posted @ 2018-08-11 20:43  四代土豆2  阅读(2163)  评论(0编辑  收藏  举报