authress-sdk 0.1.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/swagger_client.rb +30 -0
- data/lib/swagger_client/api/access_records_api.rb +541 -0
- data/lib/swagger_client/api/accounts_api.rb +232 -0
- data/lib/swagger_client/api/metadata_api.rb +152 -0
- data/lib/swagger_client/api/resource_permissions_api.rb +250 -0
- data/lib/swagger_client/api/roles_api.rb +252 -0
- data/lib/swagger_client/api/service_clients_api.rb +418 -0
- data/lib/swagger_client/api/user_permissions_api.rb +340 -0
- data/lib/swagger_client/api_client.rb +388 -0
- data/lib/swagger_client/api_error.rb +57 -0
- data/lib/swagger_client/configuration.rb +205 -0
- data/lib/swagger_client/models/access_record.rb +351 -0
- data/lib/swagger_client/models/access_record_collection.rb +229 -0
- data/lib/swagger_client/models/access_record_collection_records.rb +351 -0
- data/lib/swagger_client/models/account.rb +268 -0
- data/lib/swagger_client/models/account_collection.rb +211 -0
- data/lib/swagger_client/models/account_collection_accounts.rb +268 -0
- data/lib/swagger_client/models/body.rb +236 -0
- data/lib/swagger_client/models/body_1.rb +229 -0
- data/lib/swagger_client/models/body_10.rb +246 -0
- data/lib/swagger_client/models/body_11.rb +246 -0
- data/lib/swagger_client/models/body_2.rb +213 -0
- data/lib/swagger_client/models/body_3.rb +351 -0
- data/lib/swagger_client/models/body_4.rb +351 -0
- data/lib/swagger_client/models/body_5.rb +225 -0
- data/lib/swagger_client/models/body_6.rb +255 -0
- data/lib/swagger_client/models/body_7.rb +255 -0
- data/lib/swagger_client/models/body_8.rb +227 -0
- data/lib/swagger_client/models/body_9.rb +223 -0
- data/lib/swagger_client/models/claim_request.rb +227 -0
- data/lib/swagger_client/models/claim_response.rb +197 -0
- data/lib/swagger_client/models/client.rb +246 -0
- data/lib/swagger_client/models/client_access_key.rb +242 -0
- data/lib/swagger_client/models/client_collection.rb +229 -0
- data/lib/swagger_client/models/client_collection_clients.rb +246 -0
- data/lib/swagger_client/models/identity.rb +228 -0
- data/lib/swagger_client/models/identity_collection.rb +213 -0
- data/lib/swagger_client/models/identity_collection_identities.rb +228 -0
- data/lib/swagger_client/models/identity_request.rb +223 -0
- data/lib/swagger_client/models/inline_response_200.rb +247 -0
- data/lib/swagger_client/models/inline_response_200_1.rb +236 -0
- data/lib/swagger_client/models/inline_response_200_10.rb +255 -0
- data/lib/swagger_client/models/inline_response_200_11.rb +211 -0
- data/lib/swagger_client/models/inline_response_200_12.rb +213 -0
- data/lib/swagger_client/models/inline_response_200_13.rb +229 -0
- data/lib/swagger_client/models/inline_response_200_14.rb +246 -0
- data/lib/swagger_client/models/inline_response_200_15.rb +242 -0
- data/lib/swagger_client/models/inline_response_200_2.rb +238 -0
- data/lib/swagger_client/models/inline_response_200_3.rb +260 -0
- data/lib/swagger_client/models/inline_response_200_4.rb +228 -0
- data/lib/swagger_client/models/inline_response_200_5.rb +213 -0
- data/lib/swagger_client/models/inline_response_200_6.rb +229 -0
- data/lib/swagger_client/models/inline_response_200_7.rb +229 -0
- data/lib/swagger_client/models/inline_response_200_8.rb +351 -0
- data/lib/swagger_client/models/inline_response_200_9.rb +268 -0
- data/lib/swagger_client/models/invite.rb +225 -0
- data/lib/swagger_client/models/link.rb +223 -0
- data/lib/swagger_client/models/metadata_object.rb +236 -0
- data/lib/swagger_client/models/permission_object.rb +258 -0
- data/lib/swagger_client/models/permission_response.rb +238 -0
- data/lib/swagger_client/models/resource_permission.rb +213 -0
- data/lib/swagger_client/models/resource_permission_collection.rb +228 -0
- data/lib/swagger_client/models/resource_permission_collection_links.rb +220 -0
- data/lib/swagger_client/models/resource_permission_collection_links_next.rb +223 -0
- data/lib/swagger_client/models/resource_permission_collection_resources.rb +213 -0
- data/lib/swagger_client/models/resource_users_collection.rb +229 -0
- data/lib/swagger_client/models/role.rb +255 -0
- data/lib/swagger_client/models/statement.rb +229 -0
- data/lib/swagger_client/models/token_request.rb +229 -0
- data/lib/swagger_client/models/user.rb +212 -0
- data/lib/swagger_client/models/user_resources.rb +247 -0
- data/lib/swagger_client/models/user_resources_resources.rb +207 -0
- data/lib/swagger_client/models/user_token.rb +260 -0
- data/lib/swagger_client/models/user_token_links.rb +211 -0
- data/lib/swagger_client/models/user_token_links_self.rb +223 -0
- data/lib/swagger_client/models/v1clients_options.rb +218 -0
- data/lib/swagger_client/models/v1records_account.rb +211 -0
- data/lib/swagger_client/models/v1records_links.rb +211 -0
- data/lib/swagger_client/models/v1records_links_self.rb +223 -0
- data/lib/swagger_client/models/v1records_users.rb +212 -0
- data/lib/swagger_client/models/v1resourcesresource_uri_permissions.rb +259 -0
- data/lib/swagger_client/models/v1roles_permissions.rb +258 -0
- data/lib/swagger_client/models/v1usersuser_idresourcesresource_urimetadata_account.rb +206 -0
- data/lib/swagger_client/models/v1usersuser_idtokens_resources.rb +212 -0
- data/lib/swagger_client/models/v1usersuser_idtokens_statements.rb +229 -0
- data/lib/swagger_client/version.rb +14 -0
- metadata +313 -0
metadata
ADDED
@@ -0,0 +1,313 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: authress-sdk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.18.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rhosys
|
8
|
+
- Authress
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2020-12-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: typhoeus
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.0'
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.1
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - "~>"
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '1.0'
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.1
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: json
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.1'
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.1.0
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - "~>"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '2.1'
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.1.0
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: rspec
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.6'
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 3.6.0
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '3.6'
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 3.6.0
|
74
|
+
description: |-
|
75
|
+
# authress-sdk.rb
|
76
|
+
This is the Authress SDK used to integrate with the authorization as a service provider Authress at https://authress.io.
|
77
|
+
|
78
|
+
[![Gem Version](https://badge.fury.io/rb/authress-sdk.svg)](http://badge.fury.io/rb/authress-sdk)
|
79
|
+
|
80
|
+
|
81
|
+
## Usage
|
82
|
+
|
83
|
+
```sh
|
84
|
+
gem install authress-sdk
|
85
|
+
```
|
86
|
+
|
87
|
+
Then required the package:
|
88
|
+
```rb
|
89
|
+
require 'authress-sdk';
|
90
|
+
```
|
91
|
+
|
92
|
+
## Getting started examples
|
93
|
+
|
94
|
+
### Authorize using a user token
|
95
|
+
```rb
|
96
|
+
require 'authress-sdk';
|
97
|
+
|
98
|
+
# create an instance of the API class during service initialization
|
99
|
+
# Replace DOMAIN with the Authress domain for your account
|
100
|
+
AuthressClient.configure do |config|
|
101
|
+
config.base_url = 'https://DOMAIN.api-REGION.authress.io'
|
102
|
+
end
|
103
|
+
|
104
|
+
# on api route
|
105
|
+
[route('/resources/<resourceId>')]
|
106
|
+
function getResource(resourceId) {
|
107
|
+
# Get the user token and pass it to authress
|
108
|
+
authorizationToken = request.headers.get('authorization');
|
109
|
+
AuthressClient.setToken(authorizationToken);
|
110
|
+
|
111
|
+
# Check Authress to authorize the user
|
112
|
+
user_id = 'user_id_example' # String | The user to check permissions on
|
113
|
+
resource_uri = `resources/${resourceId}` # String | The uri path of a resource to validate, must be URL encoded, uri segments are allowed, the resource must be a full path, and permissions are not inherited by sub-resources.
|
114
|
+
permission = 'READ' # String | Permission to check, '*' and scoped permissions can also be checked here.
|
115
|
+
begin
|
116
|
+
#Check to see if a user has permissions to a resource.
|
117
|
+
api_instance = SwaggerClient::UserPermissionsApi.new
|
118
|
+
api_instance.authorize_user(user_id, resource_uri, permission)
|
119
|
+
rescue SwaggerClient::ApiError => e
|
120
|
+
# Will throw except if the user is not authorized to read the resource
|
121
|
+
if (e.status === 404) {
|
122
|
+
return { statusCode: 404 };
|
123
|
+
}
|
124
|
+
puts "Exception when calling UserPermissionsApi->authorize_user: #{e}"
|
125
|
+
throw e;
|
126
|
+
end
|
127
|
+
|
128
|
+
# On success, continue with the route code to load resource and return it
|
129
|
+
return { resource: {}, statusCode: 200 };
|
130
|
+
```
|
131
|
+
|
132
|
+
### Authorize with a service client
|
133
|
+
```rb
|
134
|
+
require 'authress-sdk';
|
135
|
+
|
136
|
+
# create an instance of the API class during service initialization
|
137
|
+
# Replace DOMAIN with the Authress domain for your account
|
138
|
+
|
139
|
+
# Create a service client in the Authress management portal and past the access token here
|
140
|
+
# This will generate a token automatically instead of passing the user token to the api
|
141
|
+
AuthressClient.configure do |config|
|
142
|
+
config.base_url = 'https://DOMAIN.api-REGION.authress.io'
|
143
|
+
accessToken = 'eyJrZXlJ....';
|
144
|
+
config.token_provider = ServiceClientTokenProvider.new(accessToken)
|
145
|
+
end
|
146
|
+
|
147
|
+
# on api route
|
148
|
+
[route('/resources/<resourceId>')]
|
149
|
+
function getResource(resourceId) {
|
150
|
+
# Check Authress to authorize the user
|
151
|
+
user_id = 'user_id_example' # String | The user to check permissions on
|
152
|
+
resource_uri = `resources/${resourceId}` # String | The uri path of a resource to validate, must be URL encoded, uri segments are allowed, the resource must be a full path, and permissions are not inherited by sub-resources.
|
153
|
+
permission = 'READ' # String | Permission to check, '*' and scoped permissions can also be checked here.
|
154
|
+
begin
|
155
|
+
#Check to see if a user has permissions to a resource.
|
156
|
+
api_instance = SwaggerClient::UserPermissionsApi.new
|
157
|
+
api_instance.authorize_user(user_id, resource_uri, permission)
|
158
|
+
rescue SwaggerClient::ApiError => e
|
159
|
+
# Will throw except if the user is not authorized to read the resource
|
160
|
+
if (e.status === 404) {
|
161
|
+
return { statusCode: 404 };
|
162
|
+
}
|
163
|
+
puts "Exception when calling UserPermissionsApi->authorize_user: #{e}"
|
164
|
+
throw e;
|
165
|
+
end
|
166
|
+
|
167
|
+
# On success, continue with the route code to load resource and return it
|
168
|
+
return { resource: {}, statusCode: 200 };
|
169
|
+
```
|
170
|
+
|
171
|
+
### Creating resources
|
172
|
+
When a user creates a resource in your application, we want to ensure that they get access own that resource.
|
173
|
+
|
174
|
+
You may receive **User does not have sufficient access to grant permissions to resources** as an error along with the status code **403**. This means that the service client or user jwt does not have access to create the access record. If using a service client, go to the Authress portal and create a one time record which grants the service client `Authress:Owner` to `Resources/` so that it can manage access records for these types of resources.
|
175
|
+
|
176
|
+
```rb
|
177
|
+
require 'authress-sdk';
|
178
|
+
|
179
|
+
begin
|
180
|
+
#Create a new access record.
|
181
|
+
new_record = SwaggerClient::Body3.new {
|
182
|
+
name: `Access To New Resource ${NewResourceId}`,
|
183
|
+
users: [{ userId: requestUserId }],
|
184
|
+
statements: [{
|
185
|
+
resources: [{ resourceUri: `Resources/${NewResourceId}` }],
|
186
|
+
# Owner by default gives full control over this new resource, including the ability to grant others access as well.
|
187
|
+
roles: ['Authress:Owner']
|
188
|
+
}]
|
189
|
+
};
|
190
|
+
api_instance = SwaggerClient::AccessRecordsApi.new
|
191
|
+
result = api_instance.create_record(new_record)
|
192
|
+
puts result
|
193
|
+
rescue SwaggerClient::ApiError => e
|
194
|
+
puts "Exception when calling AccessRecordsApi->create_record: #{e}"
|
195
|
+
end
|
196
|
+
```
|
197
|
+
email:
|
198
|
+
- support@authress.io
|
199
|
+
executables: []
|
200
|
+
extensions: []
|
201
|
+
extra_rdoc_files: []
|
202
|
+
files:
|
203
|
+
- lib/swagger_client.rb
|
204
|
+
- lib/swagger_client/api/access_records_api.rb
|
205
|
+
- lib/swagger_client/api/accounts_api.rb
|
206
|
+
- lib/swagger_client/api/metadata_api.rb
|
207
|
+
- lib/swagger_client/api/resource_permissions_api.rb
|
208
|
+
- lib/swagger_client/api/roles_api.rb
|
209
|
+
- lib/swagger_client/api/service_clients_api.rb
|
210
|
+
- lib/swagger_client/api/user_permissions_api.rb
|
211
|
+
- lib/swagger_client/api_client.rb
|
212
|
+
- lib/swagger_client/api_error.rb
|
213
|
+
- lib/swagger_client/configuration.rb
|
214
|
+
- lib/swagger_client/models/access_record.rb
|
215
|
+
- lib/swagger_client/models/access_record_collection.rb
|
216
|
+
- lib/swagger_client/models/access_record_collection_records.rb
|
217
|
+
- lib/swagger_client/models/account.rb
|
218
|
+
- lib/swagger_client/models/account_collection.rb
|
219
|
+
- lib/swagger_client/models/account_collection_accounts.rb
|
220
|
+
- lib/swagger_client/models/body.rb
|
221
|
+
- lib/swagger_client/models/body_1.rb
|
222
|
+
- lib/swagger_client/models/body_10.rb
|
223
|
+
- lib/swagger_client/models/body_11.rb
|
224
|
+
- lib/swagger_client/models/body_2.rb
|
225
|
+
- lib/swagger_client/models/body_3.rb
|
226
|
+
- lib/swagger_client/models/body_4.rb
|
227
|
+
- lib/swagger_client/models/body_5.rb
|
228
|
+
- lib/swagger_client/models/body_6.rb
|
229
|
+
- lib/swagger_client/models/body_7.rb
|
230
|
+
- lib/swagger_client/models/body_8.rb
|
231
|
+
- lib/swagger_client/models/body_9.rb
|
232
|
+
- lib/swagger_client/models/claim_request.rb
|
233
|
+
- lib/swagger_client/models/claim_response.rb
|
234
|
+
- lib/swagger_client/models/client.rb
|
235
|
+
- lib/swagger_client/models/client_access_key.rb
|
236
|
+
- lib/swagger_client/models/client_collection.rb
|
237
|
+
- lib/swagger_client/models/client_collection_clients.rb
|
238
|
+
- lib/swagger_client/models/identity.rb
|
239
|
+
- lib/swagger_client/models/identity_collection.rb
|
240
|
+
- lib/swagger_client/models/identity_collection_identities.rb
|
241
|
+
- lib/swagger_client/models/identity_request.rb
|
242
|
+
- lib/swagger_client/models/inline_response_200.rb
|
243
|
+
- lib/swagger_client/models/inline_response_200_1.rb
|
244
|
+
- lib/swagger_client/models/inline_response_200_10.rb
|
245
|
+
- lib/swagger_client/models/inline_response_200_11.rb
|
246
|
+
- lib/swagger_client/models/inline_response_200_12.rb
|
247
|
+
- lib/swagger_client/models/inline_response_200_13.rb
|
248
|
+
- lib/swagger_client/models/inline_response_200_14.rb
|
249
|
+
- lib/swagger_client/models/inline_response_200_15.rb
|
250
|
+
- lib/swagger_client/models/inline_response_200_2.rb
|
251
|
+
- lib/swagger_client/models/inline_response_200_3.rb
|
252
|
+
- lib/swagger_client/models/inline_response_200_4.rb
|
253
|
+
- lib/swagger_client/models/inline_response_200_5.rb
|
254
|
+
- lib/swagger_client/models/inline_response_200_6.rb
|
255
|
+
- lib/swagger_client/models/inline_response_200_7.rb
|
256
|
+
- lib/swagger_client/models/inline_response_200_8.rb
|
257
|
+
- lib/swagger_client/models/inline_response_200_9.rb
|
258
|
+
- lib/swagger_client/models/invite.rb
|
259
|
+
- lib/swagger_client/models/link.rb
|
260
|
+
- lib/swagger_client/models/metadata_object.rb
|
261
|
+
- lib/swagger_client/models/permission_object.rb
|
262
|
+
- lib/swagger_client/models/permission_response.rb
|
263
|
+
- lib/swagger_client/models/resource_permission.rb
|
264
|
+
- lib/swagger_client/models/resource_permission_collection.rb
|
265
|
+
- lib/swagger_client/models/resource_permission_collection_links.rb
|
266
|
+
- lib/swagger_client/models/resource_permission_collection_links_next.rb
|
267
|
+
- lib/swagger_client/models/resource_permission_collection_resources.rb
|
268
|
+
- lib/swagger_client/models/resource_users_collection.rb
|
269
|
+
- lib/swagger_client/models/role.rb
|
270
|
+
- lib/swagger_client/models/statement.rb
|
271
|
+
- lib/swagger_client/models/token_request.rb
|
272
|
+
- lib/swagger_client/models/user.rb
|
273
|
+
- lib/swagger_client/models/user_resources.rb
|
274
|
+
- lib/swagger_client/models/user_resources_resources.rb
|
275
|
+
- lib/swagger_client/models/user_token.rb
|
276
|
+
- lib/swagger_client/models/user_token_links.rb
|
277
|
+
- lib/swagger_client/models/user_token_links_self.rb
|
278
|
+
- lib/swagger_client/models/v1clients_options.rb
|
279
|
+
- lib/swagger_client/models/v1records_account.rb
|
280
|
+
- lib/swagger_client/models/v1records_links.rb
|
281
|
+
- lib/swagger_client/models/v1records_links_self.rb
|
282
|
+
- lib/swagger_client/models/v1records_users.rb
|
283
|
+
- lib/swagger_client/models/v1resourcesresource_uri_permissions.rb
|
284
|
+
- lib/swagger_client/models/v1roles_permissions.rb
|
285
|
+
- lib/swagger_client/models/v1usersuser_idresourcesresource_urimetadata_account.rb
|
286
|
+
- lib/swagger_client/models/v1usersuser_idtokens_resources.rb
|
287
|
+
- lib/swagger_client/models/v1usersuser_idtokens_statements.rb
|
288
|
+
- lib/swagger_client/version.rb
|
289
|
+
homepage: https://authress.io
|
290
|
+
licenses:
|
291
|
+
- Apache-2.0
|
292
|
+
metadata: {}
|
293
|
+
post_install_message:
|
294
|
+
rdoc_options: []
|
295
|
+
require_paths:
|
296
|
+
- lib
|
297
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
298
|
+
requirements:
|
299
|
+
- - ">="
|
300
|
+
- !ruby/object:Gem::Version
|
301
|
+
version: '2.0'
|
302
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
303
|
+
requirements:
|
304
|
+
- - ">="
|
305
|
+
- !ruby/object:Gem::Version
|
306
|
+
version: '0'
|
307
|
+
requirements: []
|
308
|
+
rubygems_version: 3.1.4
|
309
|
+
signing_key:
|
310
|
+
specification_version: 4
|
311
|
+
summary: The Authress SDK for Ruby provides authorization as a service with fully
|
312
|
+
compatible REST apis to integrate with Authress at https://authress.io.
|
313
|
+
test_files: []
|