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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18bb0551dc1a870d94a8468bb577cf8cf530aab778bac2532b47ee8ca8c7a76e
4
- data.tar.gz: 12e30df4ba3fe00f70bf5b6b4810b96c60d1f3620724c32a87e3d8d4c13a391a
3
+ metadata.gz: 745227bb1c30916ca73bcb74eb7a6f5b41389e635810b51d04a09dc4fe52d870
4
+ data.tar.gz: c94c13fed88b877aa0c5c663ed81cdf6df6571e5974399921b0d108836219bfb
5
5
  SHA512:
6
- metadata.gz: 81f04295a77cc871f1304e83a26ecd0c62e2f3dca965ace7dafe8c4fb071ec5e1ac484f7bcf4ee5736b75a456f6a944d6afef46ff7b3e51f16b2804dbf236d9f
7
- data.tar.gz: 5b445ca32839a45777cb57c1cc5243080b96d49487ddf25a26afab6585cd184b82981ffb783fb35eecac04fc21a56c41e4c3d1eb06a9670f6e426e10f7600bfc
6
+ metadata.gz: '0813ad9d28ca9d8af7d5fc70c0e8fb40ec0a98068d083b54cb153ae170cdcbb03b95406b962ca8eb820a4f23d2e06d93a8639c42f5690130eb54233b919398e2'
7
+ data.tar.gz: 2a2393987b54c02da7596651e95587d204d92f9db6b0c54fc2673e738f9bb035fc4d25662641e79dfcbf4595e7fb0b7b32c48c0dfaca771947856d419ffa989e
@@ -57,10 +57,10 @@ module Clonk
57
57
  # FIXME: Rename protocol to method - more descriptive
58
58
  #++
59
59
 
60
- def response(protocol: :get, path: '/', data: nil, token: admin_token)
61
- return unless %i[get post put delete].include?(protocol)
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(protocol, path, data)
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(protocol: :get, path: '/', data: nil, token: admin_token)
76
- resp = response(protocol: protocol, path: path, data: data, token: token)
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
- protocol: :put,
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
@@ -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
- protocol: :post,
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
- protocol: :post,
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(protocol: :post,
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
- protocol: :put,
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
@@ -39,13 +39,13 @@ module Clonk
39
39
  def save(realm = REALM)
40
40
  if @id
41
41
  Clonk.parsed_response(
42
- protocol: :put,
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
- protocol: :post,
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
- protocol: :post,
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
- protocol: :get,
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
- protocol: :post,
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
- protocol: :put,
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
- protocol: :put,
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
@@ -75,7 +75,7 @@ module Clonk
75
75
  Clonk.parsed_response(
76
76
  path: url,
77
77
  data: data,
78
- protocol: :put
78
+ method: :put
79
79
  )
80
80
  end
81
81
  end
@@ -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
- protocol: :post,
75
+ method: :post,
76
76
  path: "#{realm_management_url}/authz/resource-server/policy/#{type}",
77
77
  data: data
78
78
  )
@@ -8,7 +8,7 @@ module Clonk
8
8
  # Creates a realm with the given name, returning it as a Realm object
9
9
  def self.create(name: nil)
10
10
  Clonk.parsed_response(
11
- protocol: :post,
11
+ method: :post,
12
12
  path: '/auth/admin/realms',
13
13
  data: { id: name, realm: name, enabled: true }
14
14
  )
@@ -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(protocol: :post,
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
- protocol: :post,
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
- protocol: :put,
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
- protocol: :delete,
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.0alpha6
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-23 00:00:00.000000000 Z
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: 1.3.1
86
+ version: '0'
87
87
  requirements: []
88
88
  rubyforge_project:
89
89
  rubygems_version: 2.7.7