Commit 9eb01904 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #1016 from SaitoWu/feature/https

Feature/https
parents 3a4aff69 1df1daa1
...@@ -15,6 +15,7 @@ gem "gitolite", :git => "https://github.com/gitlabhq/gitolite-client.git", ...@@ -15,6 +15,7 @@ gem "gitolite", :git => "https://github.com/gitlabhq/gitolite-client.git",
gem "pygments.rb", :git => "https://github.com/gitlabhq/pygments.rb.git", :ref => "2cada028da5054616634a1d9ca6941b65b3ce188" gem "pygments.rb", :git => "https://github.com/gitlabhq/pygments.rb.git", :ref => "2cada028da5054616634a1d9ca6941b65b3ce188"
gem "omniauth-ldap", :git => "https://github.com/gitlabhq/omniauth-ldap.git", :ref => "7edf27d0281e09561838122982c16b7e62181f44" gem "omniauth-ldap", :git => "https://github.com/gitlabhq/omniauth-ldap.git", :ref => "7edf27d0281e09561838122982c16b7e62181f44"
gem 'yaml_db', :git => "https://github.com/gitlabhq/yaml_db.git" gem 'yaml_db', :git => "https://github.com/gitlabhq/yaml_db.git"
gem 'grack', :git => "https://github.com/gitlabhq/grack.git"
gem "linguist", "~> 1.0.0", :git => "https://github.com/gitlabhq/linguist.git" gem "linguist", "~> 1.0.0", :git => "https://github.com/gitlabhq/linguist.git"
gem "stamp" gem "stamp"
......
...@@ -13,6 +13,13 @@ GIT ...@@ -13,6 +13,13 @@ GIT
grit (>= 2.4.1) grit (>= 2.4.1)
hashery (~> 1.4.0) hashery (~> 1.4.0)
GIT
remote: https://github.com/gitlabhq/grack.git
revision: ba46f3b0845c6a09d488ae6abdce6ede37e227e8
specs:
grack (1.0.0)
rack (~> 1.4.1)
GIT GIT
remote: https://github.com/gitlabhq/grit.git remote: https://github.com/gitlabhq/grit.git
revision: 7f35cb98ff17d534a07e3ce6ec3d580f67402837 revision: 7f35cb98ff17d534a07e3ce6ec3d580f67402837
...@@ -373,6 +380,7 @@ DEPENDENCIES ...@@ -373,6 +380,7 @@ DEPENDENCIES
foreman foreman
git git
gitolite! gitolite!
grack!
grit! grit!
haml-rails haml-rails
httparty httparty
......
...@@ -17,11 +17,15 @@ git_host: ...@@ -17,11 +17,15 @@ git_host:
base_path: /home/git/repositories/ base_path: /home/git/repositories/
host: localhost host: localhost
git_user: git git_user: git
upload_pack: true
receive_pack: true
# port: 22 # port: 22
# Git settings # Git settings
# Use default values unless you understand it # Use default values unless you understand it
git: git:
path: /usr/bin/git
# Max size of git object like commit, in bytes # Max size of git object like commit, in bytes
# This value can be increased if you have a very large commits # This value can be increased if you have a very large commits
git_max_size: 5242880 # 5.megabytes git_max_size: 5242880 # 5.megabytes
......
module Grack
class Auth < Rack::Auth::Basic
def valid?
# Authentication with username and password
email, password = @auth.credentials
user = User.find_by_email(email)
return false unless user.valid_password?(password)
# Find project by PATH_INFO from env
if m = /^\/([\w-]+).git/.match(@env['PATH_INFO']).to_a
return false unless project = Project.find_by_path(m.last)
end
# Git upload and receive
if @env['REQUEST_METHOD'] == 'GET'
true
elsif @env['REQUEST_METHOD'] == 'POST'
if @env['REQUEST_URI'].end_with?('git-upload-pack')
return project.dev_access_for?(user)
elsif @env['REQUEST_URI'].end_with?('git-receive-pack')
if project.protected_branches.map(&:name).include?(current_ref)
project.master_access_for?(user)
else
project.dev_access_for?(user)
end
else
false
end
else
false
end
end# valid?
def current_ref
if @env["HTTP_CONTENT_ENCODING"] =~ /gzip/
input = Zlib::GzipReader.new(@request.body).string
else
input = @request.body.string
end
oldrev, newrev, ref = input.split(' ')
/refs\/heads\/([\w-]+)/.match(ref).to_a.last
end
end# Auth
end# Grack
...@@ -8,6 +8,14 @@ Gitlab::Application.routes.draw do ...@@ -8,6 +8,14 @@ Gitlab::Application.routes.draw do
require 'resque/server' require 'resque/server'
mount Resque::Server.new, at: '/info/resque' mount Resque::Server.new, at: '/info/resque'
# Enable Grack support
mount Grack::Bundle.new({
git_path: GIT_OPTS['path'],
project_root: GIT_HOST['base_path'],
upload_pack: GIT_HOST['upload_pack'],
receive_pack: GIT_HOST['receive_pack']
}), at: '/git'
# #
# Help # Help
# #
...@@ -20,15 +28,15 @@ Gitlab::Application.routes.draw do ...@@ -20,15 +28,15 @@ Gitlab::Application.routes.draw do
# Admin Area # Admin Area
# #
namespace :admin do namespace :admin do
resources :users do resources :users do
member do member do
put :team_update put :team_update
put :block put :block
put :unblock put :unblock
end end
end end
resources :projects, :constraints => { :id => /[^\/]+/ } do resources :projects, :constraints => { :id => /[^\/]+/ } do
member do member do
get :team get :team
put :team_update put :team_update
end end
...@@ -79,12 +87,12 @@ Gitlab::Application.routes.draw do ...@@ -79,12 +87,12 @@ Gitlab::Application.routes.draw do
resources :wikis, :only => [:show, :edit, :destroy, :create] do resources :wikis, :only => [:show, :edit, :destroy, :create] do
member do member do
get "history" get "history"
end end
end end
resource :repository do resource :repository do
member do member do
get "branches" get "branches"
get "tags" get "tags"
get "archive" get "archive"
...@@ -94,14 +102,14 @@ Gitlab::Application.routes.draw do ...@@ -94,14 +102,14 @@ Gitlab::Application.routes.draw do
resources :deploy_keys resources :deploy_keys
resources :protected_branches, :only => [:index, :create, :destroy] resources :protected_branches, :only => [:index, :create, :destroy]
resources :refs, :only => [], :path => "/" do resources :refs, :only => [], :path => "/" do
collection do collection do
get "switch" get "switch"
end end
member do member do
get "tree", :constraints => { :id => /[a-zA-Z.\/0-9_\-]+/ } get "tree", :constraints => { :id => /[a-zA-Z.\/0-9_\-]+/ }
get "blob", get "blob",
:constraints => { :constraints => {
:id => /[a-zA-Z.0-9\/_\-]+/, :id => /[a-zA-Z.0-9\/_\-]+/,
:path => /.*/ :path => /.*/
...@@ -126,36 +134,36 @@ Gitlab::Application.routes.draw do ...@@ -126,36 +134,36 @@ Gitlab::Application.routes.draw do
end end
end end
resources :merge_requests do resources :merge_requests do
member do member do
get :diffs get :diffs
get :automerge get :automerge
get :automerge_check get :automerge_check
end end
collection do collection do
get :branch_from get :branch_from
get :branch_to get :branch_to
end end
end end
resources :snippets do resources :snippets do
member do member do
get "raw" get "raw"
end end
end end
resources :hooks, :only => [:index, :create, :destroy] do resources :hooks, :only => [:index, :create, :destroy] do
member do member do
get :test get :test
end end
end end
resources :commits do resources :commits do
collection do collection do
get :compare get :compare
end end
member do member do
get :patch get :patch
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment