clonk 2.2.6 → 2.2.7

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
  SHA256:
3
- metadata.gz: 83166e5585bafb0672ed312829a8c9db311630e2bc0f6804ac7674cc2e3d2a3b
4
- data.tar.gz: 0e6f59b3ed9b0058b25bf0d2fdc49f11b62f2092e3dbe5753d108fbd6958149c
3
+ metadata.gz: 93b9278216f88d337974065bf71a3014b5a3a6421f3f614a898a1a7b516f4f8f
4
+ data.tar.gz: 6b38cf3e001df330e013b47e570fb5d849a883fa8f09570f9fd606f0087c53c1
5
5
  SHA512:
6
- metadata.gz: b2f4a73b8009a9e3cea470ae4144928cd7e52af106ca791d3eae34f824a2c886a5bf49dbf1e3a00d21de550a96d0b10727526114b18bb34d5be556cfe27efe3d
7
- data.tar.gz: b223bf0b285b60feec0a664c05dcf452edb41770701f1da95e707522bb3fec0782cb33598b2e20e406b2438b4738d5940b5bbe204c65a1f8600a2702f47f020f
6
+ metadata.gz: b40ac53d91a5ee56b0d0841edb26286b8ddf6a23b62ad7fa89ad6a9e716ac542bab0d7b593f68bb7c8b2c1a852a791a1dc19ba749b6845a7da8fb1c74d6d2c30
7
+ data.tar.gz: 6cfb83a42252b21c7275f44e290325d88386d4df4027a5ce07abf4fe7f2219336b72842341e302be21f6d93bd016eca288f9b21317ca3cb635cead056ed3860c
@@ -107,7 +107,7 @@ module Clonk
107
107
 
108
108
  ##
109
109
  # Defines a Faraday::Connection object linked to the SSO instance.
110
- def connection(raise_error: true, json: true, token: @access_token)
110
+ def connection(raise_error: false, json: true, token: @access_token)
111
111
  Faraday.new(url: @base_url) do |faraday|
112
112
  faraday.request(json ? :json : :url_encoded)
113
113
  faraday.use Faraday::Response::RaiseError if raise_error
@@ -4,6 +4,9 @@ module Clonk
4
4
  # Represents a permission in SSO. Methods on Clonk::Connection can be used to
5
5
  # index its policies, resources and associated scopes
6
6
  class Permission
7
+ attr_reader :id
8
+ attr_reader :name
9
+
7
10
  def initialize(permission_response)
8
11
  @id = permission_response['id']
9
12
  @name = permission_response['name']
@@ -12,11 +15,23 @@ module Clonk
12
15
 
13
16
  # Defines a connection to SSO.
14
17
  class Connection
15
- def permissions
18
+ ##
19
+ # Lists the permissions associated with an object.
20
+ # If an object is not provided, all permissions in the realm-management
21
+ # client are returned.
22
+ def permissions(object: nil)
23
+ # list all permissions from realm-management
16
24
  realm_management = clients.find { |client| client.name == 'realm-management' }
17
- objects(type: 'Permission',
18
- path: "/clients/#{realm_management.id}/authz/resource-server/permission"
25
+ all_permissions = objects(
26
+ type: 'Permission',
27
+ path: "#{url_for(realm_management)}/authz/resource-server/permission".delete_prefix(realm_admin_root)
19
28
  )
29
+ return all_permissions unless object
30
+ # map the scopePermissions hash to a new one with the permission objects
31
+ object_permissions = parsed_response(path: "#{url_for(object)}/management/permissions")
32
+ object_permissions['scopePermissions'].to_h { |name, id|
33
+ [name, all_permissions.find { |permission| permission.id == id }]
34
+ }
20
35
  end
21
36
 
22
37
  ##
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clonk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.6
4
+ version: 2.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Fish
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-10 00:00:00.000000000 Z
11
+ date: 2019-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday