authress-sdk 0.1.19.0 → 0.1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +122 -0
  3. metadata +16 -133
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7181eae557d3464a2626ffa2f35cab55a291392c7e51cb56aeb094f15127b3f2
4
- data.tar.gz: ce4d5eab18ff90687aa34c302408c5de5dad85e97bec8e71f44d8b73c7fb57b9
3
+ metadata.gz: f0f4c75e258a72d3a4c3d0a21fe628d3d43aad9d0faf81c4fc4aa1e4d6b1ee34
4
+ data.tar.gz: f4b603cd98c9c5068fa645a55532a0cc8a19a2934326ce075c7208f75df672c1
5
5
  SHA512:
6
- metadata.gz: 9de5a2e1dc97a754abfd180f517b8d17d7151ce84d8a87f009ba1e0c6291ddba53a9fc6b505576a386f48c2c9e6deee22df9e88d9fab4b3ba5f2d49162be5c1a
7
- data.tar.gz: 6551410fd9d0c61e2049bb00a0f48fd960acadecdabd5a4a7434d28afbfa8f6e94a62f4d754f742d66cc7c8c1f20d374e5bbae15c2bc63e91b7ccfb5b488f384
6
+ metadata.gz: 3e519ce0fc9c3bcb48a307de7e4c5e8347b0f3504c7a6445522db030f5d0f69ded735a54ca864b80022ae8c4c3c566b54fd70316c33227760ddc24fd61186cbc
7
+ data.tar.gz: 9bb5f4552bbca426284fe2c9a498c99b354c4bfd8ac7760cfbab9119bf5d1fa90ee9f54fb2c7e56df69652fc5699d51e4d426ecec6cefa1b0c5f940069866e4a
@@ -0,0 +1,122 @@
1
+ # authress-sdk.rb
2
+ This is the Authress SDK used to integrate with the authorization as a service provider Authress at https://authress.io.
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/authress-sdk.svg)](http://badge.fury.io/rb/authress-sdk)
5
+
6
+
7
+ ## Usage
8
+
9
+ ```sh
10
+ gem install authress-sdk
11
+ ```
12
+
13
+ Then required the package:
14
+ ```rb
15
+ require 'authress-sdk';
16
+ ```
17
+
18
+ ## Getting started examples
19
+
20
+ ### Authorize using a user token
21
+ ```rb
22
+ require 'authress-sdk';
23
+
24
+ # create an instance of the API class during service initialization
25
+ # Replace DOMAIN with the Authress domain for your account
26
+ AuthressClient.configure do |config|
27
+ config.base_url = 'https://DOMAIN.api-REGION.authress.io'
28
+ end
29
+
30
+ # on api route
31
+ [route('/resources/<resourceId>')]
32
+ function getResource(resourceId) {
33
+ # Get the user token and pass it to authress
34
+ authorizationToken = request.headers.get('authorization');
35
+ AuthressClient.setToken(authorizationToken);
36
+
37
+ # Check Authress to authorize the user
38
+ user_id = 'user_id_example' # String | The user to check permissions on
39
+ 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.
40
+ permission = 'READ' # String | Permission to check, '*' and scoped permissions can also be checked here.
41
+ begin
42
+ #Check to see if a user has permissions to a resource.
43
+ api_instance = SwaggerClient::UserPermissionsApi.new
44
+ api_instance.authorize_user(user_id, resource_uri, permission)
45
+ rescue SwaggerClient::ApiError => e
46
+ # Will throw except if the user is not authorized to read the resource
47
+ if (e.status === 404) {
48
+ return { statusCode: 404 };
49
+ }
50
+ puts "Exception when calling UserPermissionsApi->authorize_user: #{e}"
51
+ throw e;
52
+ end
53
+
54
+ # On success, continue with the route code to load resource and return it
55
+ return { resource: {}, statusCode: 200 };
56
+ ```
57
+
58
+ ### Authorize with a service client
59
+ ```rb
60
+ require 'authress-sdk';
61
+
62
+ # create an instance of the API class during service initialization
63
+ # Replace DOMAIN with the Authress domain for your account
64
+
65
+ # Create a service client in the Authress management portal and past the access token here
66
+ # This will generate a token automatically instead of passing the user token to the api
67
+ AuthressClient.configure do |config|
68
+ config.base_url = 'https://DOMAIN.api-REGION.authress.io'
69
+ accessToken = 'eyJrZXlJ....';
70
+ config.token_provider = ServiceClientTokenProvider.new(accessToken)
71
+ end
72
+
73
+ # on api route
74
+ [route('/resources/<resourceId>')]
75
+ function getResource(resourceId) {
76
+ # Check Authress to authorize the user
77
+ user_id = 'user_id_example' # String | The user to check permissions on
78
+ 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.
79
+ permission = 'READ' # String | Permission to check, '*' and scoped permissions can also be checked here.
80
+ begin
81
+ #Check to see if a user has permissions to a resource.
82
+ api_instance = SwaggerClient::UserPermissionsApi.new
83
+ api_instance.authorize_user(user_id, resource_uri, permission)
84
+ rescue SwaggerClient::ApiError => e
85
+ # Will throw except if the user is not authorized to read the resource
86
+ if (e.status === 404) {
87
+ return { statusCode: 404 };
88
+ }
89
+ puts "Exception when calling UserPermissionsApi->authorize_user: #{e}"
90
+ throw e;
91
+ end
92
+
93
+ # On success, continue with the route code to load resource and return it
94
+ return { resource: {}, statusCode: 200 };
95
+ ```
96
+
97
+ ### Creating resources
98
+ When a user creates a resource in your application, we want to ensure that they get access own that resource.
99
+
100
+ 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.
101
+
102
+ ```rb
103
+ require 'authress-sdk';
104
+
105
+ begin
106
+ #Create a new access record.
107
+ new_record = SwaggerClient::Body3.new {
108
+ name: `Access To New Resource ${NewResourceId}`,
109
+ users: [{ userId: requestUserId }],
110
+ statements: [{
111
+ resources: [{ resourceUri: `Resources/${NewResourceId}` }],
112
+ # Owner by default gives full control over this new resource, including the ability to grant others access as well.
113
+ roles: ['Authress:Owner']
114
+ }]
115
+ };
116
+ api_instance = SwaggerClient::AccessRecordsApi.new
117
+ result = api_instance.create_record(new_record)
118
+ puts result
119
+ rescue SwaggerClient::ApiError => e
120
+ puts "Exception when calling AccessRecordsApi->create_record: #{e}"
121
+ end
122
+ ```
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authress-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.19.0
4
+ version: 0.1.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rhosys
@@ -71,139 +71,17 @@ dependencies:
71
71
  - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: 3.6.0
74
- description: |+
75
- # authress-sdk.rb This is the Authress SDK used to integrate with the
76
- authorization as a service provider Authress at https://authress.io.
77
-
78
- [![Gem
79
- Version](https://badge.fury.io/rb/authress-sdk.svg)](http://badge.fury.io/rb/a
80
- uthress-sdk)
81
-
82
- ## Usage
83
-
84
- ```sh gem install authress-sdk ```
85
-
86
- Then required the package: ```rb require 'authress-sdk'; ```
87
-
88
- ## Getting started examples
89
-
90
- ### Authorize using a user token ```rb require 'authress-sdk';
91
-
92
- # create an instance of the API class during service initialization # Replace
93
- DOMAIN with the Authress domain for your account AuthressClient.configure do
94
- |config|
95
- config.base_url = 'https://DOMAIN.api-REGION.authress.io'
96
-
97
- end
98
-
99
- # on api route
100
- route('/resources/<resourceId>'):
101
- function getResource(resourceId) {
102
- # Get the user token and pass it to authress
103
- authorizationToken = request.headers.get('authorization');
104
- AuthressClient.setToken(authorizationToken);
105
-
106
- # Check Authress to authorize the user
107
- user_id = 'user_id_example' # String | The user to check permissions on
108
- 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.
109
- permission = 'READ' # String | Permission to check, '*' and scoped permissions can also be checked here.
110
- begin
111
- #Check to see if a user has permissions to a resource.
112
- api_instance = SwaggerClient::UserPermissionsApi.new
113
- api_instance.authorize_user(user_id, resource_uri, permission)
114
- rescue SwaggerClient::ApiError => e
115
- # Will throw except if the user is not authorized to read the resource
116
- if (e.status === 404) {
117
- return { statusCode: 404 };
118
- }
119
- puts "Exception when calling UserPermissionsApi->authorize_user: #{e}"
120
- throw e;
121
- end
122
-
123
- # On success, continue with the route code to load resource and return it
124
- return { resource: {}, statusCode: 200 };
125
-
126
- ```
127
-
128
- ### Authorize with a service client ```rb require 'authress-sdk';
129
-
130
- # create an instance of the API class during service initialization #
131
- Replace DOMAIN with the Authress domain for your account
132
-
133
- # Create a service client in the Authress management portal and past the
134
- access token here # This will generate a token automatically instead of
135
- passing the user token to the api AuthressClient.configure do |config|
136
- config.base_url = 'https://DOMAIN.api-REGION.authress.io'
137
- accessToken = 'eyJrZXlJ....';
138
- config.token_provider = ServiceClientTokenProvider.new(accessToken)
139
-
140
- end
141
-
142
- # on api route
143
- route('/resources/<resourceId>'):
144
- function getResource(resourceId) {
145
- # Check Authress to authorize the user
146
- user_id = 'user_id_example' # String | The user to check permissions on
147
- 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.
148
- permission = 'READ' # String | Permission to check, '*' and scoped permissions can also be checked here.
149
- begin
150
- #Check to see if a user has permissions to a resource.
151
- api_instance = SwaggerClient::UserPermissionsApi.new
152
- api_instance.authorize_user(user_id, resource_uri, permission)
153
- rescue SwaggerClient::ApiError => e
154
- # Will throw except if the user is not authorized to read the resource
155
- if (e.status === 404) {
156
- return { statusCode: 404 };
157
- }
158
- puts "Exception when calling UserPermissionsApi->authorize_user: #{e}"
159
- throw e;
160
- end
161
-
162
- # On success, continue with the route code to load resource and return it
163
- return { resource: {}, statusCode: 200 };
164
-
165
- ```
166
-
167
- ### Creating resources When a user creates a resource in your application,
168
- we want to ensure that they get access own that resource.
169
-
170
- You may receive **User does not have sufficient access to grant
171
- permissions to resources** as an error along with the status code
172
- *<b>403</b>*. This means that the service client or user jwt does not have
173
- access to create the access record. If using a service client, go to the
174
- Authress portal and create a one time record which grants the service
175
- client `Authress:Owner` to `Resources/` so that it can manage access
176
- records for these types of resources.
177
-
178
- ```rb require 'authress-sdk';
179
-
180
- begin
181
- #Create a new access record.
182
- new_record = SwaggerClient::Body3.new {
183
- name: `Access To New Resource ${NewResourceId}`,
184
- users: [{ userId: requestUserId }],
185
- statements: [{
186
- resources: [{ resourceUri: `Resources/${NewResourceId}` }],
187
- # Owner by default gives full control over this new resource, including the ability to grant others access as well.
188
- roles: ['Authress:Owner']
189
- }]
190
- };
191
- api_instance = SwaggerClient::AccessRecordsApi.new
192
- result = api_instance.create_record(new_record)
193
- puts result
194
-
195
- rescue SwaggerClient::ApiError => e
196
- puts "Exception when calling AccessRecordsApi->create_record: #{e}"
197
-
198
- end ```
199
-
200
-
74
+ description: " This is the Authress SDK used to integrate with the authorization
75
+ as a service provider Authress at https://authress.io. The full documentation is
76
+ available in the Github repo Readme: https://github.com/Authress/authress-sdk.rb.\n"
201
77
  email:
202
78
  - support@authress.io
203
79
  executables: []
204
80
  extensions: []
205
- extra_rdoc_files: []
81
+ extra_rdoc_files:
82
+ - README.md
206
83
  files:
84
+ - README.md
207
85
  - lib/swagger_client.rb
208
86
  - lib/swagger_client/api/access_records_api.rb
209
87
  - lib/swagger_client/api/accounts_api.rb
@@ -290,10 +168,16 @@ files:
290
168
  - lib/swagger_client/models/v1usersuser_idtokens_resources.rb
291
169
  - lib/swagger_client/models/v1usersuser_idtokens_statements.rb
292
170
  - lib/swagger_client/version.rb
293
- homepage: https://authress.io
171
+ homepage: https://github.com/Authress/authress-sdk.rb
294
172
  licenses:
295
173
  - Apache-2.0
296
- metadata: {}
174
+ metadata:
175
+ bug_tracker_uri: https://github.com/Authress/authress-sdk.rb/issues
176
+ changelog_uri: https://github.com/Authress/authress-sdk.rb/CHANGELOG.md
177
+ documentation_uri: https://github.com/Authress/authress-sdk.rb
178
+ homepage_uri: https://github.com/Authress/authress-sdk.rb
179
+ source_code_uri: https://github.com/Authress/authress-sdk.rb
180
+ wiki_uri: https://github.com/Authress/authress-sdk.rb/wiki
297
181
  post_install_message:
298
182
  rdoc_options: []
299
183
  require_paths:
@@ -313,6 +197,5 @@ rubygems_version: 3.1.4
313
197
  signing_key:
314
198
  specification_version: 4
315
199
  summary: The Authress SDK for Ruby provides authorization as a service with fully
316
- compatible REST apis to integrate with Authress at https://authress.io.
200
+ compatible REST apis.
317
201
  test_files: []
318
- ...