warrant 1.1.0 → 2.0.0.rc1
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.
- 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/subject.rb +8 -0
- data/lib/warrant/models/tenant.rb +176 -35
- data/lib/warrant/models/user.rb +231 -104
- data/lib/warrant/models/warrant.rb +222 -42
- data/lib/warrant/util.rb +20 -17
- 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,25 +2,24 @@
|
|
2
2
|
|
3
3
|
module Warrant
|
4
4
|
class Warrant
|
5
|
-
attr_reader :id, :object_type, :object_id, :relation, :subject
|
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)
|
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
|
14
|
+
@is_direct_match = is_direct_match
|
13
15
|
end
|
14
16
|
|
15
17
|
# Create a new warrant that associates an object (object_type and object_id) to a subject via a relation.
|
16
18
|
#
|
17
|
-
# @
|
18
|
-
# @
|
19
|
-
# @
|
20
|
-
# @
|
21
|
-
# * :object_type (String) - The type of object. Must be one of your system's existing object types.
|
22
|
-
# * :object_id (String) - The id of the specific object.
|
23
|
-
# * :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)
|
24
23
|
#
|
25
24
|
# @return [Warrant] created warrant
|
26
25
|
#
|
@@ -28,18 +27,27 @@ module Warrant
|
|
28
27
|
# @raise [Warrant::InternalError]
|
29
28
|
# @raise [Warrant::InvalidParameterError]
|
30
29
|
# @raise [Warrant::InvalidRequestError]
|
31
|
-
# @raise [Warrant::MissingRequiredParameterError]
|
32
30
|
# @raise [Warrant::NotFoundError]
|
33
31
|
# @raise [Warrant::UnauthorizedError]
|
34
32
|
# @raise [Warrant::WarrantError]
|
35
|
-
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
|
+
}
|
36
44
|
res = APIOperations.post(URI.parse("#{::Warrant.config.api_base}/v1/warrants"), Util.normalize_params(params))
|
37
45
|
res_json = JSON.parse(res.body)
|
38
46
|
|
39
47
|
case res
|
40
48
|
when Net::HTTPSuccess
|
41
|
-
subject = Subject.new(res_json['subject']['objectType'], res_json['subject']['objectId'])
|
42
|
-
Warrant.new(res_json['objectType'], res_json['objectId'], res_json['relation'], subject)
|
49
|
+
subject = Subject.new(res_json['subject']['objectType'], res_json['subject']['objectId'], res_json['subject']['relation'])
|
50
|
+
Warrant.new(res_json['objectType'], res_json['objectId'], res_json['relation'], subject, res_json['context'])
|
43
51
|
else
|
44
52
|
APIOperations.raise_error(res)
|
45
53
|
end
|
@@ -47,24 +55,29 @@ module Warrant
|
|
47
55
|
|
48
56
|
# Deletes a warrant specified by the combination of object_type, object_id, relation, and subject.
|
49
57
|
#
|
50
|
-
# @
|
51
|
-
# @
|
52
|
-
# @
|
53
|
-
# @
|
54
|
-
# * :object_type [String] The type of object. Must be one of your system's existing object types.
|
55
|
-
# * :object_id [String] The id of the specific object.
|
56
|
-
# * :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)
|
57
62
|
#
|
58
63
|
# @return [nil] if delete was successful
|
59
64
|
#
|
60
65
|
# @raise [Warrant::InternalError]
|
61
|
-
# @raise [Warrant::InvalidParameterError]
|
62
66
|
# @raise [Warrant::InvalidRequestError]
|
63
|
-
# @raise [Warrant::MissingRequiredParameterError]
|
64
67
|
# @raise [Warrant::NotFoundError]
|
65
68
|
# @raise [Warrant::UnauthorizedError]
|
66
69
|
# @raise [Warrant::WarrantError]
|
67
|
-
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
|
+
}
|
68
81
|
res = APIOperations.delete(URI.parse("#{::Warrant.config.api_base}/v1/warrants"), Util.normalize_params(params))
|
69
82
|
|
70
83
|
case res
|
@@ -75,28 +88,34 @@ module Warrant
|
|
75
88
|
end
|
76
89
|
end
|
77
90
|
|
78
|
-
#
|
91
|
+
# Query to find all warrants for a given subject.
|
79
92
|
#
|
80
|
-
# @option
|
81
|
-
# @option
|
82
|
-
# @option
|
93
|
+
# @option params [String] :object_type The type of object. Must be one of your system's existing object types. (optional)
|
94
|
+
# @option params [String] :relation The relation for this object to subject association. The relation must be valid as per the object type definition. (optional)
|
95
|
+
# @option params [String] :subject The subject to query warrants for. This should be in the format `OBJECT_TYPE:OBJECT_ID`, i.e. `user:8`
|
96
|
+
# * subject (Hash) - The specific subject for which warrants will be queried for.
|
97
|
+
# * object_type (String) - The type of object. Must be one of your system's existing object types.
|
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)
|
83
101
|
#
|
84
|
-
# @return [Array<Warrant>] list of all warrants with provided
|
102
|
+
# @return [Array<Warrant>] list of all warrants with provided params
|
85
103
|
#
|
86
104
|
# @raise [Warrant::InternalError]
|
87
|
-
# @raise [Warrant::
|
88
|
-
# @raise [Warrant::
|
105
|
+
# @raise [Warrant::InvalidParameterError]
|
106
|
+
# @raise [Warrant::MissingRequiredParameterError]
|
89
107
|
# @raise [Warrant::UnauthorizedError]
|
90
108
|
# @raise [Warrant::WarrantError]
|
91
|
-
def self.
|
92
|
-
|
109
|
+
def self.query(params = {})
|
110
|
+
params[:subject] = Subject.new_from_hash(params[:subject])
|
111
|
+
res = APIOperations.get(URI.parse("#{::Warrant.config.api_base}/v1/query"), params)
|
93
112
|
|
94
113
|
case res
|
95
114
|
when Net::HTTPSuccess
|
96
115
|
warrants = JSON.parse(res.body)
|
97
116
|
warrants.map{ |warrant|
|
98
|
-
subject = Subject.new(warrant['subject']['objectType'], warrant['subject']['objectId'])
|
99
|
-
Warrant.new(warrant['objectType'], warrant['objectId'], warrant['relation'], subject)
|
117
|
+
subject = Subject.new(warrant['subject']['objectType'], warrant['subject']['objectId'], warrant['subject']['relation'])
|
118
|
+
Warrant.new(warrant['objectType'], warrant['objectId'], warrant['relation'], subject, warrant['context'], warrant['isDirectMatch'])
|
100
119
|
}
|
101
120
|
else
|
102
121
|
APIOperations.raise_error(res)
|
@@ -115,7 +134,8 @@ module Warrant
|
|
115
134
|
# * object_type (String) - The type of object. Must be one of your system's existing object types.
|
116
135
|
# * object_id (String) - The id of the specific object.
|
117
136
|
# * relation (String) - The relation for this object to subject association. The relation must be valid as per the object type definition. (optional)
|
118
|
-
# @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)
|
119
139
|
# @param debug [Boolean] Boolean flag indicating whether or not to return debug information for this access check. Defaults to false. (optional)
|
120
140
|
#
|
121
141
|
# @return [Boolean] whether or not the given access check is authorized
|
@@ -134,11 +154,8 @@ module Warrant
|
|
134
154
|
#
|
135
155
|
# @raise [Warrant::InternalError]
|
136
156
|
# @raise [Warrant::InvalidParameterError]
|
137
|
-
# @raise [Warrant::InvalidRequestError]
|
138
|
-
# @raise [Warrant::MissingRequiredParameterError]
|
139
157
|
# @raise [Warrant::NotFoundError]
|
140
158
|
# @raise [Warrant::UnauthorizedError]
|
141
|
-
# @raise [Warrant::WarrantError]
|
142
159
|
def self.is_authorized?(params = {})
|
143
160
|
unless ::Warrant.config.authorize_endpoint.nil?
|
144
161
|
return edge_authorize?(params)
|
@@ -147,10 +164,142 @@ module Warrant
|
|
147
164
|
return authorize?(params)
|
148
165
|
end
|
149
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
|
+
|
150
298
|
# Checks whether a given user has a given permission.
|
151
299
|
#
|
152
300
|
# @param user_id [String] Id of the user to check
|
153
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)
|
154
303
|
# @param consistentRead [Boolean] Boolean flag indicating whether or not to enforce strict consistency for this access check. Defaults to false. (optional)
|
155
304
|
# @param debug [Boolean] Boolean flag indicating whether or not to return debug information for this access check. Defaults to false. (optional)
|
156
305
|
#
|
@@ -158,11 +307,8 @@ module Warrant
|
|
158
307
|
#
|
159
308
|
# @raise [Warrant::InternalError]
|
160
309
|
# @raise [Warrant::InvalidParameterError]
|
161
|
-
# @raise [Warrant::InvalidRequestError]
|
162
|
-
# @raise [Warrant::MissingRequiredParameterError]
|
163
310
|
# @raise [Warrant::NotFoundError]
|
164
311
|
# @raise [Warrant::UnauthorizedError]
|
165
|
-
# @raise [Warrant::WarrantError]
|
166
312
|
def self.user_has_permission?(params = {})
|
167
313
|
return is_authorized?(
|
168
314
|
warrants: [{
|
@@ -172,13 +318,47 @@ module Warrant
|
|
172
318
|
subject: {
|
173
319
|
object_type: "user",
|
174
320
|
object_id: params[:user_id]
|
175
|
-
}
|
321
|
+
},
|
322
|
+
context: params[:context]
|
176
323
|
}],
|
177
324
|
consistentRead: params[:consistentRead],
|
178
325
|
debug: params[:debug]
|
179
326
|
)
|
180
327
|
end
|
181
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
|
+
|
182
362
|
private
|
183
363
|
|
184
364
|
def self.authorize?(params = {})
|
data/lib/warrant/util.rb
CHANGED
@@ -15,26 +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
|
-
|
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
|
37
36
|
end
|
37
|
+
when Array
|
38
|
+
params.map { |i| normalize_params(i) }
|
39
|
+
else
|
40
|
+
params
|
38
41
|
end
|
39
42
|
end
|
40
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-
|
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
|