天天看點

單點登入CAS-03:cas配置02-開啟/status1、前言2、開啟/status/dashboard

單點登入CAS-03:cas配置02-開啟/status

  • 1、前言
  • 2、開啟/status/dashboard
    • 2.1找到相關的配置項參數
      • 2.1.1 Spring Boot Endpoints屬性清單
      • 2.1.2 CAS Endpoints屬性清單
    • 2.2 配置案例示範
      • 2.2.1 案例1:使用全局性配置
      • 2.2.2 案例1:驗證
      • 2.2.3 案例2:明細配置版本
      • 2.2.4 案例2:驗證
      • 2.2.3 案例3:明細配置版本-禁用某節點
      • 2.2.4 案例3:驗證

1、前言

CAS官方推薦使用/status/dashboard來管理CAS的配置,見https://apereo.github.io/cas/5.3.x/installation/Configuration-Management.html

單點登入CAS-03:cas配置02-開啟/status1、前言2、開啟/status/dashboard

點選上圖的連結,進入文檔頁:https://apereo.github.io/cas/5.3.x/installation/Monitoring-Statistics.html

此頁面有一個應用映射表格列述如下:

應用路徑 作用描述
/status/dashboard

The control panel to CAS server functionality and management

CAS伺服器功能與管理的【控制台】.

/status

Monitor CAS status and other underlying components.

監控CAS狀态及其它底層元件

/status/sso

Describes if there exists an active SSO session for this request tied to this browser session.

描述此請求是否存在綁定到此浏覽器會話的活動SSO會話

/status/swf

Describes the current configured state of CAS webflow in JSON.

描述JSON中CAS webflow的目前配置狀态

/status/stats

Visual representation of CAS statistics with graphs and charts, etc.

CAS統計的圖形、圖表等可視化表示

/status/logging

Monitor CAS logs in a streaming fashion and review the audit log.

以流式方式監視CAS日志并檢視稽核日志

/status/config

Visual representation of application properties and configuration.

應用程式屬性和配置的可視化表示

/status/ssosessions

Reports active SSO sessions. Examine attributes, services and log users out.

報告活動的SSO會話。檢查屬性、服務并登出使用者

/status/services

Reports the collection of applications registered with CAS.

報告在CAS注冊的應用程式的集合

/status/trustedDevs

Reports on the registered trusted devices/browsers.

關于注冊的受信任裝置/浏覽器的報告

/status/authnEvents

When enabled, reports on the events captured by CAS.

啟用後,報告由CAS捕獲的事件

/status/attrresolution

Examine resolution of user attributes via CAS attribute resolution.

通過CAS屬性解析檢查使用者屬性的解析

/status/discovery

Advertises the CAS server’s profile, features and capabilities for auto-configuration of client applications.

宣傳CAS伺服器的配置檔案、功能和自動配置用戶端應用程式的功能

2、開啟/status/dashboard

CAS預設情況下,是禁用/status路徑的通路的,如下圖:

單點登入CAS-03:cas配置02-開啟/status1、前言2、開啟/status/dashboard

2.1找到相關的配置項參數

在https://apereo.github.io/cas/5.3.x/installation/Configuration-Management.html頁面,點選連結

單點登入CAS-03:cas配置02-開啟/status1、前言2、開啟/status/dashboard

進入到https://apereo.github.io/cas/5.3.x/installation/Configuration-Properties.html#cas-endpoints此處可看到需要配置的參數清單。

單點登入CAS-03:cas配置02-開啟/status1、前言2、開啟/status/dashboard

在頁面上按Ctrl+F查找"/status"可以看到有一段這樣的文字“The following properties describe access controls and settings for the /status endpoint of CAS which provides administrative functionality and oversight into the CAS software. These endpoints are specific to Spring Boot”。大意是說以下的屬性描述/status節點的通路控制。

單點登入CAS-03:cas配置02-開啟/status1、前言2、開啟/status/dashboard

綜上所述,我們找到了開啟/status權限需要了兩上配置清單,我将其列在下面,并且寫上備注以便了解。

2.1.1 Spring Boot Endpoints屬性清單

# Globally control whether endpoints are enabled
# 全局控制是否開啟endpoints節點
# or marked as sensitive to require authentication.
# 或标記sensitive為要求授權(即設定為true)

#所有終結點打開。預設為false
#經驗證此選項為true時,/cas/status/config能看到屬性清單,否則看不到
 endpoints.enabled=true
#所有終結點敏感。預設為true
 endpoints.sensitive=true

