阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

单点登录之cas集成sonar的配置方法详解

260次阅读
没有评论

共计 2571 个字符,预计需要花费 7 分钟才能阅读完成。

导读 这篇文章主要介绍了单点登录之 cas 集成 sonar 的相关知识,本文通过示例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值, 需要的朋友可以参考下
一、修改 sonar 配置 conf/sonar.properties

修改 sonar 配置文件 conf/sonar.properties:

sonar.security.realm = cas                                                                                                                                                                                                                                                                            
sonar.authenticator.createUsers = true                                                                                                              
#sonar.cas.forceCasLogin = true                                                                                                                     
sonar.cas.protocol = cas3                                                                                                                           
sonar.cas.casServerUrlPrefix = http://192.168.1.58:8080/cas                                                                                         
sonar.cas.casServerLoginUrl = http://192.168.1.58:8080/cas/login                                                                    
sonar.cas.casServerLogoutUrl = http://192.168.1.58:8080/cas/logout                                                                  
sonar.cas.sonarServerUrl = http://192.168.1.35:9200                                              
sonar.cas.urlAfterCasRedirectCookieMaxAgeSeconds = 300            
sonar.cas.sessionStorePath = /opt/sonarqube/data/sonarcas/sessionstore        
sonar.cas.sessionStore.cleanUpIntervalInSeconds = 1800                                    
                                                                                               
# Specifies whether gateway=true should be sent to the CAS server. Default is false.                                                
# sonar.cas.sendGateway                                                                       
                                                                                     
# Specifies how SonarQube groups should be replicated. A value of "CAS" always overwrites the user's local groups with                     
# the group provided by CAS upon UI log-in. The user's local groups will be untouched, f. i. with the value"sonarqube".
# Defaults to "CAS".                                                                                                    
sonar.cas.groupReplication = CAS                                                                                                   
sonar.cas.rolesAttributes = groups                                                                                      
sonar.cas.fullNameAttribute = displayName                                                                               
sonar.cas.eMailAttribute = mail                                                                                                                    
sonar.cas.saml11.toleranceMilliseconds = 1000                                                                           
sonar.cas.disableCertValidation = true
二、下载插件 sonar-cas-plugin

下载插件 sonar-cas-plugin,将插件拷贝至 sonar 的 extentions/plugins 目录下,并重启 sonar 服务。

下载链接:https://github.com/cloudogu/sonar-cas-plugin/releases

单点登录之 cas 集成 sonar 的配置方法详解

三、修改 cas 配置文件 application.yml

修改 cas 配置文件 application.yml,修改内容如下:

# Application properties that need to be
# embedded within the web application can be included here
cas:
  authn:
    jdbc:
      query:
      - dialect: org.hibernate.dialect.MySQLDialect
        driverClass: com.mysql.jdbc.Driver
        fieldPassword: password
        password: 'xxxxxx'
        sql: select * from user where user_name=?
        url: jdbc:mysql://192.168.1.32:3306/cas?useUnicode=true&characterEncoding=utf-8&useSSL=false
        user: root
  serviceRegistry:
    initFromJson: true
  tgc:
    secure: false
四、修改 cas 配置文件 HTTPSandIMAPS-10000001.json

新增 cas/WEB-INF/classes/services/HTTPSandIMAPS-10000001.json 文件,添加 http 支持:

{
  "@class" : "org.apereo.cas.services.RegexRegisteredService",
  "serviceId" : "^(https?|http?|imaps?)://.*",
  "name" : "All",
  "id" : 10000000,
  "description" : "This service definition authorizes all application urls that support HTTPS and IMAPS protocols.",
  "evaluationOrder" : 10000,
  "proxyPolicy" : {
    "@class" : "org.apereo.cas.services.RegexMatchingRegisteredServiceProxyPolicy",
    "pattern" : "^(https?|http?|imaps?)://.*"
  },
  "usernameAttributeProvider" : {"@class" : "org.apereo.cas.services.DefaultRegisteredServiceUsernameProvider"},
  "attributeReleasePolicy" : {"@class" : "org.apereo.cas.services.ReturnAllAttributeReleasePolicy"}
}

到此这篇关于单点登录之 cas 集成 sonar 的文章就介绍到这了。

阿里云 2 核 2G 服务器 3M 带宽 61 元 1 年,有高配

腾讯云新客低至 82 元 / 年,老客户 99 元 / 年

代金券:在阿里云专用满减优惠券

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2024-07-25发表,共计2571字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中