warrant 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a62cf14af95db8e5b31f60059a2a826a67c067239edb5f6c63cf02426df3ae21
4
- data.tar.gz: bdc8aa083993566c57760d484e043ad3ed64abe2bf1945ebad2428c2eb497551
3
+ metadata.gz: a67a5a1dd2b6e9b95b675395d1337acd9509f166f5e22d224987260191b5090d
4
+ data.tar.gz: '08013f834166288f8a0ba21753d7a11d0a89e1aa8b7189894e0d80146f47081e'
5
5
  SHA512:
6
- metadata.gz: 36cf1f6120b776293513e49d5554aa70a8ff22e671105072e2f04115d1e00bc852fd4cc5326672ae9ad246f35f069718272f2abf957ff9abe27ebeed0b564efc
7
- data.tar.gz: 4377ab4955b67e922622ef8c10c50c17d3281d097ec62df85ce31779df3554d8326121622024ffde252abf1a3c13655d0e3f6251d898fc78f722a1578b091daa
6
+ metadata.gz: 8fd775c0e3bf27a5e2eebfa06992c2b09e6dc8d1337740ddbab46e328ea9ccc16b48f1da20e0214ba450d2428d0ac43370ae58ab7f698de7a3ed4b00abab646d
7
+ data.tar.gz: 04d89c962874fbd667d3f695f2913552e4dd855fa436737b387e05498736f4557549cd64958ab6dbce92d37f9ffd114549f498140cce5f7823e3f93e0e39c4c9
data/README.md CHANGED
@@ -28,9 +28,9 @@ require 'warrant'
28
28
  Warrant.api_key = 'api_test_f5dsKVeYnVSLHGje44zAygqgqXiLJBICbFzCiAg1E='
29
29
  ```
30
30
 
31
- ### `create_user(email, user_id = '', tenant_id = '')`
31
+ ### `create_user(email, user_id = '')`
32
32
 
33
- This method creates a user entity in Warrant with the specified `userId`. Provide an optional `username` to make it easier to identify users in the Warrant dashboard.
33
+ This method creates a user entity in Warrant with the specified `user_d`. Provide an optional `username` to make it easier to identify users in the Warrant dashboard.
34
34
 
35
35
  ```ruby
36
36
  # Create user with user email and id
@@ -40,13 +40,28 @@ Warrant::WarrantClient.create_user(user.email, user.id)
40
40
  Warrant::WarrantClient.create_user()
41
41
  ```
42
42
 
43
- ### `create_warrant(objectType, objectId, relation, user)`
43
+ ### `create_warrant(object_type, object_id, relation, user)`
44
+
45
+ #### **User parameters**
46
+ Can provide either a user id, or a combination of object type, object id, and relation
47
+ ---
48
+ #### **user_id**
49
+ Creates a warrant for the user specified by user_id
50
+
51
+ #### **object_type**
52
+ #### **object_id**
53
+ #### **relation**
54
+ Creates a warrant for the given userset specified by object type, object id, and relation
55
+
44
56
 
45
57
  This method creates a warrant which specifies that the provided `user` (or userset) has `relation` on the object of type `objectType` with id `objectId`.
46
58
 
47
59
  ```ruby
48
60
  # Create a warrant allowing user.id to "view" the store with id store.id
49
- Warrant::WarrantClient.create_warrant('store', store.id, 'view', { userId: user.id })
61
+ Warrant::WarrantClient.create_warrant('store', store.id, 'view', { user_id: user.id })
62
+
63
+ # Create a warrant specifying all members of the manager role to "view" store of id store.id
64
+ Warrant::WarrantClient.create_warrant('store', store.id, 'view', { object_type: 'role', object_id: 'manager', relation: 'member' })
50
65
  ```
51
66
 
52
67
  ### `create_session(userId)`
@@ -58,9 +73,9 @@ This method creates a session in Warrant for the user with the specified `userId
58
73
  Warrant::WarrantClient.create_session(user.id)
59
74
  ```
60
75
 
61
- ### `is_authorized(objectType, objectId, relation, userId)`
76
+ ### `is_authorized(object_type, object_id, relation, user_id)`
62
77
 
63
- This method returns `true` if the user with the specified `userId` has the specified `relation` to the object of type `objectType` with id `objectId` and `false` otherwise.
78
+ This method returns `true` if the user with the specified `user_id` has the specified `relation` to the object of type `object_type` with id `objectId` and `false` otherwise.
64
79
 
65
80
  ```ruby
66
81
  # Example: user 123 can only view store 824
@@ -73,16 +88,16 @@ This method returns all warrants that match the filters provided, or all warrant
73
88
 
74
89
  #### **Filter Parameters**
75
90
  ---
76
- #### **objectType**
91
+ #### **object_type**
77
92
  Only return warrants with the given object type.
78
93
 
79
- #### **objectId**
94
+ #### **object_id**
80
95
  Only return warrants with the given object id.
81
96
 
82
97
  #### **relation**
83
98
  Only return warrants with the given relation.
84
99
 
85
- #### **userId**
100
+ #### **user_id**
86
101
  Only return warrants with the given user id
87
102
 
88
103
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Warrant
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
@@ -19,10 +19,9 @@ module Warrant
19
19
  end
20
20
  end
21
21
 
22
- def create_user(email, user_id = '', tenant_id = '')
22
+ def create_user(email, user_id = '')
23
23
  uri = URI.parse("#{::Warrant.config.api_base}/v1/users")
24
24
  params = {
25
- tenantId: tenant_id,
26
25
  userId: user_id,
27
26
  email: email
28
27
  }
@@ -99,7 +98,7 @@ module Warrant
99
98
  objectType: object_type,
100
99
  objectId: object_id,
101
100
  relation: relation,
102
- user: user
101
+ user: Util.normalize_options(user)
103
102
  }
104
103
  res = post(uri, params)
105
104
  res_json = JSON.parse(res.body)
@@ -113,7 +112,7 @@ module Warrant
113
112
  end
114
113
 
115
114
  def delete_warrant(warrant_id)
116
- uri = URI.parse("#{Warrant.config.api_base}/v1/warrants/#{warrant_id}")
115
+ uri = URI.parse("#{::Warrant.config.api_base}/v1/warrants/#{warrant_id}")
117
116
  res = delete(uri)
118
117
 
119
118
  case res
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: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Warrant
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-09 00:00:00.000000000 Z
11
+ date: 2022-05-10 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