clonk 2.2.6 → 2.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/clonk/connection.rb +1 -1
- data/lib/clonk/permission.rb +18 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93b9278216f88d337974065bf71a3014b5a3a6421f3f614a898a1a7b516f4f8f
|
4
|
+
data.tar.gz: 6b38cf3e001df330e013b47e570fb5d849a883fa8f09570f9fd606f0087c53c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b40ac53d91a5ee56b0d0841edb26286b8ddf6a23b62ad7fa89ad6a9e716ac542bab0d7b593f68bb7c8b2c1a852a791a1dc19ba749b6845a7da8fb1c74d6d2c30
|
7
|
+
data.tar.gz: 6cfb83a42252b21c7275f44e290325d88386d4df4027a5ce07abf4fe7f2219336b72842341e302be21f6d93bd016eca288f9b21317ca3cb635cead056ed3860c
|
data/lib/clonk/connection.rb
CHANGED
@@ -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:
|
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
|
data/lib/clonk/permission.rb
CHANGED
@@ -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
|
-
|
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(
|
18
|
-
|
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.
|
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-
|
11
|
+
date: 2019-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|