authress-sdk 0.1.20.0 → 1.0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +36 -32
  3. data/lib/authress_sdk.rb +18 -0
  4. data/lib/{swagger_client → authress_sdk}/api/access_records_api.rb +73 -80
  5. data/lib/{swagger_client → authress_sdk}/api/accounts_api.rb +31 -38
  6. data/lib/{swagger_client → authress_sdk}/api/metadata_api.rb +23 -30
  7. data/lib/{swagger_client → authress_sdk}/api/resource_permissions_api.rb +33 -40
  8. data/lib/{swagger_client → authress_sdk}/api/roles_api.rb +36 -43
  9. data/lib/{swagger_client → authress_sdk}/api/service_clients_api.rb +56 -63
  10. data/lib/{swagger_client → authress_sdk}/api/user_permissions_api.rb +44 -51
  11. data/lib/authress_sdk/api_error.rb +50 -0
  12. data/lib/{swagger_client/api_client.rb → authress_sdk/authress_client.rb} +36 -110
  13. data/lib/authress_sdk/constant_token_provider.rb +19 -0
  14. data/lib/{swagger_client → authress_sdk}/models/access_record.rb +4 -11
  15. data/lib/{swagger_client → authress_sdk}/models/access_record_collection.rb +4 -11
  16. data/lib/{swagger_client → authress_sdk}/models/access_record_collection_records.rb +4 -11
  17. data/lib/{swagger_client → authress_sdk}/models/account.rb +4 -11
  18. data/lib/{swagger_client/models/inline_response_200_11.rb → authress_sdk/models/account_collection.rb} +5 -12
  19. data/lib/{swagger_client → authress_sdk}/models/account_collection_accounts.rb +4 -11
  20. data/lib/{swagger_client → authress_sdk}/models/body.rb +4 -11
  21. data/lib/{swagger_client → authress_sdk}/models/body_1.rb +4 -11
  22. data/lib/{swagger_client → authress_sdk}/models/body_10.rb +4 -11
  23. data/lib/{swagger_client → authress_sdk}/models/body_11.rb +4 -11
  24. data/lib/{swagger_client → authress_sdk}/models/body_2.rb +4 -11
  25. data/lib/{swagger_client → authress_sdk}/models/body_3.rb +4 -11
  26. data/lib/{swagger_client → authress_sdk}/models/body_4.rb +4 -11
  27. data/lib/{swagger_client → authress_sdk}/models/body_5.rb +4 -11
  28. data/lib/{swagger_client → authress_sdk}/models/body_6.rb +4 -11
  29. data/lib/{swagger_client → authress_sdk}/models/body_7.rb +4 -11
  30. data/lib/{swagger_client → authress_sdk}/models/body_8.rb +4 -11
  31. data/lib/{swagger_client → authress_sdk}/models/body_9.rb +4 -11
  32. data/lib/{swagger_client → authress_sdk}/models/claim_request.rb +4 -11
  33. data/lib/{swagger_client → authress_sdk}/models/claim_response.rb +4 -11
  34. data/lib/{swagger_client → authress_sdk}/models/client.rb +4 -11
  35. data/lib/{swagger_client → authress_sdk}/models/client_access_key.rb +4 -11
  36. data/lib/{swagger_client → authress_sdk}/models/client_collection.rb +4 -11
  37. data/lib/{swagger_client → authress_sdk}/models/client_collection_clients.rb +4 -11
  38. data/lib/{swagger_client → authress_sdk}/models/identity.rb +4 -11
  39. data/lib/{swagger_client → authress_sdk}/models/identity_collection.rb +4 -11
  40. data/lib/{swagger_client → authress_sdk}/models/identity_collection_identities.rb +4 -11
  41. data/lib/{swagger_client → authress_sdk}/models/identity_request.rb +4 -11
  42. data/lib/{swagger_client → authress_sdk}/models/inline_response_200.rb +4 -11
  43. data/lib/{swagger_client → authress_sdk}/models/inline_response_200_1.rb +4 -11
  44. data/lib/{swagger_client → authress_sdk}/models/inline_response_200_10.rb +4 -11
  45. data/lib/{swagger_client/models/account_collection.rb → authress_sdk/models/inline_response_200_11.rb} +5 -12
  46. data/lib/{swagger_client → authress_sdk}/models/inline_response_200_12.rb +4 -11
  47. data/lib/{swagger_client → authress_sdk}/models/inline_response_200_13.rb +4 -11
  48. data/lib/{swagger_client → authress_sdk}/models/inline_response_200_14.rb +4 -11
  49. data/lib/{swagger_client → authress_sdk}/models/inline_response_200_15.rb +4 -11
  50. data/lib/{swagger_client → authress_sdk}/models/inline_response_200_2.rb +4 -11
  51. data/lib/{swagger_client → authress_sdk}/models/inline_response_200_3.rb +4 -11
  52. data/lib/{swagger_client → authress_sdk}/models/inline_response_200_4.rb +4 -11
  53. data/lib/{swagger_client → authress_sdk}/models/inline_response_200_5.rb +4 -11
  54. data/lib/{swagger_client → authress_sdk}/models/inline_response_200_6.rb +4 -11
  55. data/lib/{swagger_client → authress_sdk}/models/inline_response_200_7.rb +4 -11
  56. data/lib/{swagger_client → authress_sdk}/models/inline_response_200_8.rb +4 -11
  57. data/lib/{swagger_client → authress_sdk}/models/inline_response_200_9.rb +4 -11
  58. data/lib/{swagger_client → authress_sdk}/models/invite.rb +4 -11
  59. data/lib/{swagger_client → authress_sdk}/models/link.rb +4 -11
  60. data/lib/{swagger_client → authress_sdk}/models/metadata_object.rb +4 -11
  61. data/lib/{swagger_client/models/v1roles_permissions.rb → authress_sdk/models/permission_object.rb} +5 -12
  62. data/lib/{swagger_client → authress_sdk}/models/permission_response.rb +4 -11
  63. data/lib/{swagger_client → authress_sdk}/models/resource_permission.rb +4 -11
  64. data/lib/{swagger_client → authress_sdk}/models/resource_permission_collection.rb +4 -11
  65. data/lib/{swagger_client → authress_sdk}/models/resource_permission_collection_links.rb +4 -11
  66. data/lib/{swagger_client → authress_sdk}/models/resource_permission_collection_links_next.rb +4 -11
  67. data/lib/{swagger_client → authress_sdk}/models/resource_permission_collection_resources.rb +4 -11
  68. data/lib/{swagger_client → authress_sdk}/models/resource_users_collection.rb +4 -11
  69. data/lib/{swagger_client → authress_sdk}/models/role.rb +4 -11
  70. data/lib/{swagger_client → authress_sdk}/models/statement.rb +4 -11
  71. data/lib/{swagger_client → authress_sdk}/models/token_request.rb +4 -11
  72. data/lib/{swagger_client → authress_sdk}/models/user.rb +4 -11
  73. data/lib/{swagger_client → authress_sdk}/models/user_resources.rb +4 -11
  74. data/lib/{swagger_client → authress_sdk}/models/user_resources_resources.rb +4 -11
  75. data/lib/{swagger_client → authress_sdk}/models/user_token.rb +4 -11
  76. data/lib/{swagger_client → authress_sdk}/models/user_token_links.rb +4 -11
  77. data/lib/{swagger_client → authress_sdk}/models/user_token_links_self.rb +4 -11
  78. data/lib/{swagger_client → authress_sdk}/models/v1clients_options.rb +4 -11
  79. data/lib/{swagger_client → authress_sdk}/models/v1records_account.rb +4 -11
  80. data/lib/{swagger_client → authress_sdk}/models/v1records_links.rb +4 -11
  81. data/lib/{swagger_client → authress_sdk}/models/v1records_links_self.rb +4 -11
  82. data/lib/{swagger_client → authress_sdk}/models/v1records_users.rb +4 -11
  83. data/lib/{swagger_client → authress_sdk}/models/v1resourcesresource_uri_permissions.rb +4 -11
  84. data/lib/{swagger_client/models/permission_object.rb → authress_sdk/models/v1roles_permissions.rb} +5 -12
  85. data/lib/{swagger_client → authress_sdk}/models/v1usersuser_idresourcesresource_urimetadata_account.rb +4 -11
  86. data/lib/{swagger_client → authress_sdk}/models/v1usersuser_idtokens_resources.rb +4 -11
  87. data/lib/{swagger_client → authress_sdk}/models/v1usersuser_idtokens_statements.rb +4 -11
  88. data/lib/authress_sdk/service_client_token_provider.rb +18 -0
  89. metadata +87 -87
  90. data/lib/swagger_client.rb +0 -30
  91. data/lib/swagger_client/api_error.rb +0 -57
  92. data/lib/swagger_client/configuration.rb +0 -205
  93. data/lib/swagger_client/version.rb +0 -14
@@ -1,20 +1,13 @@
1
1
  =begin
2
- #Authress
3
2
 
4
- #<p> <h2>Authorization</h2> <p>Authorization for Authress is handled one of two different ways. Both mechanisms use oauth2 <i>Bearer</i> tokens.</p> <br> <h4>Identity Provider JWT</h4> <p>Hook up your preferred identity provider directly to Authress. Authress will verify JWTs sourced from that identify provider and allow direct integration with these APIs. Any OIDC JWT provider works, Google, Auth0, Okta, etc... With this mechanism your web app can make direct calls to the permissions API on behalf of your users. <br> <a href=\"https://authress.io/app/#/manage?focus=identity\">Link identity provider</a> </p> <br> <h4>Authress Clients</h4> <p>Regardless of using direct identity provider integration, with the API you can create Authress clients which can call any of the methods on the API. Your users won't be able to directly make API calls, all web app integrations must go through a service which stores the Authress private key. <br> <a href=\"https://authress.io/app/#/manage?focus=clients\">Create Authress service client</a> </p> <br> <h2>Usage</h2> <h4>Billable APIs</h4> <p>Most of the api available is completely free. Use it to populate your roles and configure your account. You'll only be charged for the ones marked as Billable.</p> <p><ul> <li><i class=\"far fa-fw fa-money-bill-alt text-primary\"></i> <span class=\"text-primary\">Billable</span> - <small>These APIs count as calls for your account and will be charged.</small></li> <li><i class=\"fas fa-fw fa-angle-double-right text-secondary\"></i> <span class=\"text-secondary\">Free</span> - <small>These are totally free.</small></li> <li><i class=\"fas fa-fw fa-balance-scale text-secondary\"></i> <span class=\"text-secondary\">Condition</span> - <small>Are conditionally free, see api methods for details.</small></li> </ul></p> <br> <h4>API Access</h4> <p>Access to the following APIs is based on Authress permissions, not the application permissions assigned in Authress to the application services. Each resource is tagged with the required permission <span class=\"badge badge-outline-secondary\">Action: Resource</span> </p>
5
-
6
- OpenAPI spec version: v1
7
- Contact: support@authress.io
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 3.0.23
10
3
  =end