#管理上下文路徑,預設為/status。
management.contextPath=/status
#是否開啟管理安全,預設為true
management.security.enabled=true
#管理安全使用者角色,預設為ACTUATOR,ADMIN
management.security.roles=ACTUATOR,ADMIN
#是否管理安全會話,預設為if_required
management.security.sessions=if_required

# Each of the below endpoints can either be disabled
# 以下每個endpoints既可禁用(enabled=false),
# or can be marked as 'sensitive' (or not)
# 也可以标記為sensive即敏感項。
# to enable authentication. The global flags above control
# 來開啟授權。以上所列述是全局标志控制所有内容
# everything and individual settings below act as overrides.
# 以下所述的是單獨設定用作覆寫

# 以下配置預設是注釋掉的,此處将其打開
#配置清單《開始》
#------------------------------------------
#啟用/restart端點重新啟動應用程式上下文。如果設定為true,則浏覽器中輸入網址/cas/restart按回車,就自動重新啟動應用程式上下文
#注:設為true後,在/cas/status/dashboard頁面會出現Reboot操作按鈕
 endpoints.restart.enabled=false
#啟用/shutdown端點來關閉應用程式。如果設定為true,則浏覽器中輸入網址/cas/shutdown按回車,就自動關閉應用的端點
#注:設為true後,在/cas/status/dashboard頁面會出現shutdown操作按鈕
 endpoints.shutdown.enabled=false
# 啟用端點的自動配置。預設為true
 endpoints.autoconfig.enabled=true
# 啟用端點的bean加載。預設為true
 endpoints.beans.enabled=true
# 是否啟用總線
 endpoints.bus.enabled=true
# 是否啟用配置屬性 
 endpoints.configprops.enabled=true
#是否啟用dump。
 endpoints.dump.enabled=true
#是否啟用環境變化事件
 endpoints.env.enabled=true
#是否啟用節點健康檢查 
 endpoints.health.enabled=true
#是否啟用節點功能
 endpoints.features.enabled=true
#是否啟用info
 endpoints.info.enabled=true
#是否啟動節點日志
 endpoints.loggers.enabled=true
#是否啟用節點日志檔案
 endpoints.logfile.enabled=true
#是否啟用節點追蹤
 endpoints.trace.enabled=true
#是否啟用節點文檔
 endpoints.docs.enabled=false
#是否啟用堆棧導出
 endpoints.heapdump.enabled=true
#配置清單《結束》
#------------------------------------------

# IP address may be enough to protect all endpoints.
#IP位址可能足以保護所有終結點
# It's set to always protect the /status endpoint.
#它設定為始終保護/狀态終結點

#安全管理頁通路時要校驗的IP位址。例如設定成127.0.0.1那麼在浏覽器中隻能用127.0.0.1來通路,即使用localhost也是無權限通路的。
#這樣做的用意是保護安全管理頁的通路權限。此項預設是注釋掉的,預設值為127\.0\.0\.1,這裡需要将其打開,否則是通路不到的。
 cas.adminPagesSecurity.ip=127.0.0.1
#
# cas.adminPagesSecurity.alternateIpHeaderName=X-Forwarded-For

# If you wish to protect the admin pages via CAS itself, configure the rest.
#如果希望通過CAS本身保護管理頁,請配置其餘的配置項。

# cas登入頁網址。預設不用開啟。如果開啟則要寫成應用的通路路徑。
# cas.adminPagesSecurity.loginUrl=https://sso.example.org/cas/login
#cas控制台網址。預設不用開啟。如果開啟則要寫成應用的通路路徑。
# cas.adminPagesSecurity.service=https://sso.example.org/cas/status/dashboard
#cas安全管理頁的使用者帳号。這裡可以指向一個配置檔案
# 如果不指定帳号檔案,則預設會讀取user-details.properties
#cas.adminPagesSecurity.users=file:/etc/cas/config/adminusers.properties
#cas安全管理頁的角色。
# cas.adminPagesSecurity.adminRoles[0]=ROLE_ADMIN
#是否啟用CAS安全管理頁執行者節點。預設為tree
# cas.adminPagesSecurity.actuatorEndpointsEnabled=true
           

2.1.2 CAS Endpoints屬性清單

