brownbeagle-gitauth 0.0.4.3 → 0.0.4.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,16 @@ Getting started is relatively simple. First of, you'll need to log onto the remo
15
15
 
16
16
  sudo gem install brownbeagle-gitauth --source http://gems.github.com/
17
17
 
18
+ Or, if you want to avoid the gems approach, you can use simply clone the repository
19
+ as follows and use the git submodule setup in order to vendor rack, sinatra and perennial:
20
+
21
+ git clone git://github.com/brownbeagle/gitauth.git
22
+ cd gitauth
23
+ git submodule init
24
+ git submodule update
25
+
26
+ With the gitauth binary being in the bin folder.
27
+
18
28
  Once that's done, the +gitauth+ and +gitauth-shell+ commands should be in your path.
19
29
  Next, you'll want to (in most cases anyway) use a specific +git+ user to host repositories.
20
30
 
@@ -23,25 +33,25 @@ Using the example of ubuntu, we'll add a git user under which all actions will n
23
33
  sudo adduser --disabled-password --shell /bin/bash --group --home /home/git --system --gecos 'gitauth user for version control' git
24
34
 
25
35
  Now, whenever you run the +gitauth+ executable, you'll do so as the user you just created
26
- above. For simplicity purposes, I added the the following to my zsh profile so I always
27
- had it available. If you don't wish to, just use as you would without the alias:
36
+ above. For example purposes, I suggest using the following in order to run all commands
37
+ as the 'git' user:
28
38
 
29
- alias asgit='sudo -H -u git'
39
+ sudo -H -u git -i
30
40
 
31
41
  And finally, to create a settings file and initialize .ssh and authorized_keys, perform the
32
42
  following:
33
43
 
34
- asgit gitauth install
44
+ gitauth install
35
45
 
36
46
  Note that when it asks you for the gitauth shell path, the default will lock
37
47
  it to the current gitauth version SO if you want it to stay up to date between gem versions
38
48
  point it to the path for always-current executable (e.g. on Ubuntu 9.04 w/ apt-get ruby + gems,
39
49
  +/var/lib/gems/1.8/bin/gitauth-shell+)
40
50
 
41
- Also, Note that if you append a path to a public key to the end of the install command,
51
+ Also, Note that if use the --admin option with path to a public key to the end of the install command,
42
52
  it will initialize a new +admin+ user who can also login via SSH. e.g.
43
53
 
44
- asgit gitauth install id_rsa.pub
54
+ gitauth install --admin id_rsa.pub
45
55
 
46
56
  Would initialize an admin user with the given public key.
47
57
 
@@ -52,17 +62,23 @@ git (via the admin user and ssh) or by being prefixed with asgit or "sudo -H -u
52
62
 
53
63
  To start the web interface, just run:
54
64
 
55
- gitauth webapp
65
+ gitauth web-app
56
66
 
57
67
  The first time you boot the web app, you will be prompted
58
68
  to enter a username and a password. Please do so
59
69
  and then surf to http://your-server-ip:8998/
60
70
 
71
+ For people running passenger, you can simply point it at
72
+ the public subdirectory and it will act as any normal passenger
73
+ web app. It's worth noting that in this approach you need
74
+ to run gitauth web-app at least once to setup a username and
75
+ password.
76
+
61
77
  === Adding Users
62
78
 
63
79
  Whenever you want to add a user, it's as simple as:
64
80
 
65
- gitauth adduser user-name path-to-public-key
81
+ gitauth add-user user-name path-to-public-key
66
82
 
67
83
  Note that if the --admin option is specified, the user will
68
84
  be able to log in to the shell via SSH and will also be able
@@ -72,14 +88,22 @@ to access any repository.
72
88
 
73
89
  Adding a repository is a two step process. First, you create it:
74
90
 
75
- gitauth addrepo repo-name
91
+ gitauth add-repo repo-name
92
+
93
+ If you wish to initialize the repository with a blank commit (so
94
+ git clone works straight away), simply pass --make-empty / -m as
95
+ an option. e.g.:
96
+
97
+ gitauth add-repo repo-name --make-empty
76
98
 
