单点登录CAS-03:cas配置01-配置文件类型

1、前言

要了解一个框架或程序如何运行,以及如何定制运行。最好的方式就是研究它的每一个配置文件,每一个配置属性,以及属性的含义和用途。    

2、配置文件分类

用压缩工具打开cas.war文件,进入cas.war\WEB-INF\classes\目录即可看到有许多的.properties和.xml文件。列表如下:

用途 文件名 说明
web配置 apereo.properties
cas-theme-default.properties
js和css路径配置
日志输出 log4j2.xml 日志级别或路径配置
注:在windows需改此文件,默认是linux路径
国际化 messages.properties
messages_{地区后缀}.properties
用于控制web页面显示内容
SSL认证 truststore.jks 使用keyTool工具生成
使用https需要重新生成此文件
spring clound配置 bootstrap.properties 若使用spring clound则修改此文件
用户权限 user-details.properties 定义用户角色等,一般不会使用到。
CAS配置 application.yml
application.properties
默认.yml为空
这是主要的配置入口

3、application.properties详解

application.properties包含cas运行所需要的一系列参数。若要自定义此配置文件,可以创建application.properties到cas-overlay-template\src\main\resources\目录下,然后重新执行maven构建生成war包。
不建议直接修改cas.war中的配置文件,因为如果这样做,当重新cas.war时,所修改的配置就会丢失了。

3.1springboot相关参数

注:内置容器是指cas.war包含了tomcat的jar包,以springboot方式运行
如果cas.war放在tomcat/webapps/下运行,以下参数无效!

3.1.1 内置容器配置

##
# CAS Server Context Configuration
# CAS服务应用上下文配置
#
#Web应用名称
server.context-path=/cas
#应用监听端口
server.port=8443

# 以下是SSL证书相关参数。若要禁用SSL功能请注释掉以下参数,或者给以下参数设置空值。
#
#SSL证书(https)保存路径
server.ssl.key-store=file:/etc/cas/thekeystore
#SSL证书密钥库
server.ssl.key-store-password=changeit
#SSL证书密码
server.ssl.key-password=changeit

#单次http请求的header头最大长度2MB=2097152/1024/1024
server.max-http-header-size=2097152
#转发http报文时是否连header头一起转发?
server.use-forward-headers=true
#连接超时时长2秒=2 * 1000
server.connection-timeout=20000
#服务器发生错误时,错误信息是否要包含堆栈信息
server.error.include-stacktrace=ALWAYS

#是否压缩http报文
server.compression.enabled=true
#要压缩的报文格式
server.compression.mime-types=application/javascript,application/json,application/xml,text/html,text/xml,text/plain
######################################################
#               以下是tomcat相关配置
######################################################
#单次http请求的header头最大长度2MB=2097152/1024/1024
server.tomcat.max-http-post-size=2097152
#存放Tomcat日志、Dump等文件的临时文件夹,默认为系统的tmp文件夹
server.tomcat.basedir=build/tomcat
#打开Tomcat的Access日志,并可以设置日志格式的方法
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%t %a "%r" %s (%D ms)
server.tomcat.accesslog.suffix=.log
#tomcat初始会创建的线程数
server.tomcat.min-spare-threads=10
#tomcat最大线程数,默认为200
server.tomcat.max-threads=200
#设定http header使用的,用来覆盖原来port的value.
server.tomcat.port-header=X-Forwarded-Port
#设定Header包含的协议,通常是 X-Forwarded-Proto,如果remoteIpHeader有值,则将设置为RemoteIpValve.
server.tomcat.protocol-header=X-Forwarded-Proto
#设定使用SSL的header的值,默认https.
server.tomcat.protocol-header-https-value=https
#设定remote IP的header,如果remoteIpHeader有值,则设置为RemoteIpValve
server.tomcat.remote-ip-header=X-FORWARDED-FOR
#tomcat的默认URI解码字符集
server.tomcat.uri-encoding=UTF-8

#springboot的http请求编码格式
spring.http.encoding.charset=UTF-8
#是否为springboot指定http请求的编码
spring.http.encoding.enabled=true
#是否对springboot指定http请求编制编码
spring.http.encoding.force=true

3.1.2 spring云总线配置

