JustNote
  • Introduction
  • DesignPattern
    • 七大原则
      • 开闭原则(OCP)
      • 依赖倒置原则(DIP)
      • 单一职责原则(SRP)
      • 接口隔离原则(ISP)
      • 迪米特法则(LoD)
      • 里氏代换原则(LSP)
      • 合成复用原则(CRP)
    • 创建型模式
      • 简单工厂模式
      • 工厂方法模式
      • 抽象工厂模式
      • 建造者模式
      • 单例模式
      • 原型模式
    • 结构型模式
      • 外观模式
      • 装饰模式
      • 适配器模式
      • 享元模式
      • 组合模式
      • 桥接模式
      • 代理模式
    • 行为型模式
      • 模板方法模式
      • 迭代器模式
      • 策略模式
      • 解释器模式
      • 观察者模式
      • 备忘录模式
      • 命令模式
      • 中介者模式
      • 责任链模式
      • 访问者模式
      • 状态模式
  • Java
    • Java Core
      • JVM 如何加载类
      • JVM 垃圾回收
      • JVM G1GC
      • JVM G1GC Q&A
      • JVM 与 Hbase
      • JVM ZGC Overview
      • JVM ZGC 内存管理
      • JVM ZGC 线程
      • JVM ZGC 垃圾回收
      • JVM ZGC 日志分析
      • JVM ZGC 参数调优
    • checkstyle
  • Golang
    • 源码阅读
      • Goroutines
      • Channel
    • gRPC
      • 1、快速开始
      • 2、什么是gRPC
      • 3、gRPC概念梳理
      • 4、基于Golang的gRPC入门
      • 5、gRPC组件ProtocolBuffers介绍
      • 6、gRPC组件Http 2.0
      • 7、错误处理和Debug
      • 8、gRPC身份验证
      • 9、服务注册与发现
      • 10、gRPC与gRPC Gateway
      • 11、gRPC与分布式链路追踪
  • Scala
    • 数据结构与算法
      • 数组
      • 队列
    • 函数式编程
      • 高阶函数
      • 偏函数
    • Immutable Collection
      • List
    • Mutable Collection
      • Array
    • 常见函数操作
      • A
        • aggregate
        • andThen
        • appended
        • appendedAll
      • C
        • chain
        • collect
        • collectFirst
        • combinations
        • compose
        • concat
        • cond
        • condOpt
        • const
        • contains
        • containsSlice
        • copyToArray
        • corresponds
        • count
        • curried
      • D
        • diff
        • distinct
        • distinctBy
        • drop
        • dropRight
        • dropWhile
      • E
        • empty(PartialFunction)
        • empty(collections)
        • endsWith
        • exists
      • F
        • fill
        • filter
        • filterKeys
        • filterNot
        • find
        • findLast
        • flatMap
        • flatten
        • fold
        • foldLeft
        • foldRight
        • forall
        • foreach
        • fromFunction
      • G
        • getOrElse (Map)
        • getOrElse (Option)
        • groupBy
        • groupMap
        • groupMapReduce
        • grouped
      • H
        • head
        • headOption
      • I
        • indexOf
        • indexOfSlice
        • indexWhere
        • indices
        • init
        • inits
        • intersect
        • isDefinedAt (Map)
        • isDefinedAt (Seq)
        • isEmpty
        • isTraversableAgain
      • K
        • keys
      • L
        • last
        • lastIndexOf
        • lastIndexOfSlice
        • lastIndexWhere
        • lastOption
        • length
        • lift
      • M
        • map
        • mapConserve
        • mapValues
        • max
        • maxBy
        • maxByOption
        • maxOption
        • min
        • minBy
        • minByOption
        • minOption
        • mkString
      • N
        • nonEmpty
      • O
        • orElse
      • P
        • padTo
        • par
        • partition
        • partitionMap
        • patch
        • permutations
        • prefixLength
        • prepended
        • prependedAll
        • product
      • R
        • range
        • reduce
        • reduceLeft
        • reduceLeftOption
        • reduceOption
        • reduceRight
        • reduceRightOption
        • reverse
        • reverseIterator
        • reverseMap
        • runWith
      • S
        • sameElements
        • scan
        • scanLeft
        • scanRight
        • search
        • segmentLength
        • size
        • slice
        • sliding
        • sortBy
        • sortWith
        • sorted
        • span
        • splitAt
        • startsWith
        • sum
      • T
        • tabulate
        • tail
        • tails
        • take
        • takeRight
        • takeWhile
        • transpose
        • tupled
      • U
        • unfold
        • union
        • unlift
        • untupled
        • unzip
        • unzip3
        • updated
      • V
        • values
        • view
      • W
        • withFilter
        • withDefault
        • withDefaultValue
      • Z
        • zip
        • zipAll
        • zipWithIndex
      • map
      • flatmap
      • filter
      • reduceLeft
      • foldLeft
    • Futures
      • Method with future as return type
      • Non blocking future result
      • Chain futures using flatMap
      • Chain futures using for comprehension
      • Future Option with for comprehension
      • Future Option with map
      • Composing Futures
      • Future Sequence
      • Future Traverse
      • Future foldLeft
      • Future reduceLeft
      • Future firstCompletedOf
      • Future zip
      • Future zipWith
      • Future andThen
      • Future configure threadpool
      • Future recover
      • Future recoverWith
      • Future fallbackTo
      • Future promise
    • Akka
  • Algorithm
  • Docker
  • Kubernetes
    • 二进制安装kubernetes
      • 00.从零开始
  • Architecture
    • Infrastructure
      • Opentracing
      • Jaeger && ZipKin
      • SkyWalking
      • Consul
      • Envoy
      • Service Mesh
      • Service Mesh: Istio 详解
      • Service Mesh: 基于 Istio 的落地实践(一)
    • CAS
      • CAS Server
      • CAS Service Management
      • CAS 集成LDAP
      • CAS 集成gitlab
      • CAS SSO & SLO
      • CAS Gitbook
    • xCAT
  • Netty
  • DDD
  • Reactive Programming
    • Reactor
      • Publisher
      • Subscriber
      • Subscription
      • Processor
    • WebFlux
  • Gitlab
    • Git Hook
  • CICD
    • Jenkins
      • Kubectl
