Sonar集成CAS

前提

集成

  • 插件下载

       http://repository.codehaus.org/org/codehaus/sonar-plugins/sonar-cas-plugin/0.1/sonar-cas-plugin-0.1.jar

       拷贝到extensions\plugins目录下

  • 插件配置

       conf/sonar.properties文件里添加如下参数

# this property must be set to true
sonar.authenticator.createUsers=true

# enable CAS plugin
sonar.security.realm=cas

# cas1, cas2 or saml11
sonar.cas.protocol=cas2

# Location of the CAS server login form, i.e. https://localhost:8443/cas/login
sonar.cas.casServerLoginUrl=http://localhost:8080/cas/login

# CAS server root URL, i.e. https://localhost:8443/cas
sonar.cas.casServerUrlPrefix=http://localhost:8080/cas

# Sonar server root URL, without ending slash
sonar.cas.sonarServerUrl=http://localhost:9000

# Optional CAS server logout URL. If set, sonar session will be deleted on CAS logout request.
#sonar.cas.casServerLogoutUrl=http://localhost:8080/cas/logout

# Specifies whether gateway=true should be sent to the CAS server. Default is false.
#sonar.cas.sendGateway=false

# The tolerance in milliseconds for drifting clocks when validating SAML 1.1 tickets.
# Note that 10 seconds should be more than enough for most environments that have NTP time synchronization.
# Default is 1000 milliseconds.
#sonar.cas.saml11.toleranceMilliseconds=1000
如果是基于sonar3.3版本之前,到此步骤已完成整合。


修复Sonar3.3版本后的兼容

      这里有描述3.3版本后与CAS集成出现的问题http://jira.codehaus.org/browse/SONARPLUGINS/component/15492

     情况是从首页点击登录按钮后可以跳转到CAS进行验证,但回调回来依旧还是没登录。这个问题引起的原因还是不清楚,比如

  • session没有保存在cookie中

I replaced the java_servlets_store by a cookie_store in environment.rb and it works fine.
I guess the problem comes from jruby-rack.
  • 升级了JRuby and Rails


      下面是我们的解决办法,可能比较笨

  • 修改SONAR登录按钮跳转地址

      打开web/WEB-INF/app/views/layouts/_layout.html.erb, 修改第38行如下

<li><a href="<%= ApplicationController.root_context -%>/koala"><%= message('layout.login') -%></a></li>

     注意:跳转链接中koala地址与你在第二步骤定义的跳转控制器定义的名称一致

  • 添加一个跳转控制器

     在web/WEB-INF/app/controllers/目录下添加文件:koala_controller.rb,内容如下

class KoalaController < ApplicationController

  SECTION=Navigation::SECTION_CONFIGURATION
  before_filter :admin_required, :except => ['new', 'signup', 'autocomplete']
  skip_before_filter :check_authentication, :only => ['new', 'signup', 'autocomplete']

  def index
    redirect_back_or_default(home_url)
  end

end


转载于:https://my.oschina.net/xiaokaceng/blog/181708

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值