warrant 1.2.0 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/lib/warrant/api_operations.rb +9 -3
- data/lib/warrant/errors.rb +2 -0
- data/lib/warrant/models/feature.rb +327 -0
- data/lib/warrant/models/permission.rb +140 -41
- data/lib/warrant/models/pricing_tier.rb +328 -0
- data/lib/warrant/models/role.rb +128 -37
- data/lib/warrant/models/session.rb +4 -5
- data/lib/warrant/models/tenant.rb +176 -35
- data/lib/warrant/models/user.rb +225 -98
- data/lib/warrant/models/warrant.rb +208 -61
- data/lib/warrant/util.rb +20 -19
- data/lib/warrant/version.rb +1 -1
- data/lib/warrant/warrant_configuration.rb +3 -3
- data/lib/warrant/warrant_object.rb +13 -0
- data/lib/warrant.rb +5 -1
- metadata +8 -5
@@ -2,26 +2,24 @@
|
|
2
2
|
|
3
3
|
module Warrant
|
4
4
|
class Warrant
|
5
|
-
attr_reader :id, :object_type, :object_id, :relation, :subject, :is_direct_match
|
5
|
+
attr_reader :id, :object_type, :object_id, :relation, :subject, :context, :is_direct_match
|
6
6
|
|
7
7
|
# @!visibility private
|
8
|
-
def initialize(object_type, object_id, relation, subject, is_direct_match = nil)
|
8
|
+
def initialize(object_type, object_id, relation, subject, context = nil, is_direct_match = nil)
|
9
9
|
@object_type = object_type
|
10
10
|
@object_id = object_id
|
11
11
|
@relation = relation
|
12
12
|
@subject = subject
|
13
|
+
@context = context
|
13
14
|
@is_direct_match = is_direct_match
|
14
15
|
end
|
15
16
|
|
16
17
|
# Create a new warrant that associates an object (object_type and object_id) to a subject via a relation.
|
17
18
|
#
|
18
|
-
# @
|
19
|
-
# @
|
20
|
-
# @
|
21
|
-
# @
|
22
|
-
# * :object_type (String) - The type of object. Must be one of your system's existing object types.
|
23
|
-
# * :object_id (String) - The id of the specific object.
|
24
|
-
# * :relation (String) - The relation for this object to subject association. The relation must be valid as per the object type definition. (optional)
|
19
|
+
# @param object [WarrantObject] Object to check in the access check. Object must include WarrantObject module and implements its methods (`warrant_object_type` and `warrant_object_id`). The object type must be one of your system's existing object type.
|
20
|
+
# @param relation [String] The relation to check for this object to subject association. The relation must be valid as per the object type definition.
|
21
|
+
# @param subject [WarrantObject] Subject to check in the access check. Subject must include WarrantObject module and implements its methods (`warrant_object_type` and `warrant_object_id`).
|
22
|
+
# @param context [Hash] - Object containing key-value pairs that specifies the context the warrant should be created for. (optional)
|
25
23
|
#
|
26
24
|
# @return [Warrant] created warrant
|
27
25
|
#
|
@@ -29,18 +27,27 @@ module Warrant
|
|
29
27
|
# @raise [Warrant::InternalError]
|
30
28
|
# @raise [Warrant::InvalidParameterError]
|
31
29
|
# @raise [Warrant::InvalidRequestError]
|
32
|
-
# @raise [Warrant::MissingRequiredParameterError]
|
33
30
|
# @raise [Warrant::NotFoundError]
|
34
31
|
# @raise [Warrant::UnauthorizedError]
|
35
32
|
# @raise [Warrant::WarrantError]
|
36
|
-
def self.create(
|
33
|
+
def self.create(object, relation, subject, context = nil)
|
34
|
+
params = {
|
35
|
+
object_type: object.warrant_object_type,
|
36
|
+
object_id: object.warrant_object_id,
|
37
|
+
relation: relation,
|
38
|
+
subject: {
|
39
|
+
object_type: subject.warrant_object_type,
|
40
|
+
object_id: subject.warrant_object_id
|
41
|
+
},
|
42
|
+
context: context
|
43
|
+
}
|
37
44
|
res = APIOperations.post(URI.parse("#{::Warrant.config.api_base}/v1/warrants"), Util.normalize_params(params))
|
38
45
|
res_json = JSON.parse(res.body)
|
39
46
|
|
40
47
|
case res
|
41
48
|
when Net::HTTPSuccess
|
42
49
|
subject = Subject.new(res_json['subject']['objectType'], res_json['subject']['objectId'], res_json['subject']['relation'])
|
43
|
-
Warrant.new(res_json['objectType'], res_json['objectId'], res_json['relation'], subject)
|
50
|
+
Warrant.new(res_json['objectType'], res_json['objectId'], res_json['relation'], subject, res_json['context'])
|
44
51
|
else
|
45
52
|
APIOperations.raise_error(res)
|
46
53
|
end
|
@@ -48,24 +55,29 @@ module Warrant
|
|
48
55
|
|
49
56
|
# Deletes a warrant specified by the combination of object_type, object_id, relation, and subject.
|
50
57
|
#
|
51
|
-
# @
|
52
|
-
# @
|
53
|
-
# @
|
54
|
-
# @
|
55
|
-
# * :object_type [String] The type of object. Must be one of your system's existing object types.
|
56
|
-
# * :object_id [String] The id of the specific object.
|
57
|
-
# * :relation [String] The relation for this object to subject association. The relation must be valid as per the object type definition. (optional)
|
58
|
+
# @param object [WarrantObject] Object to check in the access check. Object must include WarrantObject module and implements its methods (`warrant_object_type` and `warrant_object_id`). The object type must be one of your system's existing object type.
|
59
|
+
# @param relation [String] The relation to check for this object to subject association. The relation must be valid as per the object type definition.
|
60
|
+
# @param subject [WarrantObject] Subject to check in the access check. Subject must include WarrantObject module and implements its methods (`warrant_object_type` and `warrant_object_id`).
|
61
|
+
# @param context [Hash] - Object containing key-value pairs that specifies the context the warrant should be deleted in. (optional)
|
58
62
|
#
|
59
63
|
# @return [nil] if delete was successful
|
60
64
|
#
|
61
65
|
# @raise [Warrant::InternalError]
|
62
|
-
# @raise [Warrant::InvalidParameterError]
|
63
66
|
# @raise [Warrant::InvalidRequestError]
|
64
|
-
# @raise [Warrant::MissingRequiredParameterError]
|
65
67
|
# @raise [Warrant::NotFoundError]
|
66
68
|
# @raise [Warrant::UnauthorizedError]
|
67
69
|
# @raise [Warrant::WarrantError]
|
68
|
-
def self.delete(
|
70
|
+
def self.delete(object, relation, subject, context = nil)
|
71
|
+
params = {
|
72
|
+
object_type: object.warrant_object_type,
|
73
|
+
object_id: object.warrant_object_id,
|
74
|
+
relation: relation,
|
75
|
+
subject: {
|
76
|
+
object_type: subject.warrant_object_type,
|
77
|
+
object_id: subject.warrant_object_id
|
78
|
+
},
|
79
|
+
context: context
|
80
|
+
}
|
69
81
|
res = APIOperations.delete(URI.parse("#{::Warrant.config.api_base}/v1/warrants"), Util.normalize_params(params))
|
70
82
|
|
71
83
|
case res
|
@@ -76,34 +88,6 @@ module Warrant
|
|
76
88
|
end
|
77
89
|
end
|
78
90
|
|
79
|
-
# List all warrants for your organization.
|
80
|
-
#
|
81
|
-
# @option filters [String] :object_type The type of object. Must be one of your system's existing object types. (optional)
|
82
|
-
# @option filters [String] :object_id The id of the specific object. (optional)
|
83
|
-
# @option filters [String] :relation The relation for this object to subject association. The relation must be valid as per the object type definition. (optional)
|
84
|
-
#
|
85
|
-
# @return [Array<Warrant>] list of all warrants with provided filters
|
86
|
-
#
|
87
|
-
# @raise [Warrant::InternalError]
|
88
|
-
# @raise [Warrant::InvalidRequestError]
|
89
|
-
# @raise [Warrant::NotFoundError]
|
90
|
-
# @raise [Warrant::UnauthorizedError]
|
91
|
-
# @raise [Warrant::WarrantError]
|
92
|
-
def self.list(filters = {})
|
93
|
-
res = APIOperations.get(URI.parse("#{::Warrant.config.api_base}/v1/warrants"), filters)
|
94
|
-
|
95
|
-
case res
|
96
|
-
when Net::HTTPSuccess
|
97
|
-
warrants = JSON.parse(res.body)
|
98
|
-
warrants.map{ |warrant|
|
99
|
-
subject = Subject.new(warrant['subject']['objectType'], warrant['subject']['objectId'], warrant['subject']['relation'])
|
100
|
-
Warrant.new(warrant['objectType'], warrant['objectId'], warrant['relation'], subject)
|
101
|
-
}
|
102
|
-
else
|
103
|
-
APIOperations.raise_error(res)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
91
|
# Query to find all warrants for a given subject.
|
108
92
|
#
|
109
93
|
# @option params [String] :object_type The type of object. Must be one of your system's existing object types. (optional)
|
@@ -112,12 +96,14 @@ module Warrant
|
|
112
96
|
# * subject (Hash) - The specific subject for which warrants will be queried for.
|
113
97
|
# * object_type (String) - The type of object. Must be one of your system's existing object types.
|
114
98
|
# * object_id (String) - The id of the specific object.
|
99
|
+
# @option params [Integer] :page A positive integer (starting with 1) representing the page of items to return in response. Used in conjunction with the limit param. (optional)
|
100
|
+
# @option params [Integer] :limit A positive integer representing the max number of items to return in response. (optional)
|
115
101
|
#
|
116
102
|
# @return [Array<Warrant>] list of all warrants with provided params
|
117
103
|
#
|
118
104
|
# @raise [Warrant::InternalError]
|
119
|
-
# @raise [Warrant::
|
120
|
-
# @raise [Warrant::
|
105
|
+
# @raise [Warrant::InvalidParameterError]
|
106
|
+
# @raise [Warrant::MissingRequiredParameterError]
|
121
107
|
# @raise [Warrant::UnauthorizedError]
|
122
108
|
# @raise [Warrant::WarrantError]
|
123
109
|
def self.query(params = {})
|
@@ -129,7 +115,7 @@ module Warrant
|
|
129
115
|
warrants = JSON.parse(res.body)
|
130
116
|
warrants.map{ |warrant|
|
131
117
|
subject = Subject.new(warrant['subject']['objectType'], warrant['subject']['objectId'], warrant['subject']['relation'])
|
132
|
-
Warrant.new(warrant['objectType'], warrant['objectId'], warrant['relation'], subject, warrant['isDirectMatch'])
|
118
|
+
Warrant.new(warrant['objectType'], warrant['objectId'], warrant['relation'], subject, warrant['context'], warrant['isDirectMatch'])
|
133
119
|
}
|
134
120
|
else
|
135
121
|
APIOperations.raise_error(res)
|
@@ -148,7 +134,8 @@ module Warrant
|
|
148
134
|
# * object_type (String) - The type of object. Must be one of your system's existing object types.
|
149
135
|
# * object_id (String) - The id of the specific object.
|
150
136
|
# * relation (String) - The relation for this object to subject association. The relation must be valid as per the object type definition. (optional)
|
151
|
-
# @param
|
137
|
+
# @param context [Hash] - Object containing key-value pairs that specifies the context the warrant should be checked in. (optional)
|
138
|
+
# @param consistent_read [Boolean] Boolean flag indicating whether or not to enforce strict consistency for this access check. Defaults to false. (optional)
|
152
139
|
# @param debug [Boolean] Boolean flag indicating whether or not to return debug information for this access check. Defaults to false. (optional)
|
153
140
|
#
|
154
141
|
# @return [Boolean] whether or not the given access check is authorized
|
@@ -167,11 +154,8 @@ module Warrant
|
|
167
154
|
#
|
168
155
|
# @raise [Warrant::InternalError]
|
169
156
|
# @raise [Warrant::InvalidParameterError]
|
170
|
-
# @raise [Warrant::InvalidRequestError]
|
171
|
-
# @raise [Warrant::MissingRequiredParameterError]
|
172
157
|
# @raise [Warrant::NotFoundError]
|
173
158
|
# @raise [Warrant::UnauthorizedError]
|
174
|
-
# @raise [Warrant::WarrantError]
|
175
159
|
def self.is_authorized?(params = {})
|
176
160
|
unless ::Warrant.config.authorize_endpoint.nil?
|
177
161
|
return edge_authorize?(params)
|
@@ -180,10 +164,142 @@ module Warrant
|
|
180
164
|
return authorize?(params)
|
181
165
|
end
|
182
166
|
|
167
|
+
# Checks whether a specified access check is authorized or not.
|
168
|
+
#
|
169
|
+
# @param object [WarrantObject] Object to check in the access check. Object must include WarrantObject module and implements its methods (`warrant_object_type` and `warrant_object_id`). The object type must be one of your system's existing object type.
|
170
|
+
# @param relation [String] The relation to check for this object to subject association. The relation must be valid as per the object type definition.
|
171
|
+
# @param subject [WarrantObject] Subject to check in the access check. Subject must include WarrantObject module and implements its methods (`warrant_object_type` and `warrant_object_id`).
|
172
|
+
# @option options [Hash] :context Object containing key-value pairs that specifies the context the warrant should be checked in. (optional) (optional)
|
173
|
+
# @option options [Boolean] :consistent_read Boolean flag indicating whether or not to enforce strict consistency for this access check. Defaults to false. (optional)
|
174
|
+
# @option options [Boolean] :debug Boolean flag indicating whether or not to return debug information for this access check. Defaults to false. (optional)
|
175
|
+
#
|
176
|
+
# @return [Boolean] whether or not the given access check is authorized
|
177
|
+
#
|
178
|
+
# @example Check whether the user has "viewer" relation to report. `Report` and `User` here are both classes in your application that include `WarrantObject`.
|
179
|
+
# my_report = Report.get("some-report")
|
180
|
+
# current_user = User.get("llm-128")
|
181
|
+
# Warrant::Warrant.is_authorized?(my_report, "viewer", current_user)
|
182
|
+
#
|
183
|
+
# @raise [Warrant::InternalError]
|
184
|
+
# @raise [Warrant::InvalidParameterError]
|
185
|
+
# @raise [Warrant::NotFoundError]
|
186
|
+
# @raise [Warrant::UnauthorizedError]
|
187
|
+
def self.check(object, relation, subject, options = {})
|
188
|
+
if subject.instance_of?(Subject)
|
189
|
+
subject = {
|
190
|
+
object_type: subject.object_type,
|
191
|
+
object_id: subject.object_id,
|
192
|
+
relation: subject.relation
|
193
|
+
}.compact!
|
194
|
+
else
|
195
|
+
subject = {
|
196
|
+
object_type: subject.warrant_object_type,
|
197
|
+
object_id: subject.warrant_object_id
|
198
|
+
}
|
199
|
+
end
|
200
|
+
|
201
|
+
unless ::Warrant.config.authorize_endpoint.nil?
|
202
|
+
return edge_authorize?(
|
203
|
+
warrants: [{
|
204
|
+
object_type: object.warrant_object_type,
|
205
|
+
object_id: object.warrant_object_id,
|
206
|
+
relation: relation,
|
207
|
+
subject: subject,
|
208
|
+
context: options[:context]
|
209
|
+
}],
|
210
|
+
consistent_read: options[:consistent_read],
|
211
|
+
debug: options[:debug]
|
212
|
+
)
|
213
|
+
end
|
214
|
+
|
215
|
+
return authorize?(
|
216
|
+
warrants: [{
|
217
|
+
object_type: object.warrant_object_type,
|
218
|
+
object_id: object.warrant_object_id,
|
219
|
+
relation: relation,
|
220
|
+
subject: subject,
|
221
|
+
context: options[:context]
|
222
|
+
}],
|
223
|
+
consistent_read: options[:consistent_read],
|
224
|
+
debug: options[:debug]
|
225
|
+
)
|
226
|
+
end
|
227
|
+
|
228
|
+
# Checks whether multiple access checks are authorized or not.
|
229
|
+
#
|
230
|
+
# @param op [String] Logical operator to perform on warrants. Can be 'anyOf' or 'allOf'.
|
231
|
+
# @param warrants [Array] Array of warrants to check access for.
|
232
|
+
# * object (WarrantObject) - Object to check in the access check. Object must include WarrantObject module and implements its methods (`warrant_object_type` and `warrant_object_id`). The object type must be one of your system's existing object type.
|
233
|
+
# * relation (String) - The relation to check for this object to subject association. The relation must be valid as per the object type definition.
|
234
|
+
# * subject (WarrantObject) Subject to check in the access check. Subject must include WarrantObject module and implements its methods (`warrant_object_type` and `warrant_object_id`).
|
235
|
+
# @option options [Hash] :context Object containing key-value pairs that specifies the context the warrant should be checked in. (optional)
|
236
|
+
# @option options [Boolean] :consistent_read Boolean flag indicating whether or not to enforce strict consistency for this access check. Defaults to false. (optional)
|
237
|
+
# @option options [Boolean] :debug Boolean flag indicating whether or not to return debug information for this access check. Defaults to false. (optional)
|
238
|
+
#
|
239
|
+
# @return [Boolean] whether or not the given access check is authorized
|
240
|
+
#
|
241
|
+
# @example Check whether the current user has "viewer" relation to report and is a "member" of the customer account "superstore". `Report`, `CustomerAccount` and `User` here are all classes in your application that include `WarrantObject`.
|
242
|
+
# my_report = Report.get("some-report")
|
243
|
+
# customer_account = CustomerAccount.get("superstore")
|
244
|
+
# current_user = User.get("llm-128")
|
245
|
+
# Warrant::Warrant.check_many(
|
246
|
+
# "allOf",
|
247
|
+
# [
|
248
|
+
# { object: my_report, relation: "viewer", subject: current_user },
|
249
|
+
# { object: customer_account, relation: "member", subject: current_user }
|
250
|
+
# ]
|
251
|
+
# )
|
252
|
+
#
|
253
|
+
# @raise [Warrant::InternalError]
|
254
|
+
# @raise [Warrant::InvalidParameterError]
|
255
|
+
# @raise [Warrant::NotFoundError]
|
256
|
+
# @raise [Warrant::UnauthorizedError]
|
257
|
+
def self.check_many(op, warrants, options = {})
|
258
|
+
normalized_warrants = warrants.map do |warrant|
|
259
|
+
if warrant[:subject].instance_of?(Subject)
|
260
|
+
subject = {
|
261
|
+
object_type: warrant[:subject].object_type,
|
262
|
+
object_id: warrant[:subject].object_id,
|
263
|
+
relation: warrant[:subject].relation
|
264
|
+
}.compact!
|
265
|
+
else
|
266
|
+
subject = {
|
267
|
+
object_type: warrant[:subject].warrant_object_type,
|
268
|
+
object_id: warrant[:subject].warrant_object_id
|
269
|
+
}
|
270
|
+
end
|
271
|
+
|
272
|
+
{
|
273
|
+
object_type: warrant[:object].warrant_object_type,
|
274
|
+
object_id: warrant[:object].warrant_object_id,
|
275
|
+
relation: warrant[:relation],
|
276
|
+
subject: subject,
|
277
|
+
context: warrant[:context]
|
278
|
+
}
|
279
|
+
end
|
280
|
+
|
281
|
+
unless ::Warrant.config.authorize_endpoint.nil?
|
282
|
+
return edge_authorize?(
|
283
|
+
op: op,
|
284
|
+
warrants: normalized_warrants,
|
285
|
+
consistent_read: options[:consistent_read],
|
286
|
+
debug: options[:debug]
|
287
|
+
)
|
288
|
+
end
|
289
|
+
|
290
|
+
return authorize?(
|
291
|
+
op: op,
|
292
|
+
warrants: normalized_warrants,
|
293
|
+
consistent_read: options[:consistent_read],
|
294
|
+
debug: options[:debug]
|
295
|
+
)
|
296
|
+
end
|
297
|
+
|
183
298
|
# Checks whether a given user has a given permission.
|
184
299
|
#
|
185
300
|
# @param user_id [String] Id of the user to check
|
186
301
|
# @param permission_id [String] Id of the permission to check on the user
|
302
|
+
# @param context [Hash] - Object containing key-value pairs that specifies the context the warrant should be checked in. (optional)
|
187
303
|
# @param consistentRead [Boolean] Boolean flag indicating whether or not to enforce strict consistency for this access check. Defaults to false. (optional)
|
188
304
|
# @param debug [Boolean] Boolean flag indicating whether or not to return debug information for this access check. Defaults to false. (optional)
|
189
305
|
#
|
@@ -191,11 +307,8 @@ module Warrant
|
|
191
307
|
#
|
192
308
|
# @raise [Warrant::InternalError]
|
193
309
|
# @raise [Warrant::InvalidParameterError]
|
194
|
-
# @raise [Warrant::InvalidRequestError]
|
195
|
-
# @raise [Warrant::MissingRequiredParameterError]
|
196
310
|
# @raise [Warrant::NotFoundError]
|
197
311
|
# @raise [Warrant::UnauthorizedError]
|
198
|
-
# @raise [Warrant::WarrantError]
|
199
312
|
def self.user_has_permission?(params = {})
|
200
313
|
return is_authorized?(
|
201
314
|
warrants: [{
|
@@ -205,13 +318,47 @@ module Warrant
|
|
205
318
|
subject: {
|
206
319
|
object_type: "user",
|
207
320
|
object_id: params[:user_id]
|
208
|
-
}
|
321
|
+
},
|
322
|
+
context: params[:context]
|
209
323
|
}],
|
210
324
|
consistentRead: params[:consistentRead],
|
211
325
|
debug: params[:debug]
|
212
326
|
)
|
213
327
|
end
|
214
328
|
|
329
|
+
# Checks whether a given subject has a given feature.
|
330
|
+
#
|
331
|
+
# @param subject (Hash) - The specific subject for which feature access will be checked.
|
332
|
+
# * object_type (String) - The type of object. Must be one of your system's existing object types.
|
333
|
+
# * object_id (String) - The id of the specific object.
|
334
|
+
# @param feature_id [String] Id of the feature to check on the subject
|
335
|
+
# @param context [Hash] - Object containing key-value pairs that specifies the context the warrant should be checked in. (optional)
|
336
|
+
# @param consistent_read [Boolean] Boolean flag indicating whether or not to enforce strict consistency for this access check. Defaults to false. (optional)
|
337
|
+
# @param debug [Boolean] Boolean flag indicating whether or not to return debug information for this access check. Defaults to false. (optional)
|
338
|
+
#
|
339
|
+
# @return [Boolean] whether or not the user has the given permission
|
340
|
+
#
|
341
|
+
# @raise [Warrant::InternalError]
|
342
|
+
# @raise [Warrant::InvalidParameterError]
|
343
|
+
# @raise [Warrant::NotFoundError]
|
344
|
+
# @raise [Warrant::UnauthorizedError]
|
345
|
+
def self.has_feature?(params = {})
|
346
|
+
return is_authorized?(
|
347
|
+
warrants: [{
|
348
|
+
object_type: "feature",
|
349
|
+
object_id: params[:feature_id],
|
350
|
+
relation: "member",
|
351
|
+
subject: {
|
352
|
+
object_type: params[:subject][:object_type],
|
353
|
+
object_id: params[:subject][:object_id]
|
354
|
+
},
|
355
|
+
context: params[:context]
|
356
|
+
}],
|
357
|
+
consistent_read: params[:consistent_read],
|
358
|
+
debug: params[:debug]
|
359
|
+
)
|
360
|
+
end
|
361
|
+
|
215
362
|
private
|
216
363
|
|
217
364
|
def self.authorize?(params = {})
|
data/lib/warrant/util.rb
CHANGED
@@ -15,28 +15,29 @@ module Warrant
|
|
15
15
|
.downcase
|
16
16
|
end
|
17
17
|
|
18
|
-
def normalize_options(opts)
|
19
|
-
new_opts = opts.each_with_object({}) do |(k, v), new_opts|
|
20
|
-
new_key = Util.camelcase(k.to_s)
|
21
|
-
|
22
|
-
new_opts[new_key] = v
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
18
|
def normalize_params(params)
|
27
|
-
|
28
|
-
|
19
|
+
params.compact!
|
20
|
+
|
21
|
+
case params
|
22
|
+
when Hash
|
23
|
+
params.each_with_object({}) do |(k, v), new_opts|
|
24
|
+
new_key = Util.camelcase(k.to_s)
|
29
25
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
26
|
+
case v
|
27
|
+
when Hash
|
28
|
+
new_opts[new_key] = normalize_params(v)
|
29
|
+
when Array
|
30
|
+
new_opts[new_key] = v.map { |i| normalize_params(i) }
|
31
|
+
when Subject
|
32
|
+
new_opts[new_key] = "#{v.object_type}:#{v.object_id}"
|
33
|
+
else
|
34
|
+
new_opts[new_key] = v
|
35
|
+
end
|
39
36
|
end
|
37
|
+
when Array
|
38
|
+
params.map { |i| normalize_params(i) }
|
39
|
+
else
|
40
|
+
params
|
40
41
|
end
|
41
42
|
end
|
42
43
|
end
|
data/lib/warrant/version.rb
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
module Warrant
|
4
4
|
# @!visibility private
|
5
5
|
class WarrantConfiguration
|
6
|
-
attr_accessor :api_key
|
7
|
-
attr_accessor :authorize_endpoint
|
6
|
+
attr_accessor :api_key, :api_base, :authorize_endpoint
|
8
7
|
|
9
|
-
attr_reader :
|
8
|
+
attr_reader :self_service_dash_url_base
|
10
9
|
|
11
10
|
def initialize
|
12
11
|
@api_base = "https://api.warrant.dev"
|
12
|
+
@authorize_endpoint = "https://api.warrant.dev"
|
13
13
|
@self_service_dash_url_base = "https://self-serve.warrant.dev"
|
14
14
|
end
|
15
15
|
end
|
data/lib/warrant.rb
CHANGED
@@ -6,9 +6,13 @@ require "net/http"
|
|
6
6
|
require "json"
|
7
7
|
require "forwardable"
|
8
8
|
|
9
|
+
require "warrant/warrant_object"
|
10
|
+
|
9
11
|
require "warrant/api_operations"
|
10
12
|
require "warrant/errors"
|
13
|
+
require "warrant/models/feature"
|
11
14
|
require "warrant/models/permission"
|
15
|
+
require "warrant/models/pricing_tier"
|
12
16
|
require "warrant/models/role"
|
13
17
|
require "warrant/models/session"
|
14
18
|
require "warrant/models/subject"
|
@@ -26,6 +30,6 @@ module Warrant
|
|
26
30
|
|
27
31
|
attr_reader :config
|
28
32
|
|
29
|
-
def_delegators :@config, :api_key, :api_key=, :authorize_endpoint, :authorize_endpoint=
|
33
|
+
def_delegators :@config, :api_key, :api_key=, :api_base, :api_base=, :authorize_endpoint, :authorize_endpoint=
|
30
34
|
end
|
31
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warrant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Warrant
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby library for the Warrant API at https://warrant.dev.
|
14
14
|
email: hello@warrant.dev
|
@@ -28,7 +28,9 @@ files:
|
|
28
28
|
- lib/warrant.rb
|
29
29
|
- lib/warrant/api_operations.rb
|
30
30
|
- lib/warrant/errors.rb
|
31
|
+
- lib/warrant/models/feature.rb
|
31
32
|
- lib/warrant/models/permission.rb
|
33
|
+
- lib/warrant/models/pricing_tier.rb
|
32
34
|
- lib/warrant/models/role.rb
|
33
35
|
- lib/warrant/models/session.rb
|
34
36
|
- lib/warrant/models/subject.rb
|
@@ -38,6 +40,7 @@ files:
|
|
38
40
|
- lib/warrant/util.rb
|
39
41
|
- lib/warrant/version.rb
|
40
42
|
- lib/warrant/warrant_configuration.rb
|
43
|
+
- lib/warrant/warrant_object.rb
|
41
44
|
homepage: https://github.com/warrant-dev/warrant-ruby
|
42
45
|
licenses:
|
43
46
|
- MIT
|
@@ -57,11 +60,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
60
|
version: 2.3.0
|
58
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
62
|
requirements:
|
60
|
-
- - "
|
63
|
+
- - ">"
|
61
64
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
65
|
+
version: 1.3.1
|
63
66
|
requirements: []
|
64
|
-
rubygems_version: 3.
|
67
|
+
rubygems_version: 3.1.4
|
65
68
|
signing_key:
|
66
69
|
specification_version: 4
|
67
70
|
summary: Warrant Ruby Library
|