cas.monitor.endpoints
#終結點dashboard對應uri為/cas/status/dashboard
#這是一個快捷方式頁面,裡面有很多按鈕可以進入到其他節點
cas.monitor.endpoints.dashboard
cas.monitor.endpoints.discovery
cas.monitor.endpoints.auditEvents
#管理身份驗證事件,終結點/cas/status/authnEvents
cas.monitor.endpoints.authenticationEvents
#配置頁,終結點/cas/status/config
cas.monitor.endpoints.configurationState
cas.monitor.endpoints.healthCheck
#檢視日志,終結點/cas/status/logging
cas.monitor.endpoints.loggingConfig
#度量名額,終結點/cas/status/metrics
cas.monitor.endpoints.metrics
#屬性配置清單,終結點/cas/status/attrresolution
cas.monitor.endpoints.attributeResolution
cas.monitor.endpoints.singleSignOnReport
#ticket憑證統計,終結點/cas/status/stats
cas.monitor.endpoints.statistics
cas.monitor.endpoints.trustedDevices
#cas狀态,終結點/cas/status
#注:該終結點不會影響子級終結點。例如
#-------------------------------------------------
#cas.monitor.endpoints.status.enabled=false
#cas.monitor.endpoints.dashboard.enabled=true
#-------------------------------------------------
#如上配置/cas/status不能通路,但是/cas/status/dashboard仍能通路
cas.monitor.endpoints.status
#單點登入,終結點/cas/status/sso
cas.monitor.endpoints.singleSignOnStatus
#springWebflow,終結點/cas/status/swf
#注此配置.enabled隻能控制dashboard面闆是否顯示子產品入口,即使.enabled=false浏覽器輸入網址仍能通路
cas.monitor.endpoints.springWebflowReport
#服務注冊,終結點/cas/status/services
cas.monitor.endpoints.registeredServicesReport
#配置中繼資料,終結點/cas/status/configmetadata
cas.monitor.endpoints.configurationMetadata
           

注 :CAS Endpoints的屬性清單隻是給出了一個屬性項目,每個項目有兩個參數enabled(是否啟用true或false),sensitive(用于标志該配置是否敏感資訊——即是否需要授權的操作,如果設定為true,則所有的原生端點都需要授權操作,設定為false則不需要,預設是false)

是以可以得到一個設定CAS Endpoints的屬性的原則:

  1. 所有的enabled屬性應該設定為true
  2. 所有的sensitive屬性應該設定為false——需要嚴格授權的情況除外

參考文章:https://www.iteye.com/blog/357029540-2392530

此處引述作者的話

2.endpoints.enabled

該配置屬性用于控制所有的通路原生端點的可用性,設定為false的時候所有的原生端點都不可以通路,設定為true時所有的原生端點可以通路。預設為true。

3.endpoints.{name}.enabled

該配置屬性是相對endpoints.enabled來說的,endpoints.enabled是将所有的原生端點的禁止通路,而enedpoints.{name}.enabled屬性是針對某個具體的原生端點進行控制,設定為true時該原生端點可以通路,設定為false的時候不可通路,預設為true。

4.endpoints.sensitive

該配置屬性用于配置敏感資訊,即是否需要授權的操作,如果設定為true,則所有的原生端點都需要授權操作,設定為false則不需要,預設是false,這裡需要注意的是如果沒有主動設定該值的話,有些原生端點是需要授權才能通路的,如/beans,/env等,當與management.security.enabled一起使用時以management.security.enabled為主。

5.endpoints.{name}.sensitive

該配置屬性是相對endpoints.sensitive來說的,endpoints.sensitive是将所有的原生端點進行授權操作,而endpoints.{name}.sensitive是對某個具體的原生端點進行控制,設定為true時該原生端點需要授權操作,設定為false的時候不需要授權通路,具體的預設值需要看具體的原生端點。

2.2 配置案例示範

在cas-overlay-template工程目錄下建立src\main\resources\檔案夾,所有的配置檔案放到這裡面去。

預設的配置檔案可以從cas.war檔案中獲得。如果你沒有cas.war,請看前面的博文:單點登入CAS-02:如何得到一個cas.war?

請先下載下傳工程執行mvn clean package得到一個預設的cas.war。

2.2.1 案例1:使用全局性配置

本案例使用到檔案:application.properties。這個檔案的預設版本能從cas.war中獲得。

以下配置加入到application.properties中,如果配置項已存在則覆寫。

#安全管理頁通路時要校驗的IP位址。例如設定成127.0.0.1那麼在浏覽器中隻能用127.0.0.1來通路,即使用localhost也是無權限通路的。
#這樣做的用意是保護安全管理頁的通路權限。此項預設是注釋掉的,預設值為127\.0\.0\.1,這裡需要将其打開,否則是通路不到的。
 cas.adminPagesSecurity.ip=127.0.0.1