77
99
  Then, for every user who needs access, you do:
78
100
 
79
- gitauth permissions repo-name user-name permission-type
101
+ gitauth permissions repo-name user-name --type=permission-type
80
102
 
81
103
  Where permission type is read, write or all. If permission
82
- type isn't specified, it will default to all.
104
+ type isn't specified, it will default to all. If you wish
105
+ to remove a user from a repository, you can simply pass
106
+ use the type as none.
83
107
 
84
108
  === Accessing repos:
85
109
 
@@ -95,7 +119,8 @@ Or
95
119
  Either form working just as well.
96
120
 
97
121
  Note that for the first time you push, you will need
98
- to use the full form:
122
+ to use the full form (as below) unless you've used
123
+ the --make-empty / -m option when you created the repo.
99
124
 
100
125
  git push origin master
101
126
 
@@ -113,3 +138,4 @@ on your local PC (due to the way git handles remote repositories):
113
138
  git commit -m "Added blank readme"
114
139
  git add remote origin git@your-server:my-repo.git
115
140
  git push origin master
141
+
data/USAGE CHANGED
@@ -1,27 +1,70 @@
1
- GitAuth is an SSH and Ruby based authenticated Git server.
1
+ GitAuth is a tool to provide authenticated git hosting from any unix like
2
+ box using ruby, git-shell and a whole lot of awesomeness.
2
3
 
3
- gitauth install ADMIN_PUBLIC_KEY
4
- Pass in a valid SSH public key that will be used by the GitAuth administrator
4
+ Available commands include:
5
5
 
6
- gitauth permissions REPO USERORGROUP [PERMISSION=all,read,write]
7
- REPO: the repository name you wish to set permissions on
8
- USER/GROUP: the user or group name you with to give permissions
9
- PERMISSION:
10
- Default = all
11
- The level of permissions you want to give the user or group on the repository in question
12
- all = read and write
13
- read = the user can see the repository and pull it, but cannot push changes
14
- write = user can push changes but can't pull it.
15
-
16
- gitauth addrepo NAME PATH
17
- NAME: the name you want your repository to have
18
- PATH: the part path you want the repository to have, will be ~REPOBASE~/PATH
6
+ ls-users - Lists all users handled by GitAuth
19
7
 
20
- gitauth adduser [--admin] NAME PUBLIC_KEY
21
- NAME: the name of your new user
22
- PUBLIC_KEY: a valid path to a copy of the users SSH public key file
8
+ ls-groups - Lists all groups handled by GitAuth
23
9
 
24
- --admin: pass this flag if you want your user to be able to administer the gitauth install
10
+ ls-repos - Lists all repositories handled by GitAuth
25
11
 