Powered by GitBook
On this page
  • 环境介绍
  • 参考
  • 重新构建CAS Server War
  • 生成CAS encryption and signing keys
  • 更新CMS Server 配置
  • 单点登录 单点注销

Was this helpful?

  1. Architecture
  2. CAS

CAS 集成LDAP

PreviousCAS Service ManagementNextCAS 集成gitlab

Last updated 4 years ago

Was this helpful?

接下来我们配置 CAS 与本地的LDAP 服务进行集成。

环境介绍

  • CAS 6.4.0 (小版本之间差异也很大)

  • CentOS 7.5

  • JDK 11

  • Tomcat 9.0

参考

重新构建CAS Server War

在 cas-overlay-template 项目中添加下面的依赖文件。

implementation "org.apereo.cas:cas-server-support-ldap:${project.'cas.version'}"

这是 引入了 LDAP 的support,执行 gradle clean build 重新构建,cas.war 包。

生成CAS encryption and signing keys

进入到 cas-overlay-template 项目目录下,执行下面的命令,就可以构建一个本地的cas shell 终端了。

gradlew downloadShell
java -jar build/libs/cas-server-support-shell-6.4.0-SNAPSHOT.jar

敲击 电脑的 tab 键,可以提示命令。

输入help [COMMAND] 可以显示命令帮助。

然后分别生成下面的四个参数。

cas.tgc.crypto.encryption.key=
cas.tgc.crypto.signing.key=
cas.webflow.crypto.signing.key=
cas.webflow.crypto.encryption.key=

如果 不会生成也没有关系,后面cas 启动的过程中,能够看到相应的日志,将自动生成的key 拷贝出来,添加到配置文件中,再重新启动也可以。

启动CAS 时候,注意观察 启动日志,会发现有下面这样的WARN 提醒。

如果提前配置好了这些key,或者将日志中的key 复制添加到配置文件中并重新启动CAS之后,这时的日志输出是。

更新CMS Server 配置

以上三条可以供参考学习。

  • 提醒: 这里笔者试了很长一段时间,在网上google了很多的资料,即便是借鉴了其他的成功案例,依然一直出错。直到最后认真查看了最新版本的帮助文档,仔细尝试了一下,才真正的实验成功。这里有一个小小的忠告,CAS的帮助文档,即便是一个小版本的变化,差异也非常大。例如这里部署的是CAS 6.4.0. 我看了 6.3.x 系列的帮助文档,一直出错,并且帮助文档写的不明不白。

编辑 /etc/cas/config/cas.properties 文件,添加如下的配置。

cas.server.name=http://10.0.41.74:8090
cas.server.prefix=${cas.server.name}/cas

logging.config: file:/etc/cas/config/log4j2.xml
server.port=8090
server.ssl.enabled=false


cas.service-registry.core.init-from-json=true
cas.serviceRegistry.json.location=file:/etc/cas/services

#cas.authn.oauth.grants.resourceOwner.requireServiceHeader=true
#cas.authn.oauth.userProfileViewType=NESTED
#
#cas.authn.policy.requiredHandlerAuthenticationPolicyEnabled=true
#
#cas.authn.attributeRepository.stub.attributes.email=casuser@example.org

# 开启debug 模式
logging.level.org.apereo.cas=DEBUG

# don't allow login of built-in users
cas.authn.accept.users=

## 下面这些key ,如果暂时没有生成,先不用填。启动过程中注意查看日志,会自动生成。
cas.tgc.crypto.encryption.key=xacTHFa9PP9dQPKH4MNiNP9BXoGU3HSsg665vZ_L3yE
cas.tgc.crypto.signing.key=CIcpiVI97d57UmHhiYCSozo2QC8spO6pywdSofBrSJoLxnxWnuVdEYOfevUol9Cu-29GN6eF4RQN-Q8ayR0knQ
cas.webflow.crypto.signing.key=oCFxNGwAcamNBDxNTdWAImA_ujdGXUTEedo8YDRp9iuiAb0spKxvSICRmbiGmCYWA-EbUkDaqXx-KaNJvaR18w
cas.webflow.crypto.encryption.key=mLgVHrGbp4jfj9Sp4_e9uQ

ldap-url=ldap://10.0.41.74:389
ldap-dnformat=uid=%s,ou=People,dc=sugon,dc=com
ldap-base-dn=dc=sugon,dc=com
ldap-bind-dn=cn=ldapadm,dc=sugon,dc=com
ldap-bind-credential=root;123

cas.authn.ldap[0].password-policy.groovy.location=
cas.authn.ldap[0].principal-transformation.groovy.location=
cas.authn.ldap[0].base-dn=${ldap-base-dn}
cas.authn.ldap[0].bind-dn=${ldap-bind-dn}
cas.authn.ldap[0].bind-credential=${ldap-bind-credential}
cas.authn.ldap[0].dn-format=${ldap-dnformat}
cas.authn.ldap[0].ldap-url=${ldap-url}
cas.authn.ldap[0].search-filter=(uid={user})
cas.authn.ldap[0].type=DIRECT
cas.authn.ldap[0].password-encoder.encoding-algorithm=
cas.authn.ldap[0].password-encoder.type=NONE

重新启动 CAS,然后就可以在 http://10.0.41.74:8090/cas/login 使用ldap用户去登录啦。

单点登录 单点注销

关于 单点登录,与单点注销 这里我们是通过 CAS Management 这个服务来进行的配置。

首先新增一个gitlab 服务,将gitlab服务注册到cas server 中。因为我们前面的配置只是设置了gitlab 通过CAS 来登录,还没有实现SSO的目的。

添加退出URL.

也可以参考

最重要

CAS 集成 ldap
环境介绍
参考
重新构建CAS Server War
生成CAS encryption and signing keys
更新CMS Server 配置
单点登录 单点注销
https://apereo.github.io/cas/6.3.x/planning/Installation-Requirements.html
https://apereo.github.io/cas-management/6.3.x/installation/Configuration-Properties.html#ldap-authorization
https://apereo.github.io/tags/
https://apereo.github.io/2019/02/18/cas61-saml2-idp-gitlab/
https://apereo.github.io/2017/10/30/intro-cas-cli-shell/
https://apereo.github.io/cas/6.2.x/configuration/Configuration-Properties.html#ldap-authentication
https://apereo.github.io/2019/02/18/cas61-saml2-idp-gitlab/
https://apereo.github.io/cas/5.2.x/installation/Configuration-Properties.html#ldap-authentication-1
https://apereo.github.io/cas/development/authentication/LDAP-Authentication.html#ldap-authentication
签名信息提醒
正确配置key的日志输出
添加gitlab服务
添加退出URL