leanback 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +10 -0
- data/Gemfile +5 -6
- data/Gemfile.lock +65 -14
- data/README.md +465 -33
- data/Rakefile +8 -17
- data/VERSION +1 -1
- data/leanback.gemspec +26 -85
- data/lib/leanback.rb +129 -587
- data/spec/leanback_spec.rb +356 -0
- metadata +40 -117
- data/Changelog.rdoc +0 -146
- data/documentation/static/2011/11/20/i-moved-leanback-documentation/index.html +0 -180
- data/documentation/static/2011/11/20/index.html +0 -146
- data/documentation/static/2011/11/index.html +0 -146
- data/documentation/static/2011/index.html +0 -146
- data/documentation/static/2013/06/02/index.html +0 -146
- data/documentation/static/2013/06/02/released-leanback-v0-3-4/index.html +0 -180
- data/documentation/static/2013/06/09/index.html +0 -146
- data/documentation/static/2013/06/09/released-leanback-v0-4-0/index.html +0 -179
- data/documentation/static/2013/06/index.html +0 -158
- data/documentation/static/2013/index.html +0 -158
- data/documentation/static/author/admin/index.html +0 -175
- data/documentation/static/basic-couchdb-operations/index.html +0 -259
- data/documentation/static/category/uncategorized/index.html +0 -170
- data/documentation/static/couchdb-configuration/index.html +0 -189
- data/documentation/static/couchdb-security/index.html +0 -218
- data/documentation/static/count-by-multiple-documents/index.html +0 -221
- data/documentation/static/count-documents-by-key/index.html +0 -177
- data/documentation/static/css/2c-l-fixed.css +0 -1
- data/documentation/static/css/2c-l-fixed.dev.css +0 -62
- data/documentation/static/css/2c-r-fixed.css +0 -1
- data/documentation/static/css/2c-r-fixed.dev.css +0 -60
- data/documentation/static/css/3c-c-fixed.css +0 -1
- data/documentation/static/css/3c-c-fixed.dev.css +0 -84
- data/documentation/static/css/3c-l-fixed.css +0 -1
- data/documentation/static/css/3c-l-fixed.dev.css +0 -61
- data/documentation/static/css/3c-r-fixed.css +0 -1
- data/documentation/static/css/3c-r-fixed.dev.css +0 -62
- data/documentation/static/css/holy-grail-fluid.css +0 -5
- data/documentation/static/css/plugins.css +0 -5
- data/documentation/static/css/print.css +0 -5
- data/documentation/static/css/screen.css +0 -1
- data/documentation/static/design-documents-and-permanent-views/index.html +0 -454
- data/documentation/static/error-handling/index.html +0 -157
- data/documentation/static/find-document-by-multiple-keys/index.html +0 -269
- data/documentation/static/find-documents-by-key/index.html +0 -243
- data/documentation/static/index.html +0 -161
- data/documentation/static/leanback/index.html +0 -130
- data/documentation/static/leanback/installation/index.html +0 -119
- data/documentation/static/setting-the-bind_address-port/index.html +0 -151
- data/documentation/static/style.css +0 -16
- data/spec/admin_party/database_spec.rb +0 -400
- data/spec/no_admin_party/cloudant_spec.rb +0 -365
- data/spec/no_admin_party/database_spec.rb +0 -491
- data/spec/no_admin_party/non_admin_user_spec.rb +0 -67
- data/test/helper.rb +0 -18
- data/test/main.rb +0 -295
- data/test/my_view.json +0 -8
- data/test/my_views.json +0 -8
- data/test/start.json +0 -8
- data/test/test_leanback.rb +0 -319
- data/test/view_age.json +0 -8
@@ -1,170 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en-US">
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
5
|
-
<title>Uncategorized</title>
|
6
|
-
|
7
|
-
<link rel="stylesheet" href="http://www.whisperservers.com/leanback/wp-content/themes/hybrid/style.css" type="text/css" media="all" />
|
8
|
-
<link rel="profile" href="http://gmpg.org/xfn/11" />
|
9
|
-
<link rel="pingback" href="http://www.whisperservers.com/leanback/xmlrpc.php" />
|
10
|
-
|
11
|
-
<meta name="generator" content="WordPress 3.5.1 - really-static 0.5" />
|
12
|
-
<meta name="template" content="Hybrid 1.0" />
|
13
|
-
<meta name="robots" content="index,follow" />
|
14
|
-
<meta name="copyright" content="Copyright (c) 2013" />
|
15
|
-
<link rel="alternate" type="application/rss+xml" title="Leanback » Feed" href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/feed/" />
|
16
|
-
|
17
|
-
<link rel="alternate" type="application/rss+xml" title="Leanback » Uncategorized Category Feed" href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/category/uncategorized/feed/" />
|
18
|
-
<script type='text/javascript' src='http://www.whisperservers.com/leanback/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>
|
19
|
-
|
20
|
-
<link rel="stylesheet" href="http://www.whisperservers.com/leanback/wp-content/plugins/wp-syntax/wp-syntax.css" type="text/css" media="screen" />
|
21
|
-
|
22
|
-
</head>
|
23
|
-
|
24
|
-
<body class="wordpress ltr en_US parent-theme y2013 m06 d09 h16 sunday logged-out archive taxonomy taxonomy-category taxonomy-category-uncategorized primary-active secondary-inactive subsidiary-inactive">
|
25
|
-
|
26
|
-
|
27
|
-
<div id="body-container">
|
28
|
-
|
29
|
-
|
30
|
-
<div id="header-container">
|
31
|
-
|
32
|
-
<div id="header">
|
33
|
-
|
34
|
-
<div id="site-title"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/" title="Leanback" rel="home"><span>Leanback</span></a></div>
|
35
|
-
<div id="site-description"><span>Simple Ruby interface to CouchDB</span></div>
|
36
|
-
|
37
|
-
</div><!-- #header -->
|
38
|
-
|
39
|
-
</div><!-- #header-container -->
|
40
|
-
|
41
|
-
|
42
|
-
<div id="container">
|
43
|
-
|
44
|
-
|
45
|
-
<div id="content" class="hfeed content">
|
46
|
-
|
47
|
-
<div class="breadcrumb breadcrumbs"><div class="breadcrumb-trail"><span class="trail-before"><span class="breadcrumb-title">Browse:</span></span> <a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/" title="Leanback" rel="home" class="trail-begin">Home</a> <span class="sep">/</span> <span class="trail-end">Uncategorized</span></div></div>
|
48
|
-
|
49
|
-
|
50
|
-
<div class="loop-meta archive-info category-info">
|
51
|
-
|
52
|
-
<h1 class="loop-title archive-title category-title">Uncategorized</h1>
|
53
|
-
|
54
|
-
<div class="loop-description archive-description category-description">
|
55
|
-
</div><!-- .loop-description -->
|
56
|
-
|
57
|
-
</div><!-- .loop-meta -->
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
<div id="post-177" class="hentry post publish post-1 odd author-admin category-uncategorized">
|
62
|
-
|
63
|
-
|
64
|
-
<h2 class="entry-title"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/2013/06/09/released-leanback-v0-4-0/" title="Released leanback v0.4.0" rel="bookmark">Released leanback v0.4.0</a></h2><p class="byline">By <span class="author vcard"><a class="url fn n" href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/author/admin/" title="admin">admin</a></span> on <abbr class="published" title="Sunday, June 9th, 2013, 3:43 pm">June 9, 2013</abbr> </p>
|
65
|
-
<div class="entry-summary">
|
66
|
-
<p>Just released leanback v0.4.0. See the changelog for new changes.</p>
|
67
|
-
</div><!-- .entry-summary -->
|
68
|
-
|
69
|
-
<p class="entry-meta"><span class="category"><span class="before">Posted in </span><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/category/uncategorized/" rel="tag">Uncategorized</a></span> | <a class="comments-link" href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/2013/06/09/released-leanback-v0-4-0/#respond" title="Comment on Released leanback v0.4.0">Leave a response</a></p>
|
70
|
-
</div><!-- .hentry -->
|
71
|
-
|
72
|
-
|
73
|
-
<div id="post-159" class="hentry post publish post-2 even alt author-admin category-uncategorized">
|
74
|
-
|
75
|
-
|
76
|
-
<h2 class="entry-title"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/2013/06/02/released-leanback-v0-3-4/" title="Released leanback v0.3.4" rel="bookmark">Released leanback v0.3.4</a></h2><p class="byline">By <span class="author vcard"><a class="url fn n" href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/author/admin/" title="admin">admin</a></span> on <abbr class="published" title="Sunday, June 2nd, 2013, 6:24 pm">June 2, 2013</abbr> </p>
|
77
|
-
<div class="entry-summary">
|
78
|
-
<p>Just released leanback v0.3.4. See the changelog for new changes.</p>
|
79
|
-
</div><!-- .entry-summary -->
|
80
|
-
|
81
|
-
<p class="entry-meta"><span class="category"><span class="before">Posted in </span><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/category/uncategorized/" rel="tag">Uncategorized</a></span> | <a class="comments-link" href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/2013/06/02/released-leanback-v0-3-4/#respond" title="Comment on Released leanback v0.3.4">Leave a response</a></p>
|
82
|
-
</div><!-- .hentry -->
|
83
|
-
|
84
|
-
|
85
|
-
<div id="post-113" class="hentry post publish post-3 odd author-admin category-uncategorized">
|
86
|
-
|
87
|
-
|
88
|
-
<h2 class="entry-title"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/2011/11/20/i-moved-leanback-documentation/" title="Welcome to the new site" rel="bookmark">Welcome to the new site</a></h2><p class="byline">By <span class="author vcard"><a class="url fn n" href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/author/admin/" title="admin">admin</a></span> on <abbr class="published" title="Sunday, November 20th, 2011, 10:48 pm">November 20, 2011</abbr> </p>
|
89
|
-
<div class="entry-summary">
|
90
|
-
<p>This is the new location for Leanback RubyGem’s documentation. I moved it here, to support the release of v0.3.0. A README file format wouldn’t be sufficient anymore. So I decided to move the documentation over here, to make it more accessible.</p>
|
91
|
-
</div><!-- .entry-summary -->
|
92
|
-
|
93
|
-
<p class="entry-meta"><span class="category"><span class="before">Posted in </span><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/category/uncategorized/" rel="tag">Uncategorized</a></span> | <a class="comments-link" href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/2011/11/20/i-moved-leanback-documentation/#respond" title="Comment on Welcome to the new site">Leave a response</a></p>
|
94
|
-
</div><!-- .hentry -->
|
95
|
-
|
96
|
-
<script type="text/javascript">
|
97
|
-
// <![CDATA[
|
98
|
-
var disqus_shortname = 'obi-akubue';
|
99
|
-
var disqus_domain = 'disqus.com';
|
100
|
-
(function () {
|
101
|
-
var nodes = document.getElementsByTagName('span');
|
102
|
-
for (var i = 0, url; i < nodes.length; i++) {
|
103
|
-
if (nodes[i].className.indexOf('dsq-postid') != -1) {
|
104
|
-
nodes[i].parentNode.setAttribute('data-disqus-identifier', nodes[i].getAttribute('rel'));
|
105
|
-
url = nodes[i].parentNode.href.split('#', 1);
|
106
|
-
if (url.length == 1) { url = url[0]; }
|
107
|
-
else { url = url[1]; }
|
108
|
-
nodes[i].parentNode.href = url + '#disqus_thread';
|
109
|
-
}
|
110
|
-
}
|
111
|
-
var s = document.createElement('script'); s.async = true;
|
112
|
-
s.type = 'text/javascript';
|
113
|
-
s.src = 'http://' + disqus_domain + '/forums/' + disqus_shortname + '/count.js';
|
114
|
-
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
|
115
|
-
}());
|
116
|
-
//]]>
|
117
|
-
</script>
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
</div><!-- .content .hfeed -->
|
123
|
-
|
124
|
-
|
125
|
-
<div id="primary" class="sidebar aside">
|
126
|
-
|
127
|
-
|
128
|
-
<div id="hybrid-nav-menu-3" class="widget nav-menu widget-nav-menu"><div class="widget-wrap widget-inside"><h3 class="widget-title">Leanback</h3><div class="menu-sidebar-container"><ul id="menu-sidebar" class="nav-menu"><li id="menu-item-13" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-13"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/leanback/">Leanback</a><ul class="sub-menu"><li id="menu-item-14" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-14"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/leanback/installation/">Install</a></li><li id="menu-item-15" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-15"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/basic-couchdb-operations/">Basic CouchDB Operations</a></li><li id="menu-item-41" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-41"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-documents-by-key/">Find documents by key</a></li><li id="menu-item-167" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-167"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-document-by-multiple-keys/">Find document by multiple Keys</a></li><li id="menu-item-140" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-140"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/count-documents-by-key/">Count documents by key</a></li><li id="menu-item-175" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-175"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/count-by-multiple-documents/">Count documents by multiple keys</a></li><li id="menu-item-45" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-45"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/design-documents-and-permanent-views/">Working with CouchDB views</a></li><li id="menu-item-67" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-67"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/error-handling/">Error handling</a></li><li id="menu-item-96" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-96"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-configuration/">CouchDB Configuration</a></li><li id="menu-item-102" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-102"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-security/">CouchDB Security</a></li><li id="menu-item-105" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-105"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/setting-the-bind_address-port/">CouchDB Bind_Address & Port</a></li></ul></li><li id="menu-item-142" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-142"><a href="https://github.com/obi-a/leanback/blob/master/Changelog.rdoc">Changes</a></li><li id="menu-item-78" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-78"><a href="https://github.com/obi-a/leanback">Source Code</a></li></ul></div></div></div>
|
129
|
-
|
130
|
-
</div><!-- #primary .aside -->
|
131
|
-
|
132
|
-
|
133
|
-
</div><!-- #container -->
|
134
|
-
|
135
|
-
<div id="footer-container">
|
136
|
-
|
137
|
-
|
138
|
-
<div id="footer">
|
139
|
-
|
140
|
-
<div class="footer-insert"><p class="copyright">Copyright © 2013 <a href="http://obi-akubue.org">obi-akubue.org</a>.</p></div>
|
141
|
-
</div><!-- #footer -->
|
142
|
-
|
143
|
-
|
144
|
-
</div><!-- #footer-container -->
|
145
|
-
|
146
|
-
</div><!-- #body-container -->
|
147
|
-
|
148
|
-
|
149
|
-
<script type="text/javascript">
|
150
|
-
|
151
|
-
var _gaq = _gaq || [];
|
152
|
-
_gaq.push(['_setAccount', 'UA-20190925-6']);
|
153
|
-
_gaq.push(['_trackPageview']);
|
154
|
-
|
155
|
-
(function() {
|
156
|
-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
157
|
-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
158
|
-
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
|
159
|
-
})();
|
160
|
-
</script>
|
161
|
-
|
162
|
-
<a style='color:transparent;position:absolute;left:-99999px;z-index:-99999' href='http://www.wpdownloadmanager.com/' title='Premium Wordpress Plugin download manager'>Premium Wordpress Plugin</a>
|
163
|
-
<script type='text/javascript' src='http://www.whisperservers.com/leanback/wp-content/themes/hybrid/library/js/drop-downs.js?ver=20110705'></script>
|
164
|
-
|
165
|
-
</body>
|
166
|
-
</html>
|
167
|
-
<!-- Dynamic page generated in 0.372 seconds. -->
|
168
|
-
<!-- Cached page generated by WP-Super-Cache on 2013-06-09 16:28:04 -->
|
169
|
-
|
170
|
-
<!-- super cache -->
|
@@ -1,189 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en-US">
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
5
|
-
<title>CouchDB Configuration</title>
|
6
|
-
|
7
|
-
<link rel="stylesheet" href="http://www.whisperservers.com/leanback/wp-content/themes/hybrid/style.css" type="text/css" media="all" />
|
8
|
-
<link rel="profile" href="http://gmpg.org/xfn/11" />
|
9
|
-
<link rel="pingback" href="http://www.whisperservers.com/leanback/xmlrpc.php" />
|
10
|
-
|
11
|
-
<meta name="generator" content="WordPress 3.5.1 - really-static 0.5" />
|
12
|
-
<meta name="template" content="Hybrid 1.0" />
|
13
|
-
<meta name="robots" content="index,follow" />
|
14
|
-
<meta name="author" content="admin" />
|
15
|
-
<meta name="copyright" content="Copyright (c) November 2011" />
|
16
|
-
<meta name="revised" content="Saturday, November 26th, 2011, 11:01 pm" />
|
17
|
-
<link rel="alternate" type="application/rss+xml" title="Leanback » Feed" href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/feed/" />
|
18
|
-
|
19
|
-
<script type='text/javascript' src='http://www.whisperservers.com/leanback/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>
|
20
|
-
<link rel='prev' title='Error handling' href='http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/error-handling/' />
|
21
|
-
<link rel='next' title='CouchDB Security' href='http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-security/' />
|
22
|
-
<link rel='canonical' href='http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-configuration/' />
|
23
|
-
|
24
|
-
<link rel="stylesheet" href="http://www.whisperservers.com/leanback/wp-content/plugins/wp-syntax/wp-syntax.css" type="text/css" media="screen" />
|
25
|
-
|
26
|
-
</head>
|
27
|
-
|
28
|
-
<body class="wordpress ltr en_US parent-theme y2013 m06 d09 h16 sunday logged-out singular singular-page singular-page-86 page-template-default page-86 primary-active secondary-inactive subsidiary-inactive">
|
29
|
-
|
30
|
-
|
31
|
-
<div id="body-container">
|
32
|
-
|
33
|
-
|
34
|
-
<div id="header-container">
|
35
|
-
|
36
|
-
<div id="header">
|
37
|
-
|
38
|
-
<div id="site-title"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/" title="Leanback" rel="home"><span>Leanback</span></a></div>
|
39
|
-
<div id="site-description"><span>Simple Ruby interface to CouchDB</span></div>
|
40
|
-
|
41
|
-
</div><!-- #header -->
|
42
|
-
|
43
|
-
</div><!-- #header-container -->
|
44
|
-
|
45
|
-
|
46
|
-
<div id="container">
|
47
|
-
|
48
|
-
|
49
|
-
<div id="content" class="hfeed content">
|
50
|
-
|
51
|
-
<div class="breadcrumb breadcrumbs"><div class="breadcrumb-trail"><span class="trail-before"><span class="breadcrumb-title">Browse:</span></span> <a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/" title="Leanback" rel="home" class="trail-begin">Home</a> <span class="sep">/</span> <span class="trail-end">CouchDB Configuration</span></div></div>
|
52
|
-
|
53
|
-
<div id="post-86" class="hentry page publish post-1 odd author-admin">
|
54
|
-
|
55
|
-
<h1 class="page-title entry-title"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-configuration/" title="CouchDB Configuration" rel="bookmark">CouchDB Configuration</a></h1>
|
56
|
-
<div class="entry-content">
|
57
|
-
<p>Leanback directly supports CouchDB’s configuration API. </p>
|
58
|
-
<p>First we login to CouchDB and generate the auth_session token for making requests.</p>
|
59
|
-
|
60
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">hash = Couchdb.<span style="color:#9900CC;">login</span><span style="color:#006600; font-weight:bold;">(</span>username = <span style="color:#996600;">'samson'</span>,password =<span style="color:#996600;">'sam123'</span><span style="color:#006600; font-weight:bold;">)</span>
|
61
|
-
auth_session = hash<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"AuthSession"</span><span style="color:#006600; font-weight:bold;">]</span></pre></div></div>
|
62
|
-
|
63
|
-
<p><strong>Set Configuration</strong><br />
|
64
|
-
To change a CouchDB configuration setting, we use the set_config() method. For example to add an admin user to CouchDB.</p>
|
65
|
-
|
66
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"> data = <span style="color:#006600; font-weight:bold;">{</span>:section <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"admins"</span>,
|
67
|
-
<span style="color:#ff3333; font-weight:bold;">:key</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"james"</span>,
|
68
|
-
<span style="color:#ff3333; font-weight:bold;">:value</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"abc123"</span><span style="color:#006600; font-weight:bold;">}</span>
|
69
|
-
Couchdb.<span style="color:#9900CC;">set_config</span> data,auth_session</pre></div></div>
|
70
|
-
|
71
|
-
<p>This is similar to sending a </p>
|
72
|
-
<p>PUT http://127.0.0.1:5984/_config/admins/james,’”abc123″‘ </p>
|
73
|
-
<p>If you check Futon’s Configuration section you would notice a new admin ‘james’ have been added to the admins section. The new admin’s username is ‘james’ and password is ‘abc123′. For more details on adding admin and non-admin users, <a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-security/">see here</a>.</p>
|
74
|
-
<p>To change couchDB’s bind_address</p>
|
75
|
-
|
76
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">data = <span style="color:#006600; font-weight:bold;">{</span>:section <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"httpd"</span>,
|
77
|
-
<span style="color:#ff3333; font-weight:bold;">:key</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"bind_address"</span>,
|
78
|
-
<span style="color:#ff3333; font-weight:bold;">:value</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"192.168.1.118"</span><span style="color:#006600; font-weight:bold;">}</span>
|
79
|
-
|
80
|
-
Couchdb.<span style="color:#9900CC;">set_config</span><span style="color:#006600; font-weight:bold;">(</span>data, auth_session<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
81
|
-
|
82
|
-
<p>This only changes CouchDB’s bind_address, it doesn’t change the address used by Leanback to make http requests. Leanback uses ’127.0.0.1′ by default, to change leanback’s default address:</p>
|
83
|
-
|
84
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Couchdb.<span style="color:#9900CC;">address</span> = <span style="color:#996600;">"192.168.1.118"</span></pre></div></div>
|
85
|
-
|
86
|
-
<p>This is discussed in great detail <a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/setting-the-bind_address-port/">here</a>.</p>
|
87
|
-
<p>To change the ‘couch_httpd_auth’ timeout value:</p>
|
88
|
-
|
89
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">data = <span style="color:#006600; font-weight:bold;">{</span>:section <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"couch_httpd_auth"</span>,
|
90
|
-
<span style="color:#ff3333; font-weight:bold;">:key</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"timeout"</span>,
|
91
|
-
<span style="color:#ff3333; font-weight:bold;">:value</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"700"</span><span style="color:#006600; font-weight:bold;">}</span>
|
92
|
-
|
93
|
-
Couchdb.<span style="color:#9900CC;">set_config</span><span style="color:#006600; font-weight:bold;">(</span>data, auth_session<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
94
|
-
|
95
|
-
<p>This changes the time it takes for the generated auth_session token to expire.</p>
|
96
|
-
<p>To add custom configuration settings:</p>
|
97
|
-
|
98
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">data = <span style="color:#006600; font-weight:bold;">{</span>:section <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"sample_config_section"</span>,
|
99
|
-
<span style="color:#ff3333; font-weight:bold;">:key</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"sample_key"</span>,
|
100
|
-
<span style="color:#ff3333; font-weight:bold;">:value</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"sample_value"</span><span style="color:#006600; font-weight:bold;">}</span>
|
101
|
-
Couchdb.<span style="color:#9900CC;">set_config</span> data,auth_session</pre></div></div>
|
102
|
-
|
103
|
-
<p>If you check Futon’s configuration page you will notice a new section called ‘sample_config_section’ with key ‘sample_key’ and value ‘sample_value’.</p>
|
104
|
-
<p><strong>Get Configuration</strong><br />
|
105
|
-
To retrieve CouchDB’s configuration settings we use the get_config() method.<br />
|
106
|
-
Example to retrieve couchDB’s port#</p>
|
107
|
-
|
108
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"> data = <span style="color:#006600; font-weight:bold;">{</span>:section <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"httpd"</span>,
|
109
|
-
<span style="color:#ff3333; font-weight:bold;">:key</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"port"</span><span style="color:#006600; font-weight:bold;">}</span>
|
110
|
-
|
111
|
-
Couchdb.<span style="color:#9900CC;">get_config</span><span style="color:#006600; font-weight:bold;">(</span>data,auth_session<span style="color:#006600; font-weight:bold;">)</span>
|
112
|
-
<span style="color:#008000; font-style:italic;">#=> "5984"</span></pre></div></div>
|
113
|
-
|
114
|
-
<p>To retrieve CouchDB’s database dir</p>
|
115
|
-
|
116
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">data = <span style="color:#006600; font-weight:bold;">{</span>:section <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"couchdb"</span>,
|
117
|
-
<span style="color:#ff3333; font-weight:bold;">:key</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"database_dir"</span><span style="color:#006600; font-weight:bold;">}</span>
|
118
|
-
|
119
|
-
Couchdb.<span style="color:#9900CC;">get_config</span><span style="color:#006600; font-weight:bold;">(</span>data,auth_session<span style="color:#006600; font-weight:bold;">)</span>
|
120
|
-
<span style="color:#008000; font-style:italic;">#=> "/var/lib/couchdb/1.0.1"</span></pre></div></div>
|
121
|
-
|
122
|
-
<p><strong>Delete Configuration</strong><br />
|
123
|
-
To delete a configuration setting we the delete_config() method. Example to delete an admin:</p>
|
124
|
-
|
125
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">data = <span style="color:#006600; font-weight:bold;">{</span>:section <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"admins"</span>,
|
126
|
-
<span style="color:#ff3333; font-weight:bold;">:key</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"james"</span><span style="color:#006600; font-weight:bold;">}</span>
|
127
|
-
|
128
|
-
Couchdb.<span style="color:#9900CC;">delete_config</span><span style="color:#006600; font-weight:bold;">(</span>data,auth_session<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
129
|
-
|
130
|
-
</div><!-- .entry-content -->
|
131
|
-
|
132
|
-
|
133
|
-
</div><!-- .hentry -->
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
</div><!-- .content .hfeed -->
|
142
|
-
|
143
|
-
|
144
|
-
<div id="primary" class="sidebar aside">
|
145
|
-
|
146
|
-
|
147
|
-
<div id="hybrid-nav-menu-3" class="widget nav-menu widget-nav-menu"><div class="widget-wrap widget-inside"><h3 class="widget-title">Leanback</h3><div class="menu-sidebar-container"><ul id="menu-sidebar" class="nav-menu"><li id="menu-item-13" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-ancestor current-menu-parent current_page_parent current_page_ancestor menu-item-13"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/leanback/">Leanback</a><ul class="sub-menu"><li id="menu-item-14" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-14"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/leanback/installation/">Install</a></li><li id="menu-item-15" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-15"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/basic-couchdb-operations/">Basic CouchDB Operations</a></li><li id="menu-item-41" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-41"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-documents-by-key/">Find documents by key</a></li><li id="menu-item-167" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-167"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-document-by-multiple-keys/">Find document by multiple Keys</a></li><li id="menu-item-140" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-140"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/count-documents-by-key/">Count documents by key</a></li><li id="menu-item-175" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-175"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/count-by-multiple-documents/">Count documents by multiple keys</a></li><li id="menu-item-45" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-45"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/design-documents-and-permanent-views/">Working with CouchDB views</a></li><li id="menu-item-67" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-67"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/error-handling/">Error handling</a></li><li id="menu-item-96" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-86 current_page_item menu-item-96"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-configuration/">CouchDB Configuration</a></li><li id="menu-item-102" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-102"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-security/">CouchDB Security</a></li><li id="menu-item-105" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-105"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/setting-the-bind_address-port/">CouchDB Bind_Address & Port</a></li></ul></li><li id="menu-item-142" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-142"><a href="https://github.com/obi-a/leanback/blob/master/Changelog.rdoc">Changes</a></li><li id="menu-item-78" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-78"><a href="https://github.com/obi-a/leanback">Source Code</a></li></ul></div></div></div>
|
148
|
-
|
149
|
-
</div><!-- #primary .aside -->
|
150
|
-
|
151
|
-
|
152
|
-
</div><!-- #container -->
|
153
|
-
|
154
|
-
<div id="footer-container">
|
155
|
-
|
156
|
-
|
157
|
-
<div id="footer">
|
158
|
-
|
159
|
-
<div class="footer-insert"><p class="copyright">Copyright © 2013 <a href="http://obi-akubue.org">obi-akubue.org</a>.</p></div>
|
160
|
-
</div><!-- #footer -->
|
161
|
-
|
162
|
-
|
163
|
-
</div><!-- #footer-container -->
|
164
|
-
|
165
|
-
</div><!-- #body-container -->
|
166
|
-
|
167
|
-
|
168
|
-
<script type="text/javascript">
|
169
|
-
|
170
|
-
var _gaq = _gaq || [];
|
171
|
-
_gaq.push(['_setAccount', 'UA-20190925-6']);
|
172
|
-
_gaq.push(['_trackPageview']);
|
173
|
-
|
174
|
-
(function() {
|
175
|
-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
176
|
-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
177
|
-
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
|
178
|
-
})();
|
179
|
-
</script>
|
180
|
-
|
181
|
-
<a style='color:transparent;position:absolute;left:-99999px;z-index:-99999' href='http://www.wpdownloadmanager.com/' title='Premium Wordpress Plugin download manager'>Premium Wordpress Plugin</a>
|
182
|
-
<script type='text/javascript' src='http://www.whisperservers.com/leanback/wp-content/themes/hybrid/library/js/drop-downs.js?ver=20110705'></script>
|
183
|
-
|
184
|
-
</body>
|
185
|
-
</html>
|
186
|
-
<!-- Dynamic page generated in 0.498 seconds. -->
|
187
|
-
<!-- Cached page generated by WP-Super-Cache on 2013-06-09 16:29:32 -->
|
188
|
-
|
189
|
-
<!-- super cache -->
|
@@ -1,218 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en-US">
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
5
|
-
<title>CouchDB Security</title>
|
6
|
-
|
7
|
-
<link rel="stylesheet" href="http://www.whisperservers.com/leanback/wp-content/themes/hybrid/style.css" type="text/css" media="all" />
|
8
|
-
<link rel="profile" href="http://gmpg.org/xfn/11" />
|
9
|
-
<link rel="pingback" href="http://www.whisperservers.com/leanback/xmlrpc.php" />
|
10
|
-
|
11
|
-
<meta name="generator" content="WordPress 3.5.1 - really-static 0.5" />
|
12
|
-
<meta name="template" content="Hybrid 1.0" />
|
13
|
-
<meta name="robots" content="index,follow" />
|
14
|
-
<meta name="author" content="admin" />
|
15
|
-
<meta name="copyright" content="Copyright (c) November 2011" />
|
16
|
-
<meta name="revised" content="Monday, December 3rd, 2012, 1:35 am" />
|
17
|
-
<link rel="alternate" type="application/rss+xml" title="Leanback » Feed" href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/feed/" />
|
18
|
-
|
19
|
-
<script type='text/javascript' src='http://www.whisperservers.com/leanback/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>
|
20
|
-
<link rel='prev' title='CouchDB Configuration' href='http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-configuration/' />
|
21
|
-
<link rel='next' title='CouchDB Bind_Address & Port' href='http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/setting-the-bind_address-port/' />
|
22
|
-
<link rel='canonical' href='http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-security/' />
|
23
|
-
|
24
|
-
<link rel="stylesheet" href="http://www.whisperservers.com/leanback/wp-content/plugins/wp-syntax/wp-syntax.css" type="text/css" media="screen" />
|
25
|
-
|
26
|
-
</head>
|
27
|
-
|
28
|
-
<body class="wordpress ltr en_US parent-theme y2013 m06 d09 h16 sunday logged-out singular singular-page singular-page-97 page-template-default page-97 primary-active secondary-inactive subsidiary-inactive">
|
29
|
-
|
30
|
-
|
31
|
-
<div id="body-container">
|
32
|
-
|
33
|
-
|
34
|
-
<div id="header-container">
|
35
|
-
|
36
|
-
<div id="header">
|
37
|
-
|
38
|
-
<div id="site-title"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/" title="Leanback" rel="home"><span>Leanback</span></a></div>
|
39
|
-
<div id="site-description"><span>Simple Ruby interface to CouchDB</span></div>
|
40
|
-
|
41
|
-
</div><!-- #header -->
|
42
|
-
|
43
|
-
</div><!-- #header-container -->
|
44
|
-
|
45
|
-
|
46
|
-
<div id="container">
|
47
|
-
|
48
|
-
|
49
|
-
<div id="content" class="hfeed content">
|
50
|
-
|
51
|
-
<div class="breadcrumb breadcrumbs"><div class="breadcrumb-trail"><span class="trail-before"><span class="breadcrumb-title">Browse:</span></span> <a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/" title="Leanback" rel="home" class="trail-begin">Home</a> <span class="sep">/</span> <span class="trail-end">CouchDB Security</span></div></div>
|
52
|
-
|
53
|
-
<div id="post-97" class="hentry page publish post-1 odd author-admin">
|
54
|
-
|
55
|
-
<h1 class="page-title entry-title"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-security/" title="CouchDB Security" rel="bookmark">CouchDB Security</a></h1>
|
56
|
-
<div class="entry-content">
|
57
|
-
<p><strong>Admin user</strong><br />
|
58
|
-
To add an admin user to CouchDB, and end the admin party</p>
|
59
|
-
|
60
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"> data = <span style="color:#006600; font-weight:bold;">{</span>:section <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"admins"</span>,
|
61
|
-
<span style="color:#ff3333; font-weight:bold;">:key</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"james"</span>,
|
62
|
-
<span style="color:#ff3333; font-weight:bold;">:value</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"abc123"</span><span style="color:#006600; font-weight:bold;">}</span>
|
63
|
-
Couchdb.<span style="color:#9900CC;">set_config</span> data</pre></div></div>
|
64
|
-
|
65
|
-
<p>This is similar to sending a</p>
|
66
|
-
|
67
|
-
<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">PUT http://127.0.0.1:5984/_config/admins/james,'"abc123"'</pre></div></div>
|
68
|
-
|
69
|
-
<p>If you check Futon’s Configuration section you would notice an admin ‘james’ have been added to the admins section. The admin’s username is ‘james’ and password is ‘abc123′.</p>
|
70
|
-
<p>To login the admin user,</p>
|
71
|
-
|
72
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">hash = Couchdb.<span style="color:#9900CC;">login</span><span style="color:#006600; font-weight:bold;">(</span>username = <span style="color:#996600;">'james'</span>,password =<span style="color:#996600;">'abc123'</span><span style="color:#006600; font-weight:bold;">)</span>
|
73
|
-
<span style="color:#008000; font-style:italic;">#=>{"AuthSession"=>"b2JpOjRFQzgyQ0U0OlA54YsdHNo8altYRIkLVVeyvwah",</span>
|
74
|
-
<span style="color:#008000; font-style:italic;"># "Version"=>"1", "Path"=>"%2F"}</span></pre></div></div>
|
75
|
-
|
76
|
-
<p>This is similar to sending a</p>
|
77
|
-
|
78
|
-
<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">POST 'http://127.0.0.1:5984/_session', 'name=james&password=abc123'</pre></div></div>
|
79
|
-
|
80
|
-
<p>Leanback uses CouchDB’s cookie authentication, see more details about it <a href="http://guide.couchdb.org/draft/security.html">here</a>. We need the AuthSession token for making future requests on behalf of the authenticated user.</p>
|
81
|
-
<p>We retrieve the AuthSession token by following the login with this</p>
|
82
|
-
|
83
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">auth_session = hash<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"AuthSession"</span><span style="color:#006600; font-weight:bold;">]</span></pre></div></div>
|
84
|
-
|
85
|
-
<p>The complete login code will be</p>
|
86
|
-
|
87
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">hash = Couchdb.<span style="color:#9900CC;">login</span><span style="color:#006600; font-weight:bold;">(</span>username = <span style="color:#996600;">'james'</span>,password =<span style="color:#996600;">'abc123'</span><span style="color:#006600; font-weight:bold;">)</span>
|
88
|
-
auth_session = hash<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"AuthSession"</span><span style="color:#006600; font-weight:bold;">]</span></pre></div></div>
|
89
|
-
|
90
|
-
<p>This authenticated admin user can add new admins to CouchDB</p>
|
91
|
-
|
92
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"> data = <span style="color:#006600; font-weight:bold;">{</span>:section <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"admins"</span>,
|
93
|
-
<span style="color:#ff3333; font-weight:bold;">:key</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"nancy"</span>,
|
94
|
-
<span style="color:#ff3333; font-weight:bold;">:value</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"see78no"</span><span style="color:#006600; font-weight:bold;">}</span>
|
95
|
-
Couchdb.<span style="color:#9900CC;">set_config</span> data,auth_session</pre></div></div>
|
96
|
-
|
97
|
-
<p>To delete the admin user</p>
|
98
|
-
|
99
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">data = <span style="color:#006600; font-weight:bold;">{</span>:section <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"admins"</span>,
|
100
|
-
<span style="color:#ff3333; font-weight:bold;">:key</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"nancy"</span><span style="color:#006600; font-weight:bold;">}</span>
|
101
|
-
|
102
|
-
Couchdb.<span style="color:#9900CC;">delete_config</span><span style="color:#006600; font-weight:bold;">(</span>data,auth_session<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
103
|
-
|
104
|
-
<p>If you delete all admin users CouchDB will switch to Admin Party.</p>
|
105
|
-
<p><strong>Non-Admin Users</strong></p>
|
106
|
-
<p>To add a non-admin user to CouchDB</p>
|
107
|
-
|
108
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">user = <span style="color:#006600; font-weight:bold;">{</span> <span style="color:#ff3333; font-weight:bold;">:username</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"david"</span>, <span style="color:#ff3333; font-weight:bold;">:password</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"trusted"</span>, <span style="color:#ff3333; font-weight:bold;">:roles</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006600; font-weight:bold;">[</span><span style="color:#006600; font-weight:bold;">]</span><span style="color:#006600; font-weight:bold;">}</span>
|
109
|
-
Couchdb.<span style="color:#9900CC;">add_user</span><span style="color:#006600; font-weight:bold;">(</span>user, auth_session<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
110
|
-
|
111
|
-
<p>This adds a new user to CouchDB’s _users database, if you check the _users database, you will see that a new user with id “org.couchdb.user:david” has been added to the database.<br />
|
112
|
-
The roles are left blank, since only admins can add roles. You can only assign roles to a user if you are making the request as an admin.</p>
|
113
|
-
|
114
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">user = <span style="color:#006600; font-weight:bold;">{</span> <span style="color:#ff3333; font-weight:bold;">:username</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"david"</span>, <span style="color:#ff3333; font-weight:bold;">:password</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"trusted"</span>, <span style="color:#ff3333; font-weight:bold;">:roles</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"staff"</span><span style="color:#006600; font-weight:bold;">]</span><span style="color:#006600; font-weight:bold;">}</span>
|
115
|
-
Couchdb.<span style="color:#9900CC;">add_user</span><span style="color:#006600; font-weight:bold;">(</span>user,auth_session<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
116
|
-
|
117
|
-
<p>Leanback generates a random salt string for CouchDB’s user password encryption. If you want to generate your own salt you can use the create_user() method instead of add_user().</p>
|
118
|
-
|
119
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">user = <span style="color:#006600; font-weight:bold;">{</span>:username <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"david"</span>,
|
120
|
-
<span style="color:#ff3333; font-weight:bold;">:password</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"trusted"</span>,
|
121
|
-
<span style="color:#ff3333; font-weight:bold;">:roles</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006600; font-weight:bold;">[</span><span style="color:#006600; font-weight:bold;">]</span>,
|
122
|
-
<span style="color:#ff3333; font-weight:bold;">:salt</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"random-salt-string"</span><span style="color:#006600; font-weight:bold;">}</span>
|
123
|
-
|
124
|
-
Couchdb.<span style="color:#9900CC;">create_user</span><span style="color:#006600; font-weight:bold;">(</span>user,auth_session<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
125
|
-
|
126
|
-
<p>To start a session for the non-admin user</p>
|
127
|
-
|
128
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">hash = Couchdb.<span style="color:#9900CC;">login</span><span style="color:#006600; font-weight:bold;">(</span>username = <span style="color:#996600;">'david'</span>,password =<span style="color:#996600;">'trusted'</span><span style="color:#006600; font-weight:bold;">)</span>
|
129
|
-
user_auth_session = hash<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"AuthSession"</span><span style="color:#006600; font-weight:bold;">]</span></pre></div></div>
|
130
|
-
|
131
|
-
<p>Same method works for authenticating admin & non-admin users. We can make requests on behalf of the user, using the AuthSession token we generated for them, in the login() method.</p>
|
132
|
-
<p>To change password for the non-admin user</p>
|
133
|
-
|
134
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Couchdb.<span style="color:#9900CC;">change_password</span><span style="color:#006600; font-weight:bold;">(</span>username = <span style="color:#996600;">'david'</span>, new_password = <span style="color:#996600;">"abc123"</span>,auth_session<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
135
|
-
|
136
|
-
<p>This will change the password of user <em>david</em> to <em>abc123</em>. </p>
|
137
|
-
<p><strong>Setting the Security Object of a database</strong><br />
|
138
|
-
To set the Security Object of a database named ‘contacts’</p>
|
139
|
-
|
140
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">data = <span style="color:#006600; font-weight:bold;">{</span> <span style="color:#ff3333; font-weight:bold;">:admins</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006600; font-weight:bold;">{</span><span style="color:#996600;">"names"</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"david"</span><span style="color:#006600; font-weight:bold;">]</span>, <span style="color:#996600;">"roles"</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"admin"</span><span style="color:#006600; font-weight:bold;">]</span><span style="color:#006600; font-weight:bold;">}</span>,
|
141
|
-
<span style="color:#ff3333; font-weight:bold;">:readers</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006600; font-weight:bold;">{</span><span style="color:#996600;">"names"</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"david"</span><span style="color:#006600; font-weight:bold;">]</span>,<span style="color:#996600;">"roles"</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"admin"</span><span style="color:#006600; font-weight:bold;">]</span><span style="color:#006600; font-weight:bold;">}</span>
|
142
|
-
<span style="color:#006600; font-weight:bold;">}</span>
|
143
|
-
|
144
|
-
Couchdb.<span style="color:#9900CC;">set_security</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#996600;">"contacts"</span>,data,auth_session<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
145
|
-
|
146
|
-
<p>To retrieve the security object of a database named ‘contacts’</p>
|
147
|
-
|
148
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Couchdb.<span style="color:#9900CC;">get_security</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#996600;">"contacts"</span>,auth_session<span style="color:#006600; font-weight:bold;">)</span>
|
149
|
-
<span style="color:#008000; font-style:italic;">#=>{"admins"=>{"names"=>["david"], "roles"=>["admin"]}, </span>
|
150
|
-
<span style="color:#008000; font-style:italic;"># "readers"=>{"names"=>["david"], "roles"=>["admin"]}}</span></pre></div></div>
|
151
|
-
|
152
|
-
<p>To clear the security object</p>
|
153
|
-
|
154
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">data = <span style="color:#006600; font-weight:bold;">{</span> <span style="color:#ff3333; font-weight:bold;">:admins</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006600; font-weight:bold;">{</span><span style="color:#996600;">"names"</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006600; font-weight:bold;">[</span><span style="color:#006600; font-weight:bold;">]</span>, <span style="color:#996600;">"roles"</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006600; font-weight:bold;">[</span><span style="color:#006600; font-weight:bold;">]</span><span style="color:#006600; font-weight:bold;">}</span>,
|
155
|
-
<span style="color:#ff3333; font-weight:bold;">:readers</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006600; font-weight:bold;">{</span><span style="color:#996600;">"names"</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006600; font-weight:bold;">[</span><span style="color:#006600; font-weight:bold;">]</span>,<span style="color:#996600;">"roles"</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006600; font-weight:bold;">[</span><span style="color:#006600; font-weight:bold;">]</span><span style="color:#006600; font-weight:bold;">}</span>
|
156
|
-
<span style="color:#006600; font-weight:bold;">}</span>
|
157
|
-
Couchdb.<span style="color:#9900CC;">set_security</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#996600;">"contacts"</span>,data,auth_session<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
158
|
-
|
159
|
-
</div><!-- .entry-content -->
|
160
|
-
|
161
|
-
|
162
|
-
</div><!-- .hentry -->
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
</div><!-- .content .hfeed -->
|
171
|
-
|
172
|
-
|
173
|
-
<div id="primary" class="sidebar aside">
|
174
|
-
|
175
|
-
|
176
|
-
<div id="hybrid-nav-menu-3" class="widget nav-menu widget-nav-menu"><div class="widget-wrap widget-inside"><h3 class="widget-title">Leanback</h3><div class="menu-sidebar-container"><ul id="menu-sidebar" class="nav-menu"><li id="menu-item-13" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-ancestor current-menu-parent current_page_parent current_page_ancestor menu-item-13"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/leanback/">Leanback</a><ul class="sub-menu"><li id="menu-item-14" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-14"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/leanback/installation/">Install</a></li><li id="menu-item-15" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-15"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/basic-couchdb-operations/">Basic CouchDB Operations</a></li><li id="menu-item-41" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-41"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-documents-by-key/">Find documents by key</a></li><li id="menu-item-167" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-167"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-document-by-multiple-keys/">Find document by multiple Keys</a></li><li id="menu-item-140" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-140"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/count-documents-by-key/">Count documents by key</a></li><li id="menu-item-175" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-175"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/count-by-multiple-documents/">Count documents by multiple keys</a></li><li id="menu-item-45" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-45"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/design-documents-and-permanent-views/">Working with CouchDB views</a></li><li id="menu-item-67" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-67"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/error-handling/">Error handling</a></li><li id="menu-item-96" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-96"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-configuration/">CouchDB Configuration</a></li><li id="menu-item-102" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-97 current_page_item menu-item-102"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-security/">CouchDB Security</a></li><li id="menu-item-105" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-105"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/setting-the-bind_address-port/">CouchDB Bind_Address & Port</a></li></ul></li><li id="menu-item-142" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-142"><a href="https://github.com/obi-a/leanback/blob/master/Changelog.rdoc">Changes</a></li><li id="menu-item-78" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-78"><a href="https://github.com/obi-a/leanback">Source Code</a></li></ul></div></div></div>
|
177
|
-
|
178
|
-
</div><!-- #primary .aside -->
|
179
|
-
|
180
|
-
|
181
|
-
</div><!-- #container -->
|
182
|
-
|
183
|
-
<div id="footer-container">
|
184
|
-
|
185
|
-
|
186
|
-
<div id="footer">
|
187
|
-
|
188
|
-
<div class="footer-insert"><p class="copyright">Copyright © 2013 <a href="http://obi-akubue.org">obi-akubue.org</a>.</p></div>
|
189
|
-
</div><!-- #footer -->
|
190
|
-
|
191
|
-
|
192
|
-
</div><!-- #footer-container -->
|
193
|
-
|
194
|
-
</div><!-- #body-container -->
|
195
|
-
|
196
|
-
|
197
|
-
<script type="text/javascript">
|
198
|
-
|
199
|
-
var _gaq = _gaq || [];
|
200
|
-
_gaq.push(['_setAccount', 'UA-20190925-6']);
|
201
|
-
_gaq.push(['_trackPageview']);
|
202
|
-
|
203
|
-
(function() {
|
204
|
-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
205
|
-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
206
|
-
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
|
207
|
-
})();
|
208
|
-
</script>
|
209
|
-
|
210
|
-
<a style='color:transparent;position:absolute;left:-99999px;z-index:-99999' href='http://www.wpdownloadmanager.com/' title='Premium Wordpress Plugin download manager'>Premium Wordpress Plugin</a>
|
211
|
-
<script type='text/javascript' src='http://www.whisperservers.com/leanback/wp-content/themes/hybrid/library/js/drop-downs.js?ver=20110705'></script>
|
212
|
-
|
213
|
-
</body>
|
214
|
-
</html>
|
215
|
-
<!-- Dynamic page generated in 0.481 seconds. -->
|
216
|
-
<!-- Cached page generated by WP-Super-Cache on 2013-06-09 16:29:36 -->
|
217
|
-
|
218
|
-
<!-- super cache -->
|