#管理上下文路徑,預設為/status。
management.contextPath=/status
#是否開啟管理安全,預設為true
management.security.enabled=true
#管理安全使用者角色,預設為ACTUATOR,ADMIN
management.security.roles=ACTUATOR,ADMIN
#是否管理安全會話,預設為if_required
management.security.sessions=if_required

#節點開關配置(全局)
cas.monitor.endpoints.enabled=true
cas.monitor.endpoints.sensitive=false
           

2.2.2 案例1:驗證

cmd視窗進入cas-overlay-template工程目錄,執行mvn clean package生成cas.war後部署到tomcat\webapps目錄下。

啟動tomcat加載完成後,打開浏覽器通路網址http://127.0.0.1:7711/cas/status/dashboard。

單點登入CAS-03:cas配置02-開啟/status1、前言2、開啟/status/dashboard

以上可以看到即使不登入使用者,也是可以通路/status/dashboard頁面的。

2.2.3 案例2:明細配置版本

本案例使用到檔案:application.properties。這個檔案的預設版本能從cas.war中獲得。

以下配置加入到application.properties中,如果配置項已存在則覆寫。

#安全管理頁通路時要校驗的IP位址。例如設定成127.0.0.1那麼在浏覽器中隻能用127.0.0.1來通路,即使用localhost也是無權限通路的。
#這樣做的用意是保護安全管理頁的通路權限。此項預設是注釋掉的,預設值為127\.0\.0\.1,這裡需要将其打開,否則是通路不到的。
 cas.adminPagesSecurity.ip=127.0.0.1
#管理上下文路徑,預設為/status。
management.contextPath=/status
#是否開啟管理安全,預設為true
management.security.enabled=true
#管理安全使用者角色,預設為ACTUATOR,ADMIN
management.security.roles=ACTUATOR,ADMIN
#是否管理安全會話,預設為if_required
management.security.sessions=if_required

#節點開關配置(全局)
#cas.monitor.endpoints.enabled=true
#cas.monitor.endpoints.sensitive=false

#節點開關配置(明細)。每項後面指定enabled和sensitive
cas.monitor.endpoints.dashboard.enabled=true
cas.monitor.endpoints.dashboard.sensitive=false

cas.monitor.endpoints.discovery.enabled=true
cas.monitor.endpoints.discovery.sensitive=false

cas.monitor.endpoints.auditEvents.enabled=true
cas.monitor.endpoints.auditEvents.sensitive=false

cas.monitor.endpoints.authenticationEvents.enabled=true
cas.monitor.endpoints.authenticationEvents.sensitive=false

cas.monitor.endpoints.configurationState.enabled=true
cas.monitor.endpoints.configurationState.sensitive=false

cas.monitor.endpoints.healthCheck.enabled=true
cas.monitor.endpoints.healthCheck.sensitive=false

cas.monitor.endpoints.loggingConfig.enabled=true
cas.monitor.endpoints.loggingConfig.sensitive=false

cas.monitor.endpoints.metrics.enabled=true
cas.monitor.endpoints.metrics.sensitive=false

cas.monitor.endpoints.attributeResolution.enabled=true
cas.monitor.endpoints.attributeResolution.sensitive=false

cas.monitor.endpoints.singleSignOnReport.enabled=true
cas.monitor.endpoints.singleSignOnReport.sensitive=false

cas.monitor.endpoints.statistics.enabled=true
cas.monitor.endpoints.statistics.sensitive=false

cas.monitor.endpoints.trustedDevices.enabled=true
cas.monitor.endpoints.trustedDevices.sensitive=false

cas.monitor.endpoints.status.enabled=true
cas.monitor.endpoints.status.sensitive=false

cas.monitor.endpoints.singleSignOnStatus.enabled=true
cas.monitor.endpoints.singleSignOnStatus.sensitive=false

cas.monitor.endpoints.springWebflowReport.enabled=true
cas.monitor.endpoints.springWebflowReport.sensitive=false

cas.monitor.endpoints.registeredServicesReport.enabled=true
cas.monitor.endpoints.registeredServicesReport.sensitive=false

cas.monitor.endpoints.configurationMetadata.enabled=true
cas.monitor.endpoints.configurationMetadata.sensitive=false

           

2.2.4 案例2:驗證

cmd視窗進入cas-overlay-template工程目錄,執行mvn clean package生成cas.war後部署到tomcat\webapps目錄下。