11
4
 
12
- module SwaggerClient
5
+ module AuthressSdk
13
6
  class UserPermissionsApi
14
- attr_accessor :api_client
7
+ attr_accessor :authress_client
15
8
 
16
- def initialize(api_client = ApiClient.default)
17
- @api_client = api_client
9
+ def initialize(authress_client = AuthressClient.default)
10
+ @authress_client = authress_client
18
11
  end
19
12
  # Check to see if a user has permissions to a resource.
20
13
  # <i class=\"far fa-money-bill-alt text-primary\"></i> <span class=\"text-primary\">Billable</span> Does the user have the specified permissions to the resource? <br><span class=\"badge badge-outline-secondary\">READ: Authress:UserPermissions/{userId}</span>
@@ -36,19 +29,19 @@ module SwaggerClient
36
29
  # @param [Hash] opts the optional parameters
37
30
  # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
38
31
  def authorize_user_with_http_info(user_id, resource_uri, permission, opts = {})
39
- if @api_client.config.debugging
40
- @api_client.config.logger.debug 'Calling API: UserPermissionsApi.authorize_user ...'
32
+ if @authress_client.config.debugging
33
+ @authress_client.config.logger.debug 'Calling API: UserPermissionsApi.authorize_user ...'
41
34
  end
42
35
  # verify the required parameter 'user_id' is set
43
- if @api_client.config.client_side_validation && user_id.nil?
36
+ if @authress_client.config.client_side_validation && user_id.nil?
44
37
  fail ArgumentError, "Missing the required parameter 'user_id' when calling UserPermissionsApi.authorize_user"
45
38
  end
46
39
  # verify the required parameter 'resource_uri' is set
47
- if @api_client.config.client_side_validation && resource_uri.nil?
40
+ if @authress_client.config.client_side_validation && resource_uri.nil?
48
41
  fail ArgumentError, "Missing the required parameter 'resource_uri' when calling UserPermissionsApi.authorize_user"
49
42
  end
50
43
  # verify the required parameter 'permission' is set
51
- if @api_client.config.client_side_validation && permission.nil?
44
+ if @authress_client.config.client_side_validation && permission.nil?
52
45
  fail ArgumentError, "Missing the required parameter 'permission' when calling UserPermissionsApi.authorize_user"