#是否启用spring云总结。默认false
spring.cloud.bus.enabled=false

# 指示是否用本机属性覆盖云总线的配置
#如果想要远程配置优先级高,那么allowOverride设置为false,如果想要本地配置优先级高那么allowOverride设置为true。默认为true。
spring.cloud.config.allow-override=true

#外部配置是否可覆盖本机的配置.
spring.cloud.config.override-system-properties=false

# When allowOverride is true, external properties should take lowest priority, and not override any
# existing property sources (including local config files).
#外部源配置是否不覆盖任何源
spring.cloud.config.override-none=false

#是否动态刷新总线配置
# spring.cloud.bus.refresh.enabled=true
#是否启用环境变化事件
# spring.cloud.bus.env.enabled=true
#总线使用的队列或主题名称
# spring.cloud.bus.destination=CasCloudBus
#是否启用总线ack消息确认,若不确认成功则重发
# spring.cloud.bus.ack.enabled=true

#如CAS访问地址是http://localhost/cas
#则默认访问http://localhost/cas/status/dashboard会提示没权限。
#要打开status需要修改下面的配置。
在application.properties中修改和增加如下的信息:
#enabled要设置为true, sensitive要设置为false
endpoints.enabled=false
endpoints.sensitive=true

endpoints.restart.enabled=false
endpoints.shutdown.enabled=false
##

3.1.3安全管理


# Control the security of the management/actuator endpoints
# The 'enabled' flag below here controls the rendering of details for the health endpoint amongst other things.
#启用安全管理
management.security.enabled=true
#安全管理的角色:执行者,管理员
management.security.roles=ACTUATOR,ADMIN
#安全管理session
management.security.sessions=if_required
#安全管理上下文(应用名)
management.context-path=/status
#在每个响应中添加“X-Application-Context”HTTP头
management.add-application-context-header=false
# Define a CAS-specific "WARN" status code and its order
#管理健康状态的顺序
management.health.status.order=WARN, DOWN, OUT_OF_SERVICE, UNKNOWN, UP

# Control the security of the management/actuator endpoints
# With basic authentication, assuming Spring Security and/or relevant modules are on the classpath.
#安全基础鉴权模式:通过角色鉴权
security.basic.authorize-mode=role
#安全基础路径
security.basic.path=/cas/status/**
#安全基础启用
# security.basic.enabled=true
#安全用户名
# security.user.name=casuser
#安全用户密码
# security.user.password=

3.1.4CAS Web应用会话配置

##
# CAS Web Application Session Configuration
#
#会话超时时长,默认300
server.session.timeout=300
#是否设置Cookie没有安全标志
#如果在Cookie中设置了"HttpOnly"属性,那么通过程序(JS脚本、Applet等)将无法读取到Cookie信息,这样能有效的防止XSS攻击。
server.session.cookie.http-only=true
#设定Session的追踪模式(cookie, url, ssl)
server.session.tracking-modes=COOKIE

3.1.5 thymeleaf模板引擎配置

##
# CAS Thymeleaf View Configuration
#
#模板编码格式,默认UTF-8
spring.thymeleaf.encoding=UTF-8
#是否启用模板缓存。默认true
spring.thymeleaf.cache=true
#模板格式校验(LEGACYHTML5,HTML5,HTML)
#LEGACYHTML5——严格校验
spring.thymeleaf.mode=HTML
##Thymeleaf模板解析器在解析器链中的顺序。默认情况下,它排第一位。顺序从1开始,只有在定义了额外的TemplateResolver Bean时才需要设置这个属性。
spring.thymeleaf.template-resolver-order=100

3.1.6 log4j配置

##
# CAS Log4j Configuration
#
# logging.config=file:/etc/cas/log4j2.xml
#是否禁用log4j自动初始化?
server.context-parameters.isLog4jAutoInitializationDisabled=true

3.1.7 CAS切面配置

##
# CAS AspectJ Configuration
#
#是否自动启用aop切面
spring.aop.auto=true
#是否使用切面代理目标类
spring.aop.proxy-target-class=true

3.2 CAS 登录帐号配置

##
# CAS Authentication Credentials
# 用户名:casuser,密码:Mellon
cas.authn.accept.users=casuser::Mellon
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章