leanback 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.rdoc +5 -1
- data/README.md +1 -1
- data/VERSION +1 -1
- data/leanback.gemspec +2 -2
- data/lib/leanback.rb +15 -0
- data/spec/no_admin_party/database_spec.rb +17 -0
- data/test/main.rb +11 -2
- metadata +3 -3
data/Changelog.rdoc
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
=Leanback 0.3.1
|
2
|
+
December 5,2011
|
3
|
+
* Added ability to change password for non-admin users.
|
4
|
+
|
1
5
|
=Leanback 0.3.0
|
2
|
-
|
6
|
+
November 20,2011
|
3
7
|
* Added CouchDB Security features: working with admin and non-admin users, authentication, adding security objects to databases. See documentation for details.
|
4
8
|
|
5
9
|
November 9,2011:-
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ This project is still under development. Not complete by any means. I made this
|
|
21
21
|
|
22
22
|
+ Working with [CouchDB Views](http://www.whisperservers.com/leanback/design-documents-and-permanent-views/)
|
23
23
|
|
24
|
-
+ [Error Handling](http://www.whisperservers.com/
|
24
|
+
+ [Error Handling](http://www.whisperservers.com/leanback/error-handling/)
|
25
25
|
|
26
26
|
+ [CouchDB Configuration](http://www.whisperservers.com/leanback/couchdb-configuration/)
|
27
27
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/leanback.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{leanback}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Obi Akubue}]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-12-05}
|
13
13
|
s.description = %q{lightweight Ruby interface to CouchDB}
|
14
14
|
s.email = %q{obioraakubue@yahoo.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/leanback.rb
CHANGED
@@ -11,6 +11,21 @@ end
|
|
11
11
|
|
12
12
|
module Couchdb
|
13
13
|
|
14
|
+
def self.salt
|
15
|
+
o = [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten;
|
16
|
+
salt = (0..50).map{ o[rand(o.length)] }.join;
|
17
|
+
end
|
18
|
+
|
19
|
+
#change non-admin user password
|
20
|
+
def self.change_password(username, new_password,auth_session = "")
|
21
|
+
salty = salt()
|
22
|
+
password_sha = Digest::SHA1.hexdigest(new_password + salty)
|
23
|
+
user_id = 'org.couchdb.user:' + username
|
24
|
+
data = {"salt" => salty,"password_sha" => password_sha}
|
25
|
+
doc = { :database => '_users', :doc_id => user_id, :data => data}
|
26
|
+
update_doc doc,auth_session
|
27
|
+
end
|
28
|
+
|
14
29
|
#add a new user
|
15
30
|
def self.add_user(user, auth_session="")
|
16
31
|
o = [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten;
|
@@ -255,6 +255,23 @@ it "create a new non-admin user, login user, retrieve user and delete the user"
|
|
255
255
|
end
|
256
256
|
|
257
257
|
|
258
|
+
it "should non-admin user password, verify new password" do
|
259
|
+
user = { :username => "another_sample_user", :password => "trusted", :roles => []}
|
260
|
+
hash = Couchdb.add_user(user)
|
261
|
+
hash["ok"].should == true
|
262
|
+
hash["id"].should == 'org.couchdb.user:another_sample_user'
|
263
|
+
|
264
|
+
Couchdb.change_password(username = 'another_sample_user', new_password = "brown", @@auth_session)
|
265
|
+
hash = Couchdb.login(username = 'another_sample_user',password ='brown')
|
266
|
+
hash.has_key?("AuthSession").should == true
|
267
|
+
|
268
|
+
lambda {Couchdb.login(username = 'another_sample_user',password ='trusted')}.should raise_error(CouchdbException,"CouchDB: Error - unauthorized. Reason - Name or password is incorrect.")
|
269
|
+
|
270
|
+
doc = {:database => '_users', :doc_id => 'org.couchdb.user:another_sample_user'}
|
271
|
+
hash = Couchdb.delete_doc doc,@@auth_session
|
272
|
+
|
273
|
+
end
|
274
|
+
|
258
275
|
it "should switch to default bind address" do
|
259
276
|
data = {:section => "httpd",
|
260
277
|
:key => "port",
|
data/test/main.rb
CHANGED
@@ -15,6 +15,15 @@ hash = Couchdb.login(username = 'obi',password ='trusted')
|
|
15
15
|
|
16
16
|
auth_session = hash["AuthSession"]
|
17
17
|
|
18
|
+
new_password = 'ninja'
|
19
|
+
puts new_password
|
20
|
+
puts Couchdb.change_password(username = 'kent', new_password, auth_session)
|
21
|
+
|
22
|
+
hash = Couchdb.login(username ,new_password)
|
23
|
+
user_auth_session = hash["AuthSession"]
|
24
|
+
|
25
|
+
puts user_auth_session
|
26
|
+
|
18
27
|
#data = {:section => "httpd",
|
19
28
|
# :key => "port"}
|
20
29
|
|
@@ -29,8 +38,8 @@ data = { :admins => {"names" => ["david"], "roles" => ["admin"]},
|
|
29
38
|
}
|
30
39
|
|
31
40
|
#hash = Couchdb.set_security("contacts",data,auth_session)
|
32
|
-
hash = Couchdb.get_security("contacts",auth_session)
|
33
|
-
|
41
|
+
# hash = Couchdb.get_security("contacts",auth_session)
|
42
|
+
# puts hash.inspect
|
34
43
|
|
35
44
|
data = {:section => "admins",
|
36
45
|
:key => "sample_admin",
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: leanback
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Obi Akubue
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-12-05 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -130,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
130
|
requirements:
|
131
131
|
- - ">="
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
hash:
|
133
|
+
hash: -997748307
|
134
134
|
segments:
|
135
135
|
- 0
|
136
136
|
version: "0"
|