53
46
  end
54
47
  # resource path
@@ -69,7 +62,7 @@ module SwaggerClient
69
62
  return_type = opts[:return_type]
70
63
 
71
64
  auth_names = opts[:auth_names] || ['oauth2']
72
- data, status_code, headers = @api_client.call_api(:GET, local_var_path,
65
+ data, status_code, headers = @authress_client.call_api(:GET, local_var_path,
73
66
  :header_params => header_params,
74
67
  :query_params => query_params,
75
68
  :form_params => form_params,
@@ -77,8 +70,8 @@ module SwaggerClient
77
70
  :auth_names => auth_names,
78
71
  :return_type => return_type)
79
72
 
80
- if @api_client.config.debugging
81
- @api_client.config.logger.debug "API called: UserPermissionsApi#authorize_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
73
+ if @authress_client.config.debugging
74
+ @authress_client.config.logger.debug "API called: UserPermissionsApi#authorize_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
82
75
  end
83
76
  return data, status_code, headers
84
77
  end
@@ -100,15 +93,15 @@ module SwaggerClient
100
93
  # @param [Hash] opts the optional parameters
101
94
  # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
102
95
  def disable_user_token_with_http_info(user_id, token_id, opts = {})
103
- if @api_client.config.debugging
104
- @api_client.config.logger.debug 'Calling API: UserPermissionsApi.disable_user_token ...'
96
+ if @authress_client.config.debugging
97
+ @authress_client.config.logger.debug 'Calling API: UserPermissionsApi.disable_user_token ...'
105
98
  end
106
99
  # verify the required parameter 'user_id' is set
107
- if @api_client.config.client_side_validation && user_id.nil?
100
+ if @authress_client.config.client_side_validation && user_id.nil?
108
101
  fail ArgumentError, "Missing the required parameter 'user_id' when calling UserPermissionsApi.disable_user_token"
109
102
  end
110
103
  # verify the required parameter 'token_id' is set
111
- if @api_client.config.client_side_validation && token_id.nil?
104
+ if @authress_client.config.client_side_validation && token_id.nil?
112
105
  fail ArgumentError, "Missing the required parameter 'token_id' when calling UserPermissionsApi.disable_user_token"
113
106
  end
114
107
  # resource path
@@ -129,7 +122,7 @@ module SwaggerClient
129
122
  return_type = opts[:return_type]
130
123
 
131
124
  auth_names = opts[:auth_names] || ['oauth2']
132
- data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
125
+ data, status_code, headers = @authress_client.call_api(:DELETE, local_var_path,
133
126
  :header_params => header_params,
134
127
  :query_params => query_params,
135
128
  :form_params => form_params,
@@ -137,8 +130,8 @@ module SwaggerClient
137
130
  :auth_names => auth_names,
138
131
  :return_type => return_type)
139
132
 
140
- if @api_client.config.debugging
141
- @api_client.config.logger.debug "API called: UserPermissionsApi#disable_user_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
133
+ if @authress_client.config.debugging
134
+ @authress_client.config.logger.debug "API called: UserPermissionsApi#disable_user_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
142
135
  end
143
136
  return data, status_code, headers
144
137
  end
@@ -160,15 +153,15 @@ module SwaggerClient
160
153
  # @param [Hash] opts the optional parameters
161
154
  # @return [Array<(InlineResponse2002, Integer, Hash)>] InlineResponse2002 data, response status code and response headers
162
155
  def get_user_permissions_for_resource_with_http_info(user_id, resource_uri, opts = {})
163
- if @api_client.config.debugging
164
- @api_client.config.logger.debug 'Calling API: UserPermissionsApi.get_user_permissions_for_resource ...'
156
+ if @authress_client.config.debugging
157
+ @authress_client.config.logger.debug 'Calling API: UserPermissionsApi.get_user_permissions_for_resource ...'
165
158
  end
166
159
  # verify the required parameter 'user_id' is set
167
- if @api_client.config.client_side_validation && user_id.nil?
160
+ if @authress_client.config.client_side_validation && user_id.nil?
168
161
  fail ArgumentError, "Missing the required parameter 'user_id' when calling UserPermissionsApi.get_user_permissions_for_resource"
169
162
  end
170
163
  # verify the required parameter 'resource_uri' is set
171
- if @api_client.config.client_side_validation && resource_uri.nil?
164
+ if @authress_client.config.client_side_validation && resource_uri.nil?
172
165
  fail ArgumentError, "Missing the required parameter 'resource_uri' when calling UserPermissionsApi.get_user_permissions_for_resource"
173
166
  end
174
167
  # resource path
@@ -180,7 +173,7 @@ module SwaggerClient
180
173
  # header parameters
181
174
  header_params = opts[:header_params] || {}
182
175
  # HTTP header 'Accept' (if needed)
183
- header_params['Accept'] = @api_client.select_header_accept(['application/links+json'])
176
+ header_params['Accept'] = @authress_client.select_header_accept(['application/links+json'])
184
177
 
185
178
  # form parameters
186
179
  form_params = opts[:form_params] || {}
@@ -191,7 +184,7 @@ module SwaggerClient
191
184
  return_type = opts[:return_type] || 'InlineResponse2002'
192
185
 
193
186
  auth_names = opts[:auth_names] || ['oauth2']
194
- data, status_code, headers = @api_client.call_api(:GET, local_var_path,
187
+ data, status_code, headers = @authress_client.call_api(:GET, local_var_path,
195
188
  :header_params => header_params,
196
189
  :query_params => query_params,
197
190
  :form_params => form_params,
@@ -199,8 +192,8 @@ module SwaggerClient
199
192
  :auth_names => auth_names,
200
193
  :return_type => return_type)
201
194
 
202
- if @api_client.config.debugging
203
- @api_client.config.logger.debug "API called: UserPermissionsApi#get_user_permissions_for_resource\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
195
+ if @authress_client.config.debugging
196
+ @authress_client.config.logger.debug "API called: UserPermissionsApi#get_user_permissions_for_resource\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
204
197
  end
205
198
  return data, status_code, headers
206
199
  end
@@ -228,11 +221,11 @@ module SwaggerClient
228
221
  # @option opts [String] :cursor Continuation cursor for paging (will automatically be set)
229
222
  # @return [Array<(InlineResponse200, Integer, Hash)>] InlineResponse200 data, response status code and response headers
230
223
  def get_user_resources_with_http_info(user_id, opts = {})
231
- if @api_client.config.debugging
232
- @api_client.config.logger.debug 'Calling API: UserPermissionsApi.get_user_resources ...'
224
+ if @authress_client.config.debugging
225
+ @authress_client.config.logger.debug 'Calling API: UserPermissionsApi.get_user_resources ...'
233
226
  end
234
227
  # verify the required parameter 'user_id' is set
235
- if @api_client.config.client_side_validation && user_id.nil?
228
+ if @authress_client.config.client_side_validation && user_id.nil?
236
229
  fail ArgumentError, "Missing the required parameter 'user_id' when calling UserPermissionsApi.get_user_resources"
237
230
  end
238
231
  # resource path
@@ -248,7 +241,7 @@ module SwaggerClient
248
241
  # header parameters
249
242
  header_params = opts[:header_params] || {}
250
243
  # HTTP header 'Accept' (if needed)
251
- header_params['Accept'] = @api_client.select_header_accept(['application/links+json'])
244
+ header_params['Accept'] = @authress_client.select_header_accept(['application/links+json'])
252
245
 
253
246
  # form parameters
254
247
  form_params = opts[:form_params] || {}
@@ -259,7 +252,7 @@ module SwaggerClient
259
252
  return_type = opts[:return_type] || 'InlineResponse200'
260
253
 
261
254
  auth_names = opts[:auth_names] || ['oauth2']
262
- data, status_code, headers = @api_client.call_api(:GET, local_var_path,
255
+ data, status_code, headers = @authress_client.call_api(:GET, local_var_path,
263
256
  :header_params => header_params,
264
257
  :query_params => query_params,
265
258
  :form_params => form_params,
@@ -267,8 +260,8 @@ module SwaggerClient
267
260
  :auth_names => auth_names,
268
261
  :return_type => return_type)
269
262
 
270
- if @api_client.config.debugging
271
- @api_client.config.logger.debug "API called: UserPermissionsApi#get_user_resources\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
263
+ if @authress_client.config.debugging
264
+ @authress_client.config.logger.debug "API called: UserPermissionsApi#get_user_resources\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
272
265
  end
273
266
  return data, status_code, headers
274
267
  end
@@ -290,15 +283,15 @@ module SwaggerClient
290
283
  # @param [Hash] opts the optional parameters
291
284
  # @return [Array<(InlineResponse2003, Integer, Hash)>] InlineResponse2003 data, response status code and response headers
292
285
  def request_user_token_with_http_info(body, user_id, opts = {})
293
- if @api_client.config.debugging
294
- @api_client.config.logger.debug 'Calling API: UserPermissionsApi.request_user_token ...'
286
+ if @authress_client.config.debugging
287
+ @authress_client.config.logger.debug 'Calling API: UserPermissionsApi.request_user_token ...'
295
288
  end
296
289
  # verify the required parameter 'body' is set
297
- if @api_client.config.client_side_validation && body.nil?
290
+ if @authress_client.config.client_side_validation && body.nil?
298
291
  fail ArgumentError, "Missing the required parameter 'body' when calling UserPermissionsApi.request_user_token"
299
292
  end
300
293
  # verify the required parameter 'user_id' is set
301
- if @api_client.config.client_side_validation && user_id.nil?
294
+ if @authress_client.config.client_side_validation && user_id.nil?
302
295
  fail ArgumentError, "Missing the required parameter 'user_id' when calling UserPermissionsApi.request_user_token"
303
296
  end
304
297
  # resource path
@@ -310,20 +303,20 @@ module SwaggerClient
310
303
  # header parameters
311
304
  header_params = opts[:header_params] || {}
312
305
  # HTTP header 'Accept' (if needed)
313
- header_params['Accept'] = @api_client.select_header_accept(['application/links+json'])
306
+ header_params['Accept'] = @authress_client.select_header_accept(['application/links+json'])
314
307
  # HTTP header 'Content-Type'
315
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
308
+ header_params['Content-Type'] = @authress_client.select_header_content_type(['application/json'])
316
309
 
317
310
  # form parameters
318
311
  form_params = opts[:form_params] || {}
319
312
 
320
313
  # http body (model)
321
- post_body = opts[:body] || @api_client.object_to_http_body(body)
314
+ post_body = opts[:body] || @authress_client.object_to_http_body(body)
322
315
 
323
316
  return_type = opts[:return_type] || 'InlineResponse2003'
324
317
 
325
318
  auth_names = opts[:auth_names] || ['oauth2']
326
- data, status_code, headers = @api_client.call_api(:POST, local_var_path,
319
+ data, status_code, headers = @authress_client.call_api(:POST, local_var_path,
327
320
  :header_params => header_params,
328
321
  :query_params => query_params,
329
322
  :form_params => form_params,
@@ -331,8 +324,8 @@ module SwaggerClient
331
324
  :auth_names => auth_names,
332
325
  :return_type => return_type)
333
326
 
334
- if @api_client.config.debugging
335
- @api_client.config.logger.debug "API called: UserPermissionsApi#request_user_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
327
+ if @authress_client.config.debugging
328
+ @authress_client.config.logger.debug "API called: UserPermissionsApi#request_user_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
336
329
  end
337
330
  return data, status_code, headers
338
331
  end
@@ -0,0 +1,50 @@
1
+ =begin
2
+
3
+ =end
4
+
5
+ module AuthressSdk
6
+ class ApiError < StandardError
7
+ attr_reader :code, :response_headers, :response_body
8
+
9
+ # Usage examples:
10
+ # ApiError.new
11
+ # ApiError.new("message")
12
+ # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
13
+ # ApiError.new(:code => 404, :message => "Not Found")
14
+ def initialize(arg = nil)
15
+ if arg.is_a? Hash
16
+ if arg.key?(:message) || arg.key?('message')
17
+ super(arg[:message] || arg['message'])
18
+ else
19
+ super arg
20
+ end
21
+
22
+ arg.each do |k, v|
23
+ instance_variable_set "@#{k}", v
24
+ end
25
+ else
26
+ super arg
27
+ end
28
+ end
29
+
30
+ # Override to_s to display a friendly error message
31
+ def to_s
32
+ message
33
+ end
34
+
35
+ def message
36
+ if @message.nil?
37
+ msg = "Error message: the server returns an error"
38
+ else
39
+ msg = @message
40
+ end
41
+
42
+ msg += "\nHTTP status code: #{code}" if code
43
+ msg += "\nResponse headers: #{response_headers}" if response_headers
44
+ msg += "\nResponse body: #{response_body}" if response_body
45
+
46
+ msg
47
+ end
48
+
49
+ end
50
+ end
@@ -1,12 +1,5 @@
1
1
  =begin
2
- #Authress
3
2
 
4
- #<p> <h2>Authorization</h2> <p>Authorization for Authress is handled one of two different ways. Both mechanisms use oauth2 <i>Bearer</i> tokens.</p> <br> <h4>Identity Provider JWT</h4> <p>Hook up your preferred identity provider directly to Authress. Authress will verify JWTs sourced from that identify provider and allow direct integration with these APIs. Any OIDC JWT provider works, Google, Auth0, Okta, etc... With this mechanism your web app can make direct calls to the permissions API on behalf of your users. <br> <a href=\"https://authress.io/app/#/manage?focus=identity\">Link identity provider</a> </p> <br> <h4>Authress Clients</h4> <p>Regardless of using direct identity provider integration, with the API you can create Authress clients which can call any of the methods on the API. Your users won't be able to directly make API calls, all web app integrations must go through a service which stores the Authress private key. <br> <a href=\"https://authress.io/app/#/manage?focus=clients\">Create Authress service client</a> </p> <br> <h2>Usage</h2> <h4>Billable APIs</h4> <p>Most of the api available is completely free. Use it to populate your roles and configure your account. You'll only be charged for the ones marked as Billable.</p> <p><ul> <li><i class=\"far fa-fw fa-money-bill-alt text-primary\"></i> <span class=\"text-primary\">Billable</span> - <small>These APIs count as calls for your account and will be charged.</small></li> <li><i class=\"fas fa-fw fa-angle-double-right text-secondary\"></i> <span class=\"text-secondary\">Free</span> - <small>These are totally free.</small></li> <li><i class=\"fas fa-fw fa-balance-scale text-secondary\"></i> <span class=\"text-secondary\">Condition</span> - <small>Are conditionally free, see api methods for details.</small></li> </ul></p> <br> <h4>API Access</h4> <p>Access to the following APIs is based on Authress permissions, not the application permissions assigned in Authress to the application services. Each resource is tagged with the required permission <span class=\"badge badge-outline-secondary\">Action: Resource</span> </p>
5
-
6
- OpenAPI spec version: v1
7
- Contact: support@authress.io
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 3.0.23
10
3
  =end
11
4
 
12
5
  require 'date'
@@ -16,29 +9,34 @@ require 'tempfile'
16
9
  require 'typhoeus'
17
10
  require 'uri'
18
11
 
19
- module SwaggerClient
20
- class ApiClient
12
+ module AuthressSdk
13
+ class AuthressClient
21
14
  # The Configuration object holding settings to be used in the API client.
22
15
  attr_accessor :config
23
16
 
24
- # Defines the headers to be used in HTTP requests of all API calls by default.
25
- #
26
- # @return [Hash]
27
- attr_accessor :default_headers
28
-
29
- # Initializes the ApiClient
30
- # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
31
- def initialize(config = Configuration.default)
32
- @config = config
33
- @user_agent = "Swagger-Codegen/#{VERSION}/ruby"
34
- @default_headers = {
35
- 'Content-Type' => 'application/json',
36
- 'User-Agent' => @user_agent
17
+ # The Base URL
18
+ attr_accessor :base_url
19
+
20
+ # Token Provider
21
+ attr_accessor :token_provider
22
+
23
+ # Initializes the AuthressClient
24
+ def initialize()
25
+ @config = {
26
+ :logger => Logger.new(STDOUT),
27
+ :debugging => false,
28
+ :client_side_validation => true
37
29
  }
30
+
31
+ @token_provider = ConstantTokenProvider.new(nil)
38
32
  end
39
33
 
40
34
  def self.default
41
- @@default ||= ApiClient.new
35
+ @@default ||= AuthressClient.new
36
+ end
37
+
38
+ def set_token(token)
39
+ @token_provider = ConstantTokenProvider.new(token)
42
40
  end
43
41
 
44
42
  # Call an API with given options.
@@ -49,10 +47,6 @@ module SwaggerClient
49
47
  request = build_request(http_method, path, opts)
50
48
  response = request.run
51
49
 
52
- if @config.debugging
53
- @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
54
- end
55
-
56
50
  unless response.success?
57
51
  if response.timed_out?
58
52
  fail ApiError.new('Connection timed out')
@@ -89,41 +83,36 @@ module SwaggerClient
89
83
  url = build_request_url(path)
90
84
  http_method = http_method.to_sym.downcase
91
85
 
92
- header_params = @default_headers.merge(opts[:header_params] || {})
86
+ default_headers = {
87
+ 'Content-Type' => 'application/json',
88
+ 'User-Agent' => "Ruby AuthressSDK version: #{Gem.loaded_specs["authress-sdk"].version.to_s}"
89
+ }
90
+ header_params = default_headers.merge(opts[:header_params] || {})
93
91
  query_params = opts[:query_params] || {}
94
92
  form_params = opts[:form_params] || {}
95
93
 
96
- update_params_for_auth! header_params, query_params, opts[:auth_names]
94
+ if !@token_provider.nil?
95
+ header_params['Authorization'] = "Bearer #{@token_provider.get_token()}"
96
+ end
97
97
 
98
98
  # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
99
- _verify_ssl_host = @config.verify_ssl_host ? 2 : 0
99
+ _verify_ssl_host = 2
100
100
 
101
101
  req_opts = {
102
102
  :method => http_method,
103
103
  :headers => header_params,
104
104
  :params => query_params,
105
- :params_encoding => @config.params_encoding,
106
- :timeout => @config.timeout,
107
- :ssl_verifypeer => @config.verify_ssl,
108
- :ssl_verifyhost => _verify_ssl_host,
109
- :sslcert => @config.cert_file,
110
- :sslkey => @config.key_file,
111
- :verbose => @config.debugging
105
+ :ssl_verifypeer => true,
106
+ :ssl_verifyhost => true,
107
+ :verbose => false
112
108
  }
113
109
 
114
- # set custom cert, if provided
115
- req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
116
-
117
- if [:post, :patch, :put, :delete].include?(http_method)
110
+ if [:post, :patch, :put].include?(http_method)
118
111
  req_body = build_request_body(header_params, form_params, opts[:body])
119
112
  req_opts.update :body => req_body
120
- if @config.debugging
121
- @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
122
- end
123
113
  end
124
114
 
125
115
  request = Typhoeus::Request.new(url, req_opts)
126
- download_file(request) if opts[:return_type] == 'File'
127
116
  request
128
117
  end
129
118
 
@@ -237,45 +226,7 @@ module SwaggerClient
237
226
  end
238
227
  else
239
228
  # models, e.g. Pet
240
- SwaggerClient.const_get(return_type).build_from_hash(data)
241
- end
242
- end
243
-
244
- # Save response body into a file in (the defined) temporary folder, using the filename
245
- # from the "Content-Disposition" header if provided, otherwise a random filename.
246
- # The response body is written to the file in chunks in order to handle files which
247
- # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
248
- # process can use.
249
- #
250
- # @see Configuration#temp_folder_path
251
- def download_file(request)
252
- tempfile = nil
253
- encoding = nil
254
- request.on_headers do |response|
255
- content_disposition = response.headers['Content-Disposition']
256
- if content_disposition && content_disposition =~ /filename=/i
257
- filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
258
- prefix = sanitize_filename(filename)
259
- else
260
- prefix = 'download-'
261
- end
262
- prefix = prefix + '-' unless prefix.end_with?('-')
263
- encoding = response.body.encoding
264
- tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
265
- @tempfile = tempfile
266
- end
267
- request.on_body do |chunk|
268
- chunk.force_encoding(encoding)
269
- tempfile.write(chunk)
270
- end
271
- request.on_complete do |response|
272
- if tempfile
273
- tempfile.close
274
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
275
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
276
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
277
- "explicitly with `tempfile.delete`"
278
- end
229
+ AuthressSdk.const_get(return_type).build_from_hash(data)
279
230
  end
280
231
  end
281
232
 
@@ -291,32 +242,7 @@ module SwaggerClient
291
242
  def build_request_url(path)
292
243
  # Add leading and trailing slashes to path
293
244
  path = "/#{path}".gsub(/\/+/, '/')
294
- @config.base_url + path
295
- end
296
-
297
- # Update hearder and query params based on authentication settings.
298
- #
299
- # @param [Hash] header_params Header parameters
300
- # @param [Hash] query_params Query parameters
301
- # @param [String] auth_names Authentication scheme name
302
- def update_params_for_auth!(header_params, query_params, auth_names)
303
- Array(auth_names).each do |auth_name|
304
- auth_setting = @config.auth_settings[auth_name]
305
- next unless auth_setting
306
- case auth_setting[:in]
307
- when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
308
- when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
309
- else fail ArgumentError, 'Authentication token must be in `query` of `header`'
310
- end
311
- end
312
- end
313
-
314
- # Sets user agent in HTTP header
315
- #
316
- # @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
317
- def user_agent=(user_agent)
318
- @user_agent = user_agent
319
- @default_headers['User-Agent'] = @user_agent
245
+ @base_url + path
320
246
  end
321
247
 
322
248
  # Return Accept header based on an array of accepts provided.