pe_rbac 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 858d59d7f1c47371a5f8379f5a9aa271d2ad6078
4
- data.tar.gz: 0f2bd35912191340c9978a0d08547d87bb6dc09b
3
+ metadata.gz: b68ee5976cd98508a5b2c2c05c3812f84079c838
4
+ data.tar.gz: ddb64bdd13aeea1f9ae5f6c248a6b657e1711821
5
5
  SHA512:
6
- metadata.gz: 07a17310e5e1369d72a97eba970a34dd5d33b919eac5a4ae8d9bbca6145ccd5c7692ffc955285a4229aaf00a065f02fd66471e8f56f80ad4299271018eb6d7a1
7
- data.tar.gz: 6ade6201c2003bcab6790d99086dfb4d4519ab9e2d226bc805406f0a246e438115dc7dd37b1ac16f721af0c12d1853acf9e46a03fcd0282610d7e03b4e3e8a82
6
+ metadata.gz: 6bb111f203b9d472937fdec79ed90cdaf4f9cdcd43b1ebe42e8afb8020128c4e5eb45fa75d11b4e3bde3ee6373bd65dd991cdb4c99ef304e2f14a9ec706b6623
7
+ data.tar.gz: 101a4b969b827edd2fa07f1efde04648e81bb98a1e4e2fc3d8d67167021d6821b569d01b14ab87cb83f7e6066d5b9c7980729f78d83e6b3e05208d8fd4149264
data/README.md CHANGED
@@ -43,9 +43,20 @@ pe_rbac puppetdb --password t0ps3cret
43
43
  pe_rbac puppetdb --allow-write --password t0ps3cret
44
44
  ```
45
45
 
46
+ ### Resetting a user password
47
+ ```
48
+ pe_rbac reset_password
49
+ ```
50
+ Change the password for `admin` to `changeme`
51
+
52
+ ```
53
+ pe_rbac reset_password --username foo --password 12345678
54
+ ```
55
+ Reset the password for the `foo` user to `12345678`
56
+
46
57
  ### Ruby API
47
- An *IN FLUX* Ruby API exists, see code for more info. This WILL change (well it
48
- will if I do any more development work on this...) - expect module names,
58
+ An *IN FLUX* Ruby API exists, see code for more info. This WILL change (well it
59
+ will if I do any more development work on this...) - expect module names,
49
60
  functions, etc. to change. In particular, I'm planning:
50
61
  * Sub-modules/file reorgs
51
62
  * tests!
@@ -69,4 +80,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
69
80
  ## License
70
81
 
71
82
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
72
-
data/exe/pe_rbac CHANGED
@@ -20,6 +20,8 @@ Escort::App.create do |app|
20
20
  email = options[:global][:commands][cmd][:options][:email]
21
21
 
22
22
  role_ids = PeRbac::get_role_ids(role)
23
+ # always returns an array even though there should only be one match
24
+ role_data = PeRbac::get_role(role_ids.first)
23
25
 
24
26
  perms = [{
25
27
  "object_type" => "tokens",
@@ -31,7 +33,7 @@ Escort::App.create do |app|
31
33
  PeRbac::update_role(
32
34
  role,
33
35
  nil,
34
- perms,
36
+ PeRbac::merge_permissions(role_data['permissions'], perms)
35
37
  )
36
38
 
37
39
  PeRbac::ensure_user(username, email, username, password, role_ids)
data/lib/pe_rbac.rb CHANGED
@@ -249,6 +249,29 @@ module PeRbac
249
249
  end
250
250
  end
251
251
 
252
+ # return a new array of permissions, adding the permission `ensure` to the
253
+ # existing permissions if required
254
+ def self.merge_permissions(existing, ensure_perms)
255
+ # duplicate existing array of hash
256
+ permissions = existing.map do |e| e.dup end
257
+
258
+ ensure_perms.each { |ensure_perm|
259
+ ensure_perm_exists = false
260
+ existing.each { |existing_perm|
261
+ if existing_perm['object_type'] == ensure_perm['object_type'] and
262
+ existing_perm['action'] == ensure_perm['action'] and
263
+ existing_perm['instance'] == ensure_perm['instance']
264
+ ensure_perm_exists = true
265
+ end
266
+ }
267
+ if ! ensure_perm_exists
268
+ permissions.push(ensure_perm)
269
+ end
270
+ }
271
+
272
+ permissions
273
+ end
274
+
252
275
  private
253
276
 
254
277
  def self._request(method, path, payload=nil, raw=false)
@@ -1,3 +1,3 @@
1
1
  module PeRbac
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pe_rbac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoff Williams
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-29 00:00:00.000000000 Z
11
+ date: 2017-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,9 +106,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.4.6
109
+ rubygems_version: 2.4.5
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: Ruby API for Puppet Enterprise RBAC
113
113
  test_files: []
114
- has_rdoc: