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 +4 -4
- data/README.md +24 -9
- data/lib/warrant/version.rb +1 -1
- data/lib/warrant/warrant_client.rb +3 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a67a5a1dd2b6e9b95b675395d1337acd9509f166f5e22d224987260191b5090d
|
4
|
+
data.tar.gz: '08013f834166288f8a0ba21753d7a11d0a89e1aa8b7189894e0d80146f47081e'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 = ''
|
31
|
+
### `create_user(email, user_id = '')`
|
32
32
|
|
33
|
-
This method creates a user entity in Warrant with the specified `
|
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(
|
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', {
|
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(
|
76
|
+
### `is_authorized(object_type, object_id, relation, user_id)`
|
62
77
|
|
63
|
-
This method returns `true` if the user with the specified `
|
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
|
-
#### **
|
91
|
+
#### **object_type**
|
77
92
|
Only return warrants with the given object type.
|
78
93
|
|
79
|
-
#### **
|
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
|
-
#### **
|
100
|
+
#### **user_id**
|
86
101
|
Only return warrants with the given user id
|
87
102
|
|
88
103
|
|
data/lib/warrant/version.rb
CHANGED
@@ -19,10 +19,9 @@ module Warrant
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def create_user(email, user_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.
|
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-
|
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
|