Project

General

Profile

cgit + redmine + git (advance integration)

Added by amree woot over 9 years ago

Hello

I've successfully managed to configure my Redmine with advance git integration. However, I'm very interested in combining cgit with the current configs, but I'm not sure how. So, basically I want to use cgit with authentication from Redmine by combining these two configs.

Here are my working configs (will only work if I disable one of them):

<VirtualHost *:80>                                       
    ServerName git.domain
    DocumentRoot "/var/www/htdocs/cgit/" 
    DirectoryIndex cgit.cgi
    SetEnv  CGIT_CONFIG   /etc/cgitrc

    <Directory "/var/www/htdocs/cgit">
        Options FollowSymlinks ExecCGI
        Allow from all
        AllowOverride all
        Order allow,deny

        <Files cgit.cgi>
            SetHandler cgi-script
        </Files>

        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^.* /cgit.cgi/$0 [L,PT]
    </Directory>

    <Directory "/opt/git">
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
  ServerName git.domain
  DocumentRoot /opt/git

  SetEnv GIT_PROJECT_ROOT /opt/git
  SetEnv GIT_HTTP_EXPORT_ALL
  SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER

  ScriptAlias / /usr/lib/git-core/git-http-backend/
  AliasMatch ^/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$          /opt/git/$1
  AliasMatch ^/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /opt/git/$1

  PerlLoadModule Apache::Redmine

  ScriptAliasMatch \
    "(?x)^/(.*/(HEAD | \
    info/refs | \
    objects/(info/[^/]+ | \
        [0-9a-f]{2}/[0-9a-f]{38} | \
        pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
    git-(upload|receive)-pack))$" \
    /usr/lib/git-core/git-http-backend/$1

  <Directory /usr/libexec/git-core/>
    Options +ExecCGI
    Allow From All
  </Directory>

  <Location "/">
    AuthType Basic
    AuthName "Git Repositories" 
    Require valid-user

    PerlAccessHandler Apache::Authn::Redmine::access_handler
    PerlAuthenHandler Apache::Authn::Redmine::authen_handler

    RedmineDSN "DBI:mysql:database=redmine;host=localhost" 

    RedmineDbUser "redmine" 
    RedmineDbPass "redmine password" 
    RedmineGitSmartHttp yes
  </Location>
</VirtualHost>

Replies (2)

RE: cgit + redmine + git (advance integration) - Added by Martin Denizet (redmine.org team member) over 9 years ago

Hi Amree,
Your 2 configs use the same port/ServerName, it cannot work.
I'm not sure if you can use the Redmine.pm authentication to authenticate any Apache location but it worth trying. Here is what I'm thinking about:

<VirtualHost *:80>                                       
-    ServerName git.domain
+    ServerName cgit.domain
    DocumentRoot "/var/www/htdocs/cgit/" 
    DirectoryIndex cgit.cgi
    SetEnv  CGIT_CONFIG   /etc/cgitrc

    <Directory "/var/www/htdocs/cgit">
        Options FollowSymlinks ExecCGI
        Allow from all
        AllowOverride all
        Order allow,deny

        <Files cgit.cgi>
            SetHandler cgi-script
        </Files>

        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^.* /cgit.cgi/$0 [L,PT]
    </Directory>

    <Directory "/opt/git">
        Allow from all
    </Directory>

+    <Location "/">
+        AuthType Basic
+        AuthName "Cgit" 
+        Require valid-user
+    
+        PerlAccessHandler Apache::Authn::Redmine::access_handler
+        PerlAuthenHandler Apache::Authn::Redmine::authen_handler
+    
+        RedmineDSN "DBI:mysql:database=redmine;host=localhost" 
+    
+        RedmineDbUser "redmine" 
+        RedmineDbPass "redmine password" 
+    </Location>
</VirtualHost>


You could also try to have it in the same VirtualHost as Git to share the authentication.
Hope it helps!

RE: cgit + redmine + git (advance integration) - Added by amree woot over 9 years ago

Thanks for the reply. I'll try it out

    (1-2/2)