【问题标题】:gerrit http authenticationgerrit http 认证
【发布时间】:2012-01-17 02:42:45
【问题描述】:

我正在尝试设置 gerrit HTTP 身份验证。 我正在阅读gerrit http authentication 的文档,其中简要介绍了如何设置 apache,但我究竟应该在哪里放置这段代码并配置 apache tomcat?

否则,我研究并发现了用于http身份验证的“siteminder”;我应该改用它吗?

我的要求是我的自定义系统中有自己的一组用户帐户,并且我需要我的每个用户帐户都能够与 gerrit 交互,因此我认为 http 将允许自定义创建/复制每个用户帐户。

【问题讨论】:

    标签: apache http tomcat continuous-integration gerrit


    【解决方案1】:

    试试这个(不需要tomcat)

    • 下载gerrit.war
    • 初始化一个新项目

      java -jar gerrit.war init -d review
      
    • 将身份验证方法设置为“HTTP”
    • 检查gerrit和apache的配置文件

    etc/gerrit.config

    [gerrit]
        ...
        canonicalWebUrl = http://hostname:9091/
        ...
    [httpd]
        listenUrl = http://*:9090/
        ...
    

    apache 的虚拟主机配置

    Listen 9091
    <VirtualHost *:9091>
      ProxyRequests Off
      ProxyVia Off
      ProxyPreserveHost On
    
      <Proxy *>
        Order deny,allow
        Allow from all
      </Proxy>
    
      <Location /login/>
        AuthType Basic
        AuthName "Gerrit Code Review"
        AuthUserFile /path/to/gerrit-users
        Require valid-user
        Order Deny,Allow
        Allow from all
      </Location>
    
      ProxyPass / http://127.0.0.1:9090/
    </VirtualHost>
    

    【讨论】:

      【解决方案2】:

      我知道这是一个旧线程,但我提供了一个关于 serverfault 的教程,用于在 tomcat 下设置 Gerrit。如果您仍然感兴趣,这里是:

      https://serverfault.com/questions/383573/how-do-i-install-gerrit-under-tomcat-with-ldap

      【讨论】:

        【解决方案3】:

        我花了一段时间才弄明白。

        Tomcat 已安装并测试。

        然后我把gerrit war文件复制过来,放到tomcat/webapps中。然后从tomcat管理器 http://[host]:8080/manager/ 我安装了它(通过点击开始按钮)

        然后我必须安装 mysql J 连接器。基本上是从Mysql下载,然后把jar文件复制到tomcat/lib中

        接下来我在 tomcat/webapps/gerrit/META-INF 中创建了一个名为 Context.xml 的文件

        <Context>
          <Resource name="jdbc/ReviewDb" auth="Container" type="javax.sql.DataSource"
                    maxActive="100" maxIdle="30" maxWait="10000"
                    username="****" password="******" driverClassName="com.mysql.jdbc.Driver"
                    url="jdbc:mysql://localhost:3306/reviewdb"/>
        </Context>
        

        因为我在守护进程中使用了充气城堡,所以我不得不将 .jar 文件从原始安装复制到 tomcat/webapps/gerrit/WEB-INF/lib

        然后我设法启动 gerrit 看看它是否工作。尝试访问 http://[host]:8080/gerrit 这应该会给您一个来自 gerrit 的错误,提示您 Apache conf 错误。

        然后我像这样重新配置了我的 apache 虚拟主机。所以我用http://gerrit/gerrit访问gerrit

        然后在将您的请求传递到 tomcat 服务器之前使用 http auth。

        <VirtualHost *:80>
            ServerAdmin adrian@iceweasel
            ServerName gerrit
            ServerAlias gerrit
            ErrorLog "logs/error_log"
            CustomLog "logs/access_log" vcommon
        
            ProxyRequests Off
            ProxyVia Off
            ProxyPreserveHost On
        
            <Proxy *>
                Order deny,allow
                Allow from all
            </Proxy>
        
            <Location /gerrit/login/>
               AuthType Basic
               AuthName "Gerrit Code Review"
               AuthUserFile /rddata/www/gerrit/users
               AuthGroupFile /rddata/www/gerrit/groups
               Require group review
               Order Deny,Allow
               Allow from all
            </Location>
        
            ProxyPass /gerrit/ http://127.0.0.1:8080/gerrit/
        </VirtualHost>
        

        【讨论】:

        • 谢谢阿德里安!我会试试这个。通常使用 Apache 我会知道把它放在哪里但是使用 apache tomcat 我找不到我的 http.conf 文件!知道它在哪里吗?
        • Adrian 我假设你通过tomcat运行gerrit?现在我将gerrit作为守护进程运行,我如何通过tomcat运行它才能使用你的方法?
        • httpd -V 应该告诉你 apache 在哪里寻找它。当我绕过 tomcat 时,我还应该更新我的答案——我实际上并没有使用它——(我知道我试过了)
        • @user391986 我猜这个 - 但我认为你需要更改 ProxyPass 以指向 tomcat 安装的 IP/端口 - 我现在正在尝试这个(因为我想也使用 tomcat)一定很无聊试图弄清楚 - 我的 tomcat 安装了一半:-)
        • Adrian 非常感谢您提供详细的更新,问题我正在尝试按照您的步骤进行操作,但每次在 tomcat 管理器中按开始时,我都会收到“失败 - 上下文路径 /gerrit-2.1.8 中的应用程序无法开始”
        猜你喜欢
        • 2013-08-13
        • 1970-01-01
        • 1970-01-01
        • 2012-03-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-05-03
        • 2020-09-17
        相关资源
        最近更新 更多