26
- gitauth addgroup NAME
27
- NAME: the name of your new group
12
+ show-user - Shows information about a user with a given name
13
+ e.g: gitauth show-user darcy
14
+
15
+ show-group - Shows information about a group with a given name
16
+ e.g: gitauth show-group brownbeagle
17
+ or,: gitauth show-group @brownbeagle
18
+
19
+ show-repo - Shows information about a repository with a given name
20
+ e.g: gitauth show-repo project-a
21
+
22
+ add-user - adds a user with a specific name and ssh key
23
+ e.g. gitauth add-user darcy ~/id_rsa-one.pub
24
+ or,: gitauth add-user sutto ~/id_rsa-two.pub --admin
25
+
26
+ Would create two users, one an admin and one a normal user.
27
+
28
+ add-group - Adds a group with a specified name.
29
+ e.g: gitauth add-group brownbeagle
30
+ or,: gitauth add-group brownbeagle
31
+
32
+ From there on in, you can refer to the group as @brownbeagle
33
+
34
+ add-repo - Adds a repository with a specific name and an optional path
35
+ e.g: gitauth add-repo project-a
36
+ or,: gitauth add-repo project-b --make-empty
37
+ or,: gitauth add-repo project-c my-path-to-repo.git
38
+ or,: gitauth add-repo project-d my-path-to-other-repo --make-empty
39
+
40
+ --make-empty initializes it with a blank commit whilst
41
+ a second argument sets the path for the created repository.
42
+ The path is only ever used internally, the user refers to
43
+ it externally. e.g, project-c above would be accessible by:
44
+ user@your-server.com:project-c or user@your-server.com:project-c.git
45
+
46
+ rm-user - Removes a user with the given name
47
+ e.g: gitauth rm-user darcy
48
+
49
+ rm-group - Removes a specific group from GitAuth
50
+ e.g: gitauth rm-group brownbeagle
51
+ or,: gitauth rm-group @brownbeagle
52
+
53
+ rm-repo - Removes a repository from gitauth (destroys it on the filesystem as well)
54
+ e.g: gitauth rm-repo project-a
55
+
56
+ permissions - Set the permissions for a given user or group on a specific repository.
57
+ e.g: gitauth permissions project-a darcy
58
+ or,: gitauth permissions project-b darcy --type read
59
+ or,: gitauth permissions project-c darcy --type none
60
+ or,: gitauth permissions project-a @brownbeagle -t read
61
+ or,: gitauth permissions project-b @brownbeagle
62
+
63
+ The first argument being the repository name, the second a target -
64
+ either a user (e.g. darcy), or, if prefixed with an @-symbol, a group.
65
+ An optional --type argument specifies what permissions to use (all, read, write
66
+ or none - defaulting to all).
67
+
68
+ web-app - Starts up the web app, serving on port 8998
69
+ e.g: gitauth web-app
70
+
@@ -198,9 +198,13 @@ GitAuth::Application.processing(ARGV) do |a|
198
198
  end
199
199
 
200
200
  a.add("usage", "Prints out the sample usage instructions") do |options|
201
- File.open(GitAuth::BASE_DIR.join("USAGE")) do |f|
202
- f.each_line { |line| puts line }
201
+ pager = nil
202
+ if ENV.has_key?('PAGER')
203
+ pager = ENV['PAGER'].blank? ? 'cat' : ENV['PAGER']
204
+ else
205
+ pager = "less"
203
206
  end
207
+ exec "#{pager} '#{GitAuth::BASE_DIR.join("USAGE")}'"
204
208
  end
205
209
 
206
210
  a.add("show-repo NAME", "Shows information for a repository with a given name") do |name, options|
@@ -21,7 +21,7 @@ require 'ostruct'
21
21
 
22
22
  module GitAuth
23
23
 
24
- VERSION = [0, 0, 4, 3]
24
+ VERSION = [0, 0, 4, 5]
25
25
  BASE_DIR = Pathname.new(__FILE__).dirname.join("..").expand_path
26
26
  LIB_DIR = BASE_DIR.join("lib", "gitauth")
27
27
  GITAUTH_DIR = Pathname.new("~/.gitauth/").expand_path
@@ -43,8 +43,6 @@ module GitAuth
43
43
  include Perennial
44
44
  include Loggable
45
45
 
46
- require LIB_DIR.join("settings")
47
-
48
46
  %w(message saveable_class repo user command client group).each do |file|
49
47
  require LIB_DIR.join(file)
50
48
  end
@@ -55,6 +53,7 @@ module GitAuth
55
53
  manifest do |m, l|
56
54
  Settings.root = File.dirname(__FILE__)
57
55
  Settings.default_settings_path = GITAUTH_DIR.join("settings.yml")
56
+ Settings.lookup_key_path = []
58
57
  Logger.default_logger_path = GITAUTH_DIR.join("gitauth.log")
59
58
  l.before_run { GitAuth.each_model(:load!) }
60
59
  l.register_controller :web_app, 'GitAuth::WebApp'
@@ -63,7 +62,7 @@ module GitAuth
63
62
  class << self
64
63
 
65
64
  def prepare
66
- Settings.setup
65
+ GitAuth::Settings.setup!
67
66
  reload_models!
68
67
  end
69
68
 
@@ -17,47 +17,36 @@
17
17
  #++
18
18
 
19
19
  module GitAuth
20
- def self.SaveableClass(kind)
21
- klass = Class.new
22
- path_name = "#{kind.to_s.upcase}_PATH"
23
- yaml_file_name = "#{kind}.yml"
24
-
25
- saveable_class_def = <<-END
20
+
21
+ class BasicSaveable
26
22
 
27
- #{path_name} = GitAuth::GITAUTH_DIR.join(#{yaml_file_name.inspect})
28
-
29
- class << self
23
+ class_inheritable_accessor :all, :store_path
30
24
 
31
- def all
32
- @@all_#{kind} ||= nil
33
- end
25
+ class << self
34
26
 
35
- def all=(value)
36
- @@all_#{kind} = value
37
- end
27
+ def load!
28
+ self.all = YAML.load(File.read(store_path)) rescue nil if File.file?(store_path)
29
+ self.all = [] unless all.is_a?(Array)
30
+ end
38
31
 
39
- def load!
40
- self.all = YAML.load_file(#{path_name}) rescue nil if File.exist?(#{path_name})
41
- self.all = [] unless self.all.is_a?(Array)
42
- end
43
-
44
- def save!
45
- load! if self.all.nil?
46
- File.open(#{path_name}, "w+") do |f|
47
- f.write self.all.to_yaml
48
- end
49
- end
32
+ def save!
33
+ load! if all.nil?
34
+ File.open(store_path, "w+") { |f| f.write all.to_yaml }
35
+ end
50
36
 
51
- def add_item(item)
52
- self.load! if self.all.nil?
53
- self.all << item
54
- self.save!
55
- end
56
-
37
+ def add_item(item)
38
+ load! if all.nil?
39
+ all << item
40
+ save!
57
41
  end
58
-
59
- END
60
- klass.class_eval(saveable_class_def)
42
+
43
+ end
44
+ end
45
+
46
+ def self.SaveableClass(kind)
47
+ klass = Class.new(BasicSaveable)
48
+ klass.store_path = GitAuth::GITAUTH_DIR.join("#{kind}.yml").to_s
49
+ klass.all = nil
61
50
  return klass
62
51
  end
63
52
  end
@@ -52,6 +52,7 @@ module GitAuth
52
52
  end
53
53
 
54
54
  def self.check_auth
55
+ GitAuth.prepare
55
56
  if !has_auth?
56
57
  if $stderr.tty?
57
58
  logger.verbose = true
@@ -82,6 +83,7 @@ module GitAuth
82
83
  if current_server.present?
83
84
  current_server.respond_to?(:stop!) ? current_server.stop! : current_server.stop
84
85
  end
86
+ exit!
85
87
  logger.debug "Stopped Server."
86
88
  end
87
89
 
@@ -181,8 +183,10 @@ module GitAuth
181
183
  path = params[:repo][:path]
182
184
  path = name if path.to_s.strip.empty?
183
185
  if repo = GitAuth::Repo.create(name, path)
186
+ make_empty = (params[:repo][:make_empty] == "1")
187
+ repo.make_empty! if make_empty
184
188
  if repo.execute_post_create_hook!
185
- redirect "/?repo_name=#{URI.encode(name)}"
189
+ redirect "/?repo_name=#{URI.encode(name)}&made_empty=#{make_empty ? "yes" : "no"}"
186
190
  else
187
191
  redirect root_with_message("Repository added but the post-create hook exited unsuccessfully.")
188
192
  end
@@ -181,6 +181,7 @@ div.message {
181
181
  .section ul {
182
182
  line-height: 1.8em;
183
183
  margin: 0.5em 1em;
184
+ font-family: Helvetica, Arial, Sans-Serif;
184
185
  }
185
186
 
186
187
  .section ul li {
@@ -193,12 +194,15 @@ div.message {
193
194
  width: 4em;
194
195
  color: white;
195
196
  background: #666;
196
- font-size: 0.8em;
197
+ font-size: 0.65em;
197
198
  text-transform: uppercase;
198
199
  font-weight: bold;
199
200
  text-align: center;
200
- padding: 0 0.75em;
201
+ padding: 0 0.5em;
201
202
  margin-right: 0.5em;
203
+ -moz-border-radius: 0.6em;
204
+ -webkit-border-radius: 0.6em;
205
+ font-family: Helvetica, Arial, Sans-Serif;
202
206
  }
203
207
 
204
208
  #users .tag.admin {
@@ -6,17 +6,19 @@
6
6
  </p>
7
7
  <code> cd your-repo
8
8
  git remote add origin <%= repo_url %>
9
- git push origin master</code>
9
+ git push origin master<%= " --force" if params[:made_empty] == "yes" %></code>
10
10
  <p>
11
11
  Otherwise, to initialize an empty repository:
12
12
  </p>
13
- <code> mkdir your-repo
13
+ <% if params[:made_empty] == "yes" %>
14
+ <code>git clone <%= repo_url %></code>
15
+ <% else %><code> mkdir your-repo
14
16
  cd your-repo
15
17
  git init
16
18
  touch .gitignore
17
19
  git add .gitignore
18
20
  git commit -m "Added blank .gitignore to initialize repository"
19
21
  git remote add origin <%= repo_url %>
20
- git push origin master</code>
22
+ git push origin master</code><% end %>
21
23
  <p>And you should be good to go! <a href="#" onclick="$('#repository-details').slideUp(); return false;">(close instructions)</a></p>
22
24
  </div>
@@ -13,6 +13,10 @@
13
13
  <label for="repo_path">Path: (optional)</label>
14
14
  <input type="text" name="repo[path]" id="repo_path" />
15
15
  </div>
16
+ <div class="row">
17
+ <label for="repo_make_empty">Initial Commit?</label>
18
+ <input type="checkbox" name="repo[make_empty]" id="repo_make_empty" value="1" />
19
+ </div>
16
20
  <div class="buttons">
17
21
  <input type="submit" value="Add Repository" /> or <a href="#" onclick="hideForm('repo'); return false;">Cancel</a>
18
22
  </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brownbeagle-gitauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.3
4
+ version: 0.0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darcy Laycock
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-06 00:00:00 -07:00
12
+ date: 2009-09-07 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 0.2.3
43
+ version: 0.2.3.1
44
44
  version:
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: thoughtbot-shoulda
@@ -107,7 +107,6 @@ files:
107
107
  - lib/gitauth/message.rb
108
108
  - lib/gitauth/repo.rb
109
109
  - lib/gitauth/saveable_class.rb
110
- - lib/gitauth/settings.rb
111
110
  - lib/gitauth/user.rb
112
111
  - lib/gitauth/web_app.rb
113
112
  - public/gitauth.css
@@ -1,49 +0,0 @@
1
- #--
2
- # Copyright (C) 2009 Brown Beagle Software
3
- # Copyright (C) 2009 Darcy Laycock <sutto@sutto.net>
4
- #
5
- # This program is free software: you can redistribute it and/or modify
6
- # it under the terms of the GNU Affero General Public License as published by
7
- # the Free Software Foundation, either version 3 of the License, or
8
- # (at your option) any later version.
9
- #
10
- # This program is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- # GNU Affero General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU Affero General Public License
16
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
- #++
18
-
19
-
20
- module GitAuth
21
- class Settings < Perennial::Settings
22
-
23
- def self.setup!(options = {})
24
- @@configuration = {}
25
- settings_file = self.default_settings_path
26
- if File.exist?(settings_file)
27
- loaded_yaml = YAML.load(File.read(settings_file))
28
- # We don't use the default namespace etc.
29
- @@configuration.merge!(loaded_yaml || {})
30
- end
31
- @@configuration.merge! options
32
- @@configuration.symbolize_keys!
33
- # Generate a module
34
- mod = generate_settings_accessor_mixin
35
- extend mod
36
- include mod
37
- @@setup = true
38
- end
39
-
40
- def self.update!(hash)
41
- settings_file = self.default_settings_path
42
- settings = File.file?(settings_file) ? YAML.load(File.read(settings_file)) : {}
43
- hash.each_pair { |k,v| settings[k.to_s] = v }
44
- File.open(settings_file, "w+") { |f| f.write(settings.to_yaml) }
45
- setup!
46
- end
47
-
48
- end
49
- end