啟動tomcat加載完成後,打開浏覽器通路網址http://127.0.0.1:7711/cas/status/dashboard。

單點登入CAS-03:cas配置02-開啟/status1、前言2、開啟/status/dashboard

打開浏覽器通路網址http://127.0.0.1:7711/cas/status/dashboard。

單點登入CAS-03:cas配置02-開啟/status1、前言2、開啟/status/dashboard

以上可以看到即使不登入使用者,也是可以通路/status/dashboard和/status/stats頁面的。

2.2.3 案例3:明細配置版本-禁用某節點

本案例使用到檔案:application.properties。這個檔案的預設版本能從cas.war中獲得。

以下配置加入到application.properties中,如果配置項已存在則覆寫。

#安全管理頁通路時要校驗的IP位址。例如設定成127.0.0.1那麼在浏覽器中隻能用127.0.0.1來通路,即使用localhost也是無權限通路的。
#這樣做的用意是保護安全管理頁的通路權限。此項預設是注釋掉的,預設值為127\.0\.0\.1,這裡需要将其打開,否則是通路不到的。
 cas.adminPagesSecurity.ip=127.0.0.1
#管理上下文路徑,預設為/status。
management.contextPath=/status
#是否開啟管理安全,預設為true
management.security.enabled=true
#管理安全使用者角色,預設為ACTUATOR,ADMIN
management.security.roles=ACTUATOR,ADMIN
#是否管理安全會話,預設為if_required
management.security.sessions=if_required

#節點開關配置(全局)
#cas.monitor.endpoints.enabled=true
#cas.monitor.endpoints.sensitive=false

#節點開關配置(明細)。每項後面指定enabled和sensitive
cas.monitor.endpoints.dashboard.enabled=true
cas.monitor.endpoints.dashboard.sensitive=false

cas.monitor.endpoints.discovery.enabled=true
cas.monitor.endpoints.discovery.sensitive=false

cas.monitor.endpoints.auditEvents.enabled=true
cas.monitor.endpoints.auditEvents.sensitive=false

cas.monitor.endpoints.authenticationEvents.enabled=true
cas.monitor.endpoints.authenticationEvents.sensitive=false

cas.monitor.endpoints.configurationState.enabled=true
cas.monitor.endpoints.configurationState.sensitive=false

cas.monitor.endpoints.healthCheck.enabled=true
cas.monitor.endpoints.healthCheck.sensitive=false

cas.monitor.endpoints.loggingConfig.enabled=true
cas.monitor.endpoints.loggingConfig.sensitive=false

cas.monitor.endpoints.metrics.enabled=true
cas.monitor.endpoints.metrics.sensitive=false

cas.monitor.endpoints.attributeResolution.enabled=true
cas.monitor.endpoints.attributeResolution.sensitive=false

cas.monitor.endpoints.singleSignOnReport.enabled=true
cas.monitor.endpoints.singleSignOnReport.sensitive=false

#關閉/status/stats
cas.monitor.endpoints.statistics.enabled=false
cas.monitor.endpoints.statistics.sensitive=false

cas.monitor.endpoints.trustedDevices.enabled=true
cas.monitor.endpoints.trustedDevices.sensitive=false

cas.monitor.endpoints.status.enabled=true
cas.monitor.endpoints.status.sensitive=false

cas.monitor.endpoints.singleSignOnStatus.enabled=true
cas.monitor.endpoints.singleSignOnStatus.sensitive=false

cas.monitor.endpoints.springWebflowReport.enabled=true
cas.monitor.endpoints.springWebflowReport.sensitive=false

cas.monitor.endpoints.registeredServicesReport.enabled=true
cas.monitor.endpoints.registeredServicesReport.sensitive=false

cas.monitor.endpoints.configurationMetadata.enabled=true
cas.monitor.endpoints.configurationMetadata.sensitive=false

           

2.2.4 案例3:驗證

cmd視窗進入cas-overlay-template工程目錄,執行mvn clean package生成cas.war後部署到tomcat\webapps目錄下。

啟動tomcat加載完成後,打開浏覽器通路網址http://127.0.0.1:7711/cas/status/dashboard。

單點登入CAS-03:cas配置02-開啟/status1、前言2、開啟/status/dashboard

打開浏覽器通路網址http://127.0.0.1:7711/cas/status/stats。

單點登入CAS-03:cas配置02-開啟/status1、前言2、開啟/status/dashboard

以上可以看到當設定cas.monitor.endpoints.statistics.enabled=false時/status/stats子產品無法通路了。

繼續閱讀