Module: Conjur::API::Router
Overview
Router translates method arguments to rest-ful API request parameters.
because of this, most of the methods suffer from :reek:LongParameterList:
and :reek:UtilityFunction:
Instance Method Summary
collapse
-
#authentication_providers(account, authenticator, credentials) ⇒ Object
-
#authenticator(account, authenticator, service_id, credentials) ⇒ Object
-
#authenticator_authenticate(account, service_id, authenticator, options) ⇒ Object
-
#authenticators ⇒ Object
-
#authn_authenticate(account, username) ⇒ Object
-
#authn_authenticate_local(username, account, expiration, cidr, &block) ⇒ Object
The authn-local message is a JSON string with account, sub, and optional fields.
-
#authn_azure_authenticate(account, service_id, identity) ⇒ Object
POST /authn-azure/service_id/account/login/authenticate.
-
#authn_cert_authenticate(account, service_id, host_id, cert_options) ⇒ Object
Builds the RestClient::Resource for an authn-cert authentication request.
-
#authn_gcp_authenticate(account) ⇒ Object
POST /authn-gcp/account/authenticate authn-gcp is a serviceless authenticator: Conjur derives the host from the GCP identity token's claims, so neither a service id nor the login appears in the path.
-
#authn_iam_authenticate(account, service_id, identity) ⇒ Object
POST /authn-iam/service_id/account/login/authenticate.
-
#authn_login(account, username, password) ⇒ Object
-
#authn_rotate_api_key(credentials, account, id) ⇒ Object
-
#authn_rotate_own_api_key(account, username, password) ⇒ Object
-
#authn_update_password(account, username, password) ⇒ Object
-
#group_attributes(credentials, resource, id) ⇒ Object
-
#host_factory_create_host(token) ⇒ Object
-
#host_factory_create_tokens(credentials, id) ⇒ Object
-
#host_factory_revoke_token(credentials, token) ⇒ Object
-
#ldap_sync_policy(credentials, config_name) ⇒ Object
-
#parse_group_gidnumber(attributes) ⇒ Object
-
#parse_members(credentials, result) ⇒ Object
-
#parse_user_uidnumber(attributes) ⇒ Object
-
#parse_variable_kind(attributes) ⇒ Object
-
#parse_variable_mime_type(attributes) ⇒ Object
-
#policies_dry_run_policy(credentials, account, id) ⇒ Object
-
#policies_fetch_policy(credentials, account, id, options = {}) ⇒ Object
-
#policies_load_policy(credentials, account, id) ⇒ Object
-
#public_keys_for_user(account, username) ⇒ Object
-
#resources(credentials, account, kind, options) ⇒ Object
-
#resources_check(credentials, id, privilege, role) ⇒ Object
-
#resources_permitted_roles(credentials, id, privilege) ⇒ Object
-
#resources_resource(credentials, id) ⇒ Object
-
#roles_role(credentials, id) ⇒ Object
-
#secrets_add(credentials, id) ⇒ Object
-
#secrets_value(credentials, id, options) ⇒ Object
-
#secrets_values(credentials, variable_ids) ⇒ Object
-
#server_info ⇒ Object
-
#server_root ⇒ Object
-
#user_attributes(credentials, resource, id) ⇒ Object
-
#variable_attributes(credentials, resource, id) ⇒ Object
-
#whoami(credentials) ⇒ Object
fully_escape, path_escape, path_or_query_escape, query_escape
Instance Method Details
#authentication_providers(account, authenticator, credentials) ⇒ Object
109
110
111
112
113
114
|
# File 'lib/conjur/api/router.rb', line 109
def authentication_providers(account, authenticator, credentials)
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)[fully_escape authenticator][fully_escape account]['providers']
end
|
#authenticator(account, authenticator, service_id, credentials) ⇒ Object
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/conjur/api/router.rb', line 91
def authenticator account, authenticator, service_id, credentials
resource = RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)[fully_escape authenticator]
resource = resource[fully_escape service_id] unless service_id.nil? || service_id.empty?
resource[fully_escape account]
end
|
#authenticator_authenticate(account, service_id, authenticator, options) ⇒ Object
84
85
86
87
88
89
|
# File 'lib/conjur/api/router.rb', line 84
def authenticator_authenticate(account, service_id, authenticator, options)
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.rest_client_options
)[fully_escape authenticator][fully_escape service_id][fully_escape account]['authenticate'][options_querystring options]
end
|
#authenticators ⇒ Object
102
103
104
105
106
107
|
# File 'lib/conjur/api/router.rb', line 102
def authenticators
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.rest_client_options
)['authenticators']
end
|
#authn_authenticate(account, username) ⇒ Object
38
39
40
41
42
43
|
# File 'lib/conjur/api/router.rb', line 38
def authn_authenticate account, username
RestClient::Resource.new(
Conjur.configuration.authn_url,
Conjur.configuration.rest_client_options
)[fully_escape account][fully_escape username]['authenticate']
end
|
#authn_authenticate_local(username, account, expiration, cidr, &block) ⇒ Object
The authn-local message is a JSON string with account, sub, and optional fields.
117
118
119
120
121
122
|
# File 'lib/conjur/api/router.rb', line 117
def authn_authenticate_local username, account, expiration, cidr, &block
{ account: account, sub: username }.tap do |params|
params[:exp] = expiration if expiration
params[:cidr] = cidr if cidr
end.to_json
end
|
#authn_azure_authenticate(account, service_id, identity) ⇒ Object
46
47
48
49
50
51
|
# File 'lib/conjur/api/router.rb', line 46
def authn_azure_authenticate account, service_id, identity
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.rest_client_options
)['authn-azure'][fully_escape service_id][fully_escape account][fully_escape identity]['authenticate']
end
|
#authn_cert_authenticate(account, service_id, host_id, cert_options) ⇒ Object
Builds the RestClient::Resource for an authn-cert authentication request.
cert_options must include :ssl_client_cert and :ssl_client_key so that
the client certificate is presented during the TLS handshake.
75
76
77
78
79
80
81
82
|
# File 'lib/conjur/api/router.rb', line 75
def authn_cert_authenticate account, service_id, host_id, cert_options
options = Conjur.configuration.create_rest_client_options(cert_options)
resource = RestClient::Resource.new(
Conjur.configuration.core_url,
options
)['authn-cert'][fully_escape service_id][fully_escape account]
host_id ? resource[fully_escape host_id]['authenticate'] : resource['authenticate']
end
|
#authn_gcp_authenticate(account) ⇒ Object
POST /authn-gcp/account/authenticate
authn-gcp is a serviceless authenticator: Conjur derives the host from
the GCP identity token's claims, so neither a service id nor the login
appears in the path.
65
66
67
68
69
70
|
# File 'lib/conjur/api/router.rb', line 65
def authn_gcp_authenticate account
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.rest_client_options
)['authn-gcp'][fully_escape account]['authenticate']
end
|
#authn_iam_authenticate(account, service_id, identity) ⇒ Object
54
55
56
57
58
59
|
# File 'lib/conjur/api/router.rb', line 54
def authn_iam_authenticate account, service_id, identity
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.rest_client_options
)['authn-iam'][fully_escape service_id][fully_escape account][fully_escape identity]['authenticate']
end
|
#authn_login(account, username, password) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/conjur/api/router.rb', line 28
def authn_login account, username, password
RestClient::Resource.new(
Conjur.configuration.authn_url,
Conjur.configuration.create_rest_client_options(
user: username,
password: password
)
)[fully_escape account]['login']
end
|
#authn_rotate_api_key(credentials, account, id) ⇒ Object
134
135
136
137
138
139
|
# File 'lib/conjur/api/router.rb', line 134
def authn_rotate_api_key credentials, account, id
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)['authn'][fully_escape account]["api_key?role=#{id}"]
end
|
#authn_rotate_own_api_key(account, username, password) ⇒ Object
141
142
143
144
145
146
147
148
149
|
# File 'lib/conjur/api/router.rb', line 141
def authn_rotate_own_api_key account, username, password
RestClient::Resource.new(
Conjur.configuration.authn_url,
Conjur.configuration.create_rest_client_options(
user: username,
password: password
)
)[fully_escape account]['api_key']
end
|
#authn_update_password(account, username, password) ⇒ Object
124
125
126
127
128
129
130
131
132
|
# File 'lib/conjur/api/router.rb', line 124
def authn_update_password account, username, password
RestClient::Resource.new(
Conjur.configuration.authn_url,
Conjur.configuration.create_rest_client_options(
user: username,
password: password
)
)[fully_escape account]['password']
end
|
#group_attributes(credentials, resource, id) ⇒ Object
268
269
270
|
# File 'lib/conjur/api/router.rb', line 268
def group_attributes credentials, resource, id
resource_annotations resource
end
|
#host_factory_create_host(token) ⇒ Object
151
152
153
154
155
156
157
158
159
|
# File 'lib/conjur/api/router.rb', line 151
def host_factory_create_host token
http_options = {
headers: { authorization: %Q(Token token="#{token}") }
}
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(http_options)
)["host_factories"]["hosts"]
end
|
#host_factory_create_tokens(credentials, id) ⇒ Object
161
162
163
164
165
166
|
# File 'lib/conjur/api/router.rb', line 161
def host_factory_create_tokens credentials, id
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)['host_factory_tokens']
end
|
#host_factory_revoke_token(credentials, token) ⇒ Object
168
169
170
171
172
173
|
# File 'lib/conjur/api/router.rb', line 168
def host_factory_revoke_token credentials, token
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)['host_factory_tokens'][token]
end
|
#ldap_sync_policy(credentials, config_name) ⇒ Object
302
303
304
305
306
307
|
# File 'lib/conjur/api/router.rb', line 302
def ldap_sync_policy(credentials, config_name)
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)['ldap-sync']["policy?config_name=#{fully_escape(config_name)}"]
end
|
#parse_group_gidnumber(attributes) ⇒ Object
280
281
282
|
# File 'lib/conjur/api/router.rb', line 280
def parse_group_gidnumber attributes
HasAttributes.annotation_value attributes, 'conjur/gidnumber'
end
|
#parse_members(credentials, result) ⇒ Object
296
297
298
299
300
|
# File 'lib/conjur/api/router.rb', line 296
def parse_members credentials, result
result.map do |json|
RoleGrant.parse_from_json(json, credentials)
end
end
|
#parse_user_uidnumber(attributes) ⇒ Object
284
285
286
|
# File 'lib/conjur/api/router.rb', line 284
def parse_user_uidnumber attributes
HasAttributes.annotation_value attributes, 'conjur/uidnumber'
end
|
#parse_variable_kind(attributes) ⇒ Object
288
289
290
|
# File 'lib/conjur/api/router.rb', line 288
def parse_variable_kind attributes
HasAttributes.annotation_value attributes, 'conjur/kind'
end
|
#parse_variable_mime_type(attributes) ⇒ Object
292
293
294
|
# File 'lib/conjur/api/router.rb', line 292
def parse_variable_mime_type attributes
HasAttributes.annotation_value attributes, 'conjur/mime_type'
end
|
#policies_dry_run_policy(credentials, account, id) ⇒ Object
182
183
184
185
186
187
|
# File 'lib/conjur/api/router.rb', line 182
def policies_dry_run_policy credentials, account, id
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)['policies'][fully_escape account]['policy'][fully_escape id]['?dryRun=true']
end
|
#policies_fetch_policy(credentials, account, id, options = {}) ⇒ Object
189
190
191
192
193
194
|
# File 'lib/conjur/api/router.rb', line 189
def policies_fetch_policy credentials, account, id, options = {}
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)['policies'][fully_escape account]['policy'][fully_escape id][options_querystring options]
end
|
#policies_load_policy(credentials, account, id) ⇒ Object
175
176
177
178
179
180
|
# File 'lib/conjur/api/router.rb', line 175
def policies_load_policy credentials, account, id
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)['policies'][fully_escape account]['policy'][fully_escape id]
end
|
#public_keys_for_user(account, username) ⇒ Object
196
197
198
199
200
201
|
# File 'lib/conjur/api/router.rb', line 196
def public_keys_for_user account, username
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.rest_client_options
)['public_keys'][fully_escape account]['user'][fully_escape username]
end
|
#resources(credentials, account, kind, options) ⇒ Object
203
204
205
206
207
208
209
210
211
212
213
|
# File 'lib/conjur/api/router.rb', line 203
def resources credentials, account, kind, options
credentials ||= {}
path = "/resources/#{fully_escape account}"
path += "/#{fully_escape kind}" if kind
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)[path][options_querystring options]
end
|
#resources_check(credentials, id, privilege, role) ⇒ Object
229
230
231
232
233
234
235
|
# File 'lib/conjur/api/router.rb', line 229
def resources_check credentials, id, privilege, role
options = {}
options[:check] = true
options[:privilege] = privilege
options[:role] = query_escape(Id.new(role)) if role
resources_resource(credentials, id)[options_querystring options].get
end
|
#resources_permitted_roles(credentials, id, privilege) ⇒ Object
222
223
224
225
226
227
|
# File 'lib/conjur/api/router.rb', line 222
def resources_permitted_roles credentials, id, privilege
options = {}
options[:permitted_roles] = true
options[:privilege] = privilege
resources_resource(credentials, id)[options_querystring options]
end
|
#resources_resource(credentials, id) ⇒ Object
215
216
217
218
219
220
|
# File 'lib/conjur/api/router.rb', line 215
def resources_resource credentials, id
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)['resources'][id.to_url_path]
end
|
#roles_role(credentials, id) ⇒ Object
237
238
239
240
241
242
|
# File 'lib/conjur/api/router.rb', line 237
def roles_role credentials, id
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)['roles'][id.to_url_path]
end
|
#secrets_add(credentials, id) ⇒ Object
244
245
246
247
248
249
|
# File 'lib/conjur/api/router.rb', line 244
def secrets_add credentials, id
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)['secrets'][id.to_url_path]
end
|
#secrets_value(credentials, id, options) ⇒ Object
251
252
253
254
255
256
|
# File 'lib/conjur/api/router.rb', line 251
def secrets_value credentials, id, options
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)['secrets'][id.to_url_path][options_querystring options]
end
|
#secrets_values(credentials, variable_ids) ⇒ Object
258
259
260
261
262
263
264
265
266
|
# File 'lib/conjur/api/router.rb', line 258
def secrets_values credentials, variable_ids
options = {
variable_ids: Array(variable_ids).join(',')
}
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)['secrets'][options_querystring(options).gsub("%2C", ',')]
end
|
#server_info ⇒ Object
316
317
318
319
320
321
|
# File 'lib/conjur/api/router.rb', line 316
def server_info
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.rest_client_options
)['info']
end
|
#server_root ⇒ Object
323
324
325
326
327
328
|
# File 'lib/conjur/api/router.rb', line 323
def server_root
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.rest_client_options
)['/']
end
|
#user_attributes(credentials, resource, id) ⇒ Object
276
277
278
|
# File 'lib/conjur/api/router.rb', line 276
def user_attributes credentials, resource, id
resource_annotations resource
end
|
#variable_attributes(credentials, resource, id) ⇒ Object
272
273
274
|
# File 'lib/conjur/api/router.rb', line 272
def variable_attributes credentials, resource, id
resource_annotations resource
end
|
#whoami(credentials) ⇒ Object
309
310
311
312
313
314
|
# File 'lib/conjur/api/router.rb', line 309
def whoami(credentials)
RestClient::Resource.new(
Conjur.configuration.core_url,
Conjur.configuration.create_rest_client_options(credentials)
)['whoami']
end
|