clonk 1.0.0alpha6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/clonk.rb +6 -6
- data/lib/clonk/client.rb +11 -4
- data/lib/clonk/group.rb +14 -7
- data/lib/clonk/permission.rb +1 -1
- data/lib/clonk/policy.rb +1 -1
- data/lib/clonk/realm.rb +1 -1
- data/lib/clonk/user.rb +4 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 745227bb1c30916ca73bcb74eb7a6f5b41389e635810b51d04a09dc4fe52d870
|
4
|
+
data.tar.gz: c94c13fed88b877aa0c5c663ed81cdf6df6571e5974399921b0d108836219bfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0813ad9d28ca9d8af7d5fc70c0e8fb40ec0a98068d083b54cb153ae170cdcbb03b95406b962ca8eb820a4f23d2e06d93a8639c42f5690130eb54233b919398e2'
|
7
|
+
data.tar.gz: 2a2393987b54c02da7596651e95587d204d92f9db6b0c54fc2673e738f9bb035fc4d25662641e79dfcbf4595e7fb0b7b32c48c0dfaca771947856d419ffa989e
|
data/lib/clonk.rb
CHANGED
@@ -57,10 +57,10 @@ module Clonk
|
|
57
57
|
# FIXME: Rename protocol to method - more descriptive
|
58
58
|
#++
|
59
59
|
|
60
|
-
def response(
|
61
|
-
return unless %i[get post put delete].include?(
|
60
|
+
def response(method: :get, path: '/', data: nil, token: admin_token)
|
61
|
+
return unless %i[get post put delete].include?(method)
|
62
62
|
|
63
|
-
conn = connection(token: token).public_send(
|
63
|
+
conn = connection(token: token).public_send(method, path, data)
|
64
64
|
end
|
65
65
|
|
66
66
|
##
|
@@ -72,8 +72,8 @@ module Clonk
|
|
72
72
|
# FIXME: Rename protocol to method - more descriptive
|
73
73
|
#++
|
74
74
|
|
75
|
-
def parsed_response(
|
76
|
-
resp = response(
|
75
|
+
def parsed_response(method: :get, path: '/', data: nil, token: admin_token)
|
76
|
+
resp = response(method: method, path: path, data: data, token: token)
|
77
77
|
|
78
78
|
JSON.parse(resp.body)
|
79
79
|
rescue JSON::ParserError
|
@@ -88,7 +88,7 @@ module Clonk
|
|
88
88
|
|
89
89
|
def set_permissions(object: nil, type: nil, enabled: true, realm: REALM)
|
90
90
|
parsed_response(
|
91
|
-
|
91
|
+
method: :put,
|
92
92
|
path: "#{realm_admin_root(realm)}/#{type}s/#{object['id']}/management/permissions",
|
93
93
|
data: { enabled: enabled },
|
94
94
|
token: @token
|
data/lib/clonk/client.rb
CHANGED
@@ -29,7 +29,7 @@ module Clonk
|
|
29
29
|
def self.create(realm: REALM, name: nil, public_client: true, dag_enabled: true)
|
30
30
|
# TODO: Client with a secret
|
31
31
|
response = Clonk.response(
|
32
|
-
|
32
|
+
method: :post,
|
33
33
|
path: "#{Clonk.realm_admin_root(realm)}/clients",
|
34
34
|
data: defaults.merge(
|
35
35
|
clientId: name,
|
@@ -104,7 +104,7 @@ module Clonk
|
|
104
104
|
|
105
105
|
def map_scope(client: nil, role: nil, realm: REALM)
|
106
106
|
Clonk.parsed_response(
|
107
|
-
|
107
|
+
method: :post,
|
108
108
|
data: [role.config],
|
109
109
|
path: "#{url}/scope-mappings/clients/#{client.id}"
|
110
110
|
)
|
@@ -117,7 +117,7 @@ module Clonk
|
|
117
117
|
|
118
118
|
def create_role(realm: REALM, name: nil, description: nil, scope_param_required: false)
|
119
119
|
# TODO: Create realm roles
|
120
|
-
response = Clonk.response(
|
120
|
+
response = Clonk.response(method: :post,
|
121
121
|
path: "#{url}/roles",
|
122
122
|
data: {
|
123
123
|
name: name,
|
@@ -143,7 +143,7 @@ module Clonk
|
|
143
143
|
|
144
144
|
def set_permissions(enabled: true)
|
145
145
|
Clonk.parsed_response(
|
146
|
-
|
146
|
+
method: :put,
|
147
147
|
path: "#{url}/management/permissions",
|
148
148
|
data: {
|
149
149
|
enabled: enabled
|
@@ -159,5 +159,12 @@ module Clonk
|
|
159
159
|
path: "#{url}/client-secret"
|
160
160
|
)['value']
|
161
161
|
end
|
162
|
+
|
163
|
+
def delete
|
164
|
+
Clonk.response(
|
165
|
+
method: :delete,
|
166
|
+
path: url
|
167
|
+
)
|
168
|
+
end
|
162
169
|
end
|
163
170
|
end
|
data/lib/clonk/group.rb
CHANGED
@@ -39,13 +39,13 @@ module Clonk
|
|
39
39
|
def save(realm = REALM)
|
40
40
|
if @id
|
41
41
|
Clonk.parsed_response(
|
42
|
-
|
42
|
+
method: :put,
|
43
43
|
path: "#{Clonk.realm_admin_root(@realm)}/groups/#{@id}",
|
44
44
|
data: config.merge('name' => @name)
|
45
45
|
)
|
46
46
|
else
|
47
47
|
Clonk.response(
|
48
|
-
|
48
|
+
method: :post,
|
49
49
|
path: "#{Clonk.realm_admin_root(realm)}/groups",
|
50
50
|
data: { name: @name }
|
51
51
|
)
|
@@ -54,7 +54,7 @@ module Clonk
|
|
54
54
|
|
55
55
|
def create_subgroup(name: nil)
|
56
56
|
response = Clonk.parsed_response(
|
57
|
-
|
57
|
+
method: :post,
|
58
58
|
path: "#{url}/children",
|
59
59
|
data: { name: name }
|
60
60
|
)
|
@@ -67,7 +67,7 @@ module Clonk
|
|
67
67
|
|
68
68
|
def self.all(realm: REALM, flattened: false)
|
69
69
|
response = Clonk.parsed_response(
|
70
|
-
|
70
|
+
method: :get,
|
71
71
|
path: "#{Clonk.realm_admin_root(realm)}/groups",
|
72
72
|
)
|
73
73
|
response += response.map { |group| group['subGroups'] } if flattened
|
@@ -98,7 +98,7 @@ module Clonk
|
|
98
98
|
def map_role(role: nil)
|
99
99
|
client_path = role.container_id == @realm ? 'realm' : "clients/#{role.container_id}"
|
100
100
|
response = Clonk.parsed_response(
|
101
|
-
|
101
|
+
method: :post,
|
102
102
|
data: [role.config],
|
103
103
|
path: "#{url}/role-mappings/#{client_path}"
|
104
104
|
)
|
@@ -106,7 +106,7 @@ module Clonk
|
|
106
106
|
|
107
107
|
def add_user(user: nil, realm: REALM)
|
108
108
|
Clonk.parsed_response(
|
109
|
-
|
109
|
+
method: :put,
|
110
110
|
path: "#{user.url}/groups/#{@id}",
|
111
111
|
data: {
|
112
112
|
groupId: @id,
|
@@ -118,12 +118,19 @@ module Clonk
|
|
118
118
|
|
119
119
|
def set_permissions(enabled: true)
|
120
120
|
Clonk.parsed_response(
|
121
|
-
|
121
|
+
method: :put,
|
122
122
|
path: "#{url}/management/permissions",
|
123
123
|
data: {
|
124
124
|
enabled: enabled
|
125
125
|
}
|
126
126
|
)
|
127
127
|
end
|
128
|
+
|
129
|
+
def delete
|
130
|
+
Clonk.response(
|
131
|
+
method: :delete,
|
132
|
+
path: url
|
133
|
+
)
|
134
|
+
end
|
128
135
|
end
|
129
136
|
end
|
data/lib/clonk/permission.rb
CHANGED
data/lib/clonk/policy.rb
CHANGED
@@ -72,7 +72,7 @@ module Clonk
|
|
72
72
|
data = self.define(type: type, name: name, objects: objects, description: description, groups_claim: groups_claim)
|
73
73
|
realm_management_url = Clonk::Client.find_by(name: 'realm-management', realm: realm).url
|
74
74
|
Clonk.parsed_response(
|
75
|
-
|
75
|
+
method: :post,
|
76
76
|
path: "#{realm_management_url}/authz/resource-server/policy/#{type}",
|
77
77
|
data: data
|
78
78
|
)
|
data/lib/clonk/realm.rb
CHANGED
data/lib/clonk/user.rb
CHANGED
@@ -37,7 +37,7 @@ module Clonk
|
|
37
37
|
# username
|
38
38
|
|
39
39
|
def self.create(realm: REALM, username: nil, enabled: true)
|
40
|
-
response = Clonk.response(
|
40
|
+
response = Clonk.response(method: :post,
|
41
41
|
path: "#{Clonk.realm_admin_root(realm)}/users",
|
42
42
|
data: { username: username, enabled: enabled }
|
43
43
|
)
|
@@ -80,7 +80,7 @@ module Clonk
|
|
80
80
|
def map_role(role: nil)
|
81
81
|
client_path = role.container_id == @realm ? 'realm' : "clients/#{role.container_id}"
|
82
82
|
response = Clonk.parsed_response(
|
83
|
-
|
83
|
+
method: :post,
|
84
84
|
data: [role.config],
|
85
85
|
path: "#{url}/role-mappings/#{client_path}"
|
86
86
|
)
|
@@ -94,7 +94,7 @@ module Clonk
|
|
94
94
|
|
95
95
|
def set_password(password: nil, temporary: false)
|
96
96
|
Clonk.parsed_response(
|
97
|
-
|
97
|
+
method: :put,
|
98
98
|
data: {
|
99
99
|
type: 'password',
|
100
100
|
value: password,
|
@@ -106,7 +106,7 @@ module Clonk
|
|
106
106
|
|
107
107
|
def delete
|
108
108
|
Clonk.response(
|
109
|
-
|
109
|
+
method: :delete,
|
110
110
|
path: url
|
111
111
|
)
|
112
112
|
end
|
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: 1.0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Fish
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -81,9 +81,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
81
|
version: '0'
|
82
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
|
-
- - "
|
84
|
+
- - ">="
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
86
|
+
version: '0'
|
87
87
|
requirements: []
|
88
88
|
rubyforge_project:
|
89
89
|
rubygems_version: 2.7.7
|