gritano 0.9.4 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/TODO +3 -4
- data/VERSION +1 -1
- data/db/migrate/007_add_password_to_users.rb +10 -0
- data/features/data/local_help.txt +1 -0
- data/features/data/remote_commands/admin_help_igorbonadio.txt +1 -0
- data/features/data/remote_commands/admin_help_jessicaeto.txt +1 -0
- data/gritano.gemspec +6 -2
- data/lib/gritano/cli.rb +21 -0
- data/lib/gritano/console/executor.rb +30 -0
- data/lib/gritano/models/user.rb +13 -0
- data/spec/model_user_spec.rb +10 -0
- metadata +20 -3
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -13,6 +13,7 @@ GEM
|
|
13
13
|
i18n (~> 0.6)
|
14
14
|
multi_json (~> 1.0)
|
15
15
|
arel (3.0.2)
|
16
|
+
bcrypt-ruby (3.0.1)
|
16
17
|
builder (3.0.4)
|
17
18
|
cucumber (1.2.1)
|
18
19
|
builder (>= 2.1.2)
|
@@ -63,6 +64,7 @@ PLATFORMS
|
|
63
64
|
|
64
65
|
DEPENDENCIES
|
65
66
|
activerecord (>= 3.2.8)
|
67
|
+
bcrypt-ruby
|
66
68
|
bundler (>= 1.0)
|
67
69
|
cucumber (>= 1.2.1)
|
68
70
|
database_cleaner (>= 0.8.0)
|
data/TODO
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.10.0
|
@@ -14,6 +14,7 @@
|
|
14
14
|
gritano user:key:list username
|
15
15
|
gritano user:repo:list username
|
16
16
|
gritano user:add username [email admin]*
|
17
|
+
gritano user:password:set username
|
17
18
|
gritano user:rm username
|
18
19
|
gritano user:email:update username email@server.com
|
19
20
|
gritano user:email:get username
|
@@ -14,6 +14,7 @@
|
|
14
14
|
ssh git@host.com admin:user:key:list username
|
15
15
|
ssh git@host.com admin:user:repo:list username
|
16
16
|
ssh git@host.com admin:user:add username [email admin]*
|
17
|
+
ssh git@host.com admin:user:password:set username
|
17
18
|
ssh git@host.com admin:user:rm username
|
18
19
|
ssh git@host.com admin:user:email:update username email@server.com
|
19
20
|
ssh git@host.com admin:user:email:get username
|
@@ -14,6 +14,7 @@
|
|
14
14
|
ssh git@host.com admin:user:key:list username
|
15
15
|
ssh git@host.com admin:user:repo:list username
|
16
16
|
ssh git@host.com admin:user:add username [email admin]*
|
17
|
+
ssh git@host.com admin:user:password:set username
|
17
18
|
ssh git@host.com admin:user:rm username
|
18
19
|
ssh git@host.com admin:user:email:update username email@server.com
|
19
20
|
ssh git@host.com admin:user:email:get username
|
data/gritano.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "gritano"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.10.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Igor Bonadio"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-05-02"
|
13
13
|
s.description = "Gritano is the simplest way to configure your git server over ssh. You can create repositories and manage user access."
|
14
14
|
s.email = "igorbonadio@gmail.com"
|
15
15
|
s.executables = ["gritano", "gritano-pub-key", "gritano-remote"]
|
@@ -40,6 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
"db/migrate/004_create_keys.rb",
|
41
41
|
"db/migrate/005_add_admin_to_users.rb",
|
42
42
|
"db/migrate/006_add_email_to_users.rb",
|
43
|
+
"db/migrate/007_add_password_to_users.rb",
|
43
44
|
"features/data/config_true.yml",
|
44
45
|
"features/data/local_commands/addon_list.txt",
|
45
46
|
"features/data/local_commands/addon_ssh_install.txt",
|
@@ -282,6 +283,7 @@ Gem::Specification.new do |s|
|
|
282
283
|
s.add_runtime_dependency(%q<grit>, [">= 2.5.0"])
|
283
284
|
s.add_runtime_dependency(%q<terminal-table>, [">= 1.4.5"])
|
284
285
|
s.add_runtime_dependency(%q<sshd_config>, [">= 0"])
|
286
|
+
s.add_runtime_dependency(%q<bcrypt-ruby>, [">= 0"])
|
285
287
|
s.add_development_dependency(%q<rspec>, [">= 2.11.0"])
|
286
288
|
s.add_development_dependency(%q<rdoc>, [">= 3.12"])
|
287
289
|
s.add_development_dependency(%q<cucumber>, [">= 1.2.1"])
|
@@ -295,6 +297,7 @@ Gem::Specification.new do |s|
|
|
295
297
|
s.add_dependency(%q<grit>, [">= 2.5.0"])
|
296
298
|
s.add_dependency(%q<terminal-table>, [">= 1.4.5"])
|
297
299
|
s.add_dependency(%q<sshd_config>, [">= 0"])
|
300
|
+
s.add_dependency(%q<bcrypt-ruby>, [">= 0"])
|
298
301
|
s.add_dependency(%q<rspec>, [">= 2.11.0"])
|
299
302
|
s.add_dependency(%q<rdoc>, [">= 3.12"])
|
300
303
|
s.add_dependency(%q<cucumber>, [">= 1.2.1"])
|
@@ -309,6 +312,7 @@ Gem::Specification.new do |s|
|
|
309
312
|
s.add_dependency(%q<grit>, [">= 2.5.0"])
|
310
313
|
s.add_dependency(%q<terminal-table>, [">= 1.4.5"])
|
311
314
|
s.add_dependency(%q<sshd_config>, [">= 0"])
|
315
|
+
s.add_dependency(%q<bcrypt-ruby>, [">= 0"])
|
312
316
|
s.add_dependency(%q<rspec>, [">= 2.11.0"])
|
313
317
|
s.add_dependency(%q<rdoc>, [">= 3.12"])
|
314
318
|
s.add_dependency(%q<cucumber>, [">= 1.2.1"])
|
data/lib/gritano/cli.rb
CHANGED
@@ -33,5 +33,26 @@ module Gritano
|
|
33
33
|
return "invalid"
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
def CLI.check_password(login, password, home_dir = Etc.getpwuid.dir, repo_dir = Etc.getpwuid.dir)
|
38
|
+
ActiveRecord::Base.establish_connection(YAML::load(File.open(File.join(home_dir, '.gritano', 'database.yml'))))
|
39
|
+
user = User.find_by_login(login)
|
40
|
+
if user
|
41
|
+
return user.password == password
|
42
|
+
end
|
43
|
+
return false
|
44
|
+
end
|
45
|
+
|
46
|
+
def CLI.check_access(login, repo, access, home_dir = Etc.getpwuid.dir, repo_dir = Etc.getpwuid.dir)
|
47
|
+
ActiveRecord::Base.establish_connection(YAML::load(File.open(File.join(home_dir, '.gritano', 'database.yml'))))
|
48
|
+
user = User.find_by_login(login)
|
49
|
+
if user
|
50
|
+
repo = Gritano::Repository.find_by_name(repo)
|
51
|
+
if repo
|
52
|
+
return user.check_access(repo, access)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
return false
|
56
|
+
end
|
36
57
|
end
|
37
58
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "terminal-table"
|
2
|
+
require 'io/console'
|
2
3
|
|
3
4
|
module Gritano
|
4
5
|
module Console
|
@@ -84,6 +85,35 @@ module Gritano
|
|
84
85
|
return [false, "#{user.errors.full_messages.join(", ")}."]
|
85
86
|
end
|
86
87
|
|
88
|
+
add_command "user:password:set", "username" do |argv|
|
89
|
+
login, = argv
|
90
|
+
user = User.find_by_login(login)
|
91
|
+
if user.crypted_password == nil
|
92
|
+
puts "You have not set your password yet."
|
93
|
+
print "Please, set one now: "
|
94
|
+
user.password = @stdin.noecho(&:gets).gsub("\n", "")
|
95
|
+
puts
|
96
|
+
if user.save
|
97
|
+
return [true, "Done!"]
|
98
|
+
end
|
99
|
+
else
|
100
|
+
print "Before you start, enter you current password: "
|
101
|
+
if user.password == @stdin.noecho(&:gets).gsub("\n", "")
|
102
|
+
puts
|
103
|
+
print "Now, enter you new password: "
|
104
|
+
user.password = @stdin.noecho(&:gets).gsub("\n", "")
|
105
|
+
puts
|
106
|
+
if user.save
|
107
|
+
return [true, "Done!"]
|
108
|
+
end
|
109
|
+
else
|
110
|
+
puts
|
111
|
+
return [false, "Password you entered do not match."]
|
112
|
+
end
|
113
|
+
end
|
114
|
+
return [false, "Password could not be changed."]
|
115
|
+
end
|
116
|
+
|
87
117
|
add_command "user:rm", "username" do |argv|
|
88
118
|
login, = argv
|
89
119
|
user = User.find_by_login(login)
|
data/lib/gritano/models/user.rb
CHANGED
@@ -1,11 +1,24 @@
|
|
1
|
+
require 'bcrypt'
|
2
|
+
|
1
3
|
module Gritano
|
2
4
|
class User < ActiveRecord::Base
|
5
|
+
include BCrypt
|
6
|
+
|
3
7
|
validates :login, presence: true
|
4
8
|
validates_uniqueness_of :login
|
5
9
|
|
6
10
|
has_many :permissions
|
7
11
|
has_many :repositories, through: :permissions
|
8
12
|
has_many :keys
|
13
|
+
|
14
|
+
def password
|
15
|
+
@password ||= Password.new(crypted_password)
|
16
|
+
end
|
17
|
+
|
18
|
+
def password=(new_password)
|
19
|
+
@password = Password.create(new_password)
|
20
|
+
self.crypted_password = @password
|
21
|
+
end
|
9
22
|
|
10
23
|
def add_access(repo, access)
|
11
24
|
change_access(repo, "add", access)
|
data/spec/model_user_spec.rb
CHANGED
@@ -92,5 +92,15 @@ module Gritano
|
|
92
92
|
user.add_access(repo, :write).should be_true
|
93
93
|
user.check_access(repo, :write).should be_true
|
94
94
|
end
|
95
|
+
|
96
|
+
it "can have a password" do
|
97
|
+
user = User.create(login: 'user', password: '123')
|
98
|
+
user.should be_valid
|
99
|
+
end
|
100
|
+
|
101
|
+
it "can if a password is valid" do
|
102
|
+
user = User.create(login: 'user', password: '123')
|
103
|
+
user.password.should be == '123'
|
104
|
+
end
|
95
105
|
end
|
96
106
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gritano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -91,6 +91,22 @@ dependencies:
|
|
91
91
|
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: bcrypt-ruby
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
94
110
|
- !ruby/object:Gem::Dependency
|
95
111
|
name: rspec
|
96
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -237,6 +253,7 @@ files:
|
|
237
253
|
- db/migrate/004_create_keys.rb
|
238
254
|
- db/migrate/005_add_admin_to_users.rb
|
239
255
|
- db/migrate/006_add_email_to_users.rb
|
256
|
+
- db/migrate/007_add_password_to_users.rb
|
240
257
|
- features/data/config_true.yml
|
241
258
|
- features/data/local_commands/addon_list.txt
|
242
259
|
- features/data/local_commands/addon_ssh_install.txt
|
@@ -479,7 +496,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
479
496
|
version: '0'
|
480
497
|
segments:
|
481
498
|
- 0
|
482
|
-
hash: -
|
499
|
+
hash: -1458194907486604045
|
483
500
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
484
501
|
none: false
|
485
502
|
requirements:
|