forked from bcgov/von-network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth_rules
364 lines (290 loc) · 23.1 KB
/
auth_rules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# ===================================================================================
# Start an Indy-cli Session and Update a list of Auth_Rules
# -----------------------------------------------------------------------------------
# Start an interactive indy-cli session with a connected pool, wallet, and did,
# and apply a list of auth rules.
#
# - The ledger pool MUST exist.
# - A wallet containing the DID MUST exist.
#
# This batch script is designed to be used with von-network. To use it place the
# script in the cli-scripts folder of your working copy of von-network and follow
# the examples below to run it.
#
# Examples:
# ./manage \
# indy-cli auth_rules \
# walletName=endorser_wallet \
# poolName=localpool \
# useDid=DFuDqCYpeDNXLuc3MKooX3
#
# ./manage \
# indy-cli auth_rules \
# walletName=endorser_wallet \
# storageType=postgres_storage \
# storageConfig='{"url":"192.168.65.3:5435"}' \
# storageCredentials='{"account":"DB_USER","password":"DB_PASSWORD","admin_account":"postgres","admin_password":"mysecretpassword"}' \
# poolName=localpool \
# useDid=DFuDqCYpeDNXLuc3MKooX3
#
# Params:
# walletName:
# - The name of the wallet to be used for the operation.
#
# storageType:
# - Optional - The wallet storage type. Defaults to 'default'.
# - Remote Wallet Example; postgres_storage
# - Local Wallet Example; default
#
# storageConfig:
# - Optional - The wallet storage configuration. Defaults to '{}'.
# - Remote Wallet Example; '{"url":"192.168.65.3:5435"}'
# - Local Wallet Example; '{}'
#
# storageCredentials:
# - Optional - The wallet storage credentials. Defaults to '{}'.
# - Remote Wallet Example; '{"account":"DB_USER","password":"DB_PASSWORD","admin_account":"postgres","admin_password":"mysecretpassword"}'
# - Local Wallet Example; '{}'
#
# poolName:
# - The name of the ledger pool to use during the operations.
# - Example; sandbox
#
# useDid:
# - The DID to use for the session.
# ===================================================================================
load-plugin library=libindystrgpostgres.so initializer=postgresstorage_init
pool connect ${poolName}
-wallet attach ${walletName} storage_type=${storageType} storage_config=${storageConfig}
wallet open ${walletName} key storage_credentials=${storageCredentials}
did use ${useDid}
# Roles:
# - Trustee 0
# - Steward 2
# - Endorser 101
# - Network_Monitor 201
# - User (non-privileged) <None>
# =================================================================================================================================================================
# Add/Edit DID
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
# Add Trustee DID
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=ADD field=role old_value=* new_value=0 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Add Steward DID
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=ADD field=role old_value=* new_value=2 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Add Endorser DID
# - Require 1 Trustee signatures
ledger auth-rule txn_type=NYM action=ADD field=role old_value=* new_value=101 constraint="{"sig_count":1,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Add Network_Monitor DID
# - Require 1 Trustee signature || 1 Steward signature
ledger auth-rule txn_type=NYM action=ADD field=role old_value=* new_value=201 constraint="{"constraint_id":"OR","auth_constraints":[{"sig_count":1,"role":"0","constraint_id":"ROLE","need_to_be_owner":false},{"sig_count":1,"role":"2","constraint_id":"ROLE","need_to_be_owner":false}]}"
# Add non-privileged DID
# - Require 1 Trustee signature || 1 Endorser signature
ledger auth-rule txn_type=NYM action=ADD field=role old_value=* constraint="{"constraint_id":"OR","auth_constraints":[{"sig_count":1,"role":"0","constraint_id":"ROLE","need_to_be_owner":false},{"sig_count":1,"role":"101","constraint_id":"ROLE","need_to_be_owner":false}]}"
# Edit DID - Change Role from Trustee to Steward
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=0 new_value=2 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from Trustee to Endorser
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=0 new_value=101 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from Trustee to Network_Monitor
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=0 new_value=201 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from Trustee to non-privileged
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=0 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from Steward to Trustee
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=2 new_value=0 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from Steward to Endorser
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=2 new_value=101 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from Steward to Network_Monitor
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=2 new_value=201 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from Steward to non-privileged
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=2 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from Endorser to Trustee
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=101 new_value=0 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from Endorser to Steward
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=101 new_value=2 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from Endorser to Network_Monitor
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=101 new_value=201 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from Endorser to non-privileged
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=101 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from Network_Monitor to Trustee
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=201 new_value=0 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from Network_Monitor to Steward
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=201 new_value=2 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from Network_Monitor to Endorser
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=201 new_value=101 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from Network_Monitor to non-privileged
# - Require 1 Trustee signature || 1 Network_Monitor (owner) signature
ledger auth-rule txn_type=NYM action=EDIT field=role old_value=201 constraint="{"constraint_id":"OR","auth_constraints":[{"sig_count":1,"role":"0","constraint_id":"ROLE","need_to_be_owner":false},{"sig_count":1,"role":"201","constraint_id":"ROLE","need_to_be_owner":true}]}"
# Edit DID - Change Role from non-privileged to Trustee
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role new_value=0 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from non-privileged to Steward
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role new_value=2 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from non-privileged to Endorser
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role new_value=101 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change Role from non-privileged to Network_Monitor
# - Require 2 Trustee signatures
ledger auth-rule txn_type=NYM action=EDIT field=role new_value=201 constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit DID - Change verkey
# - Require owner signature
ledger auth-rule txn_type=NYM action=EDIT field=verkey old_value=* new_value=* constraint="{"sig_count":1,"role":"*","constraint_id":"ROLE","need_to_be_owner":true}"
# =================================================================================================================================================================
# =================================================================================================================================================================
# Add/Edit ATTRIB
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
# Add ATTRIB
# - Require owner signature
ledger auth-rule txn_type=ATTRIB action=ADD field=* old_value=* new_value=* constraint="{"sig_count":1,"role":"*","constraint_id":"ROLE","need_to_be_owner":true}"
# Edit ATTRIB
# - Require owner signature
ledger auth-rule txn_type=ATTRIB action=EDIT field=* old_value=* new_value=* constraint="{"sig_count":1,"role":"*","constraint_id":"ROLE","need_to_be_owner":true}"
# =================================================================================================================================================================
# =================================================================================================================================================================
# Add/Edit Schema
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
# Add Schema
# - Require 1 Endorser signature
ledger auth-rule txn_type=SCHEMA action=ADD field=* old_value=* new_value=* constraint="{"sig_count":1,"role":"101","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit Schema
# - Forbidden
ledger auth-rule txn_type=SCHEMA action=EDIT field=* old_value=* new_value=* constraint="{"constraint_id":"FORBIDDEN"}"
# =================================================================================================================================================================
# =================================================================================================================================================================
# Add/Edit SET_CONTEXT (200) [aka Rich Schema]
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
# Add Set Context
# - Require 2 Trustee signatures
ledger auth-rule txn_type=200 action=ADD field=* old_value=* new_value=* constraint="{"constraint_id":"FORBIDDEN"}"
# Edit Set Context
# - Forbidden
ledger auth-rule txn_type=200 action=EDIT field=* old_value=* new_value=* constraint="{"constraint_id":"FORBIDDEN"}"
# =================================================================================================================================================================
# =================================================================================================================================================================
# Add Claim Def
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
# Add Claim Def
# - Require 1 Endorser signature
ledger auth-rule txn_type=CLAIM_DEF action=ADD field=* old_value=* new_value=* constraint="{"sig_count":1,"role":"101","constraint_id":"ROLE","need_to_be_owner":false}"
# =================================================================================================================================================================
# =================================================================================================================================================================
# Add/Edit Node
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
# Add Node - Set active
# - Require 1 Steward signature
ledger auth-rule txn_type=NODE action=ADD field=services old_value=* new_value=['VALIDATOR'] constraint="{"sig_count":1,"role":"2","constraint_id":"ROLE","need_to_be_owner":false}"
# Add Node - Set inactive
# - Require 1 Steward signature
ledger auth-rule txn_type=NODE action=ADD field=services old_value=* new_value=[] constraint="{"sig_count":1,"role":"2","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit Node - Set inactive
# - Require 2 Trustee signatures || 1 Steward (owner) signature
ledger auth-rule txn_type=NODE action=EDIT field=services old_value=['VALIDATOR'] new_value=[] constraint="{"constraint_id":"OR","auth_constraints":[{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false},{"sig_count":1,"role":"2","constraint_id":"ROLE","need_to_be_owner":true}]}"
# Edit Node - Set active
# - Require 2 Trustee signatures || 1 Steward (owner) signature
ledger auth-rule txn_type=NODE action=EDIT field=services old_value=[] new_value=['VALIDATOR'] constraint="{"constraint_id":"OR","auth_constraints":[{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false},{"sig_count":1,"role":"2","constraint_id":"ROLE","need_to_be_owner":true}]}"
# Edit Node - update registered node ip address
# - Require 1 Steward (owner) signature
ledger auth-rule txn_type=NODE action=EDIT field=node_ip old_value=* new_value=* constraint="{"sig_count":1,"role":"2","constraint_id":"ROLE","need_to_be_owner":true}"
# Edit Node - update registered node port
# - Require 1 Steward (owner) signature
ledger auth-rule txn_type=NODE action=EDIT field=node_port old_value=* new_value=* constraint="{"sig_count":1,"role":"2","constraint_id":"ROLE","need_to_be_owner":true}"
# Edit Node - update registered client ip address
# - Require 1 Steward (owner) signature
ledger auth-rule txn_type=NODE action=EDIT field=client_ip old_value=* new_value=* constraint="{"sig_count":1,"role":"2","constraint_id":"ROLE","need_to_be_owner":true}"
# Edit Node - update registered client port
# - Require 1 Steward (owner) signature
ledger auth-rule txn_type=NODE action=EDIT field=client_port old_value=* new_value=* constraint="{"sig_count":1,"role":"2","constraint_id":"ROLE","need_to_be_owner":true}"
# Edit Node - update registered blskey
# - Require 1 Steward (owner) signature
ledger auth-rule txn_type=NODE action=EDIT field=blskey old_value=* new_value=* constraint="{"sig_count":1,"role":"2","constraint_id":"ROLE","need_to_be_owner":true}"
# =================================================================================================================================================================
# =================================================================================================================================================================
# Pool Commands
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
# Schedule Pool Upgrade
# - Require 2 Trustee signatures
ledger auth-rule txn_type=POOL_UPGRADE action=ADD field=action old_value=* new_value=start constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit scheduled Pool Upgrade
# - Require 2 Trustee signatures
ledger auth-rule txn_type=POOL_UPGRADE action=EDIT field=action old_value=start new_value=cancel constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit scheduled Pool Upgrade
# - Require 1 Trustee signature
ledger auth-rule txn_type=POOL_RESTART action=ADD field=action old_value=* new_value=* constraint="{"sig_count":1,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit Pool Configuration
# - Require 2 Trustee signatures
ledger auth-rule txn_type=POOL_CONFIG action=EDIT field=action old_value=* new_value=* constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Query validator-info for a node
# - Require 1 Trustee signature || 1 Steward signature || 1 Network_Monitor signature
ledger auth-rule txn_type=GET_VALIDATOR_INFO action=ADD field=* old_value=* new_value=* constraint="{"constraint_id":"OR","auth_constraints":[{"sig_count":1,"role":"0","constraint_id":"ROLE","need_to_be_owner":false},{"sig_count":1,"role":"2","constraint_id":"ROLE","need_to_be_owner":false},{"sig_count":1,"role":"201","constraint_id":"ROLE","need_to_be_owner":false}]}"
# =================================================================================================================================================================
# =================================================================================================================================================================
# Add/Edit Revocation Registry Definitions
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
# Add Revocation Registry Definition
# - Require 1 Endorser signature
ledger auth-rule txn_type=REVOC_REG_DEF action=ADD field=* old_value=* new_value=* constraint="{"sig_count":1,"role":"101","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit Revocation Registry Definition
# - Require 1 Owner signature
ledger auth-rule txn_type=REVOC_REG_DEF action=EDIT field=* old_value=* new_value=* constraint="{"sig_count":1,"role":"*","constraint_id":"ROLE","need_to_be_owner":true}"
# =================================================================================================================================================================
# =================================================================================================================================================================
# Add/Edit Revocation Registry Entries
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
# Add Revocation Registry Entry
# - Require 1 Owner signature
ledger auth-rule txn_type=REVOC_REG_ENTRY action=ADD field=* old_value=* new_value=* constraint="{"sig_count":1,"role":"*","constraint_id":"ROLE","need_to_be_owner":true}"
# Edit Revocation Registry Entry
# - Require 1 Owner signature
ledger auth-rule txn_type=REVOC_REG_ENTRY action=EDIT field=* old_value=* new_value=* constraint="{"sig_count":1,"role":"*","constraint_id":"ROLE","need_to_be_owner":true}"
# =================================================================================================================================================================
# =================================================================================================================================================================
# Edit Auth Rules - Bulk
# Note:
# - The update for txn_type=AUTH_RULE (singular auth rule edit) is not enabled in this batch file.
# It is applied separately after this batch file has been run and the new rules have been reviewed and validated.
# This ensures rules can be updated or the batch file corrected and rerun before that ability to edit the rules is finally secured.
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
# Batch Edit Auth Rules (AUTH_RULES = 122)
# - Require 2 Trustee signatures
ledger auth-rule txn_type=122 action=EDIT field=* old_value=* new_value=* constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit Auth Rules
# - Require 2 Trustee signatures
# - DISABLED ON PURPOSE - DO NOT UNCOMMENT!
# - Here for reference only. To be run after this batch file have been successfully run and all other rules have been set.
# ledger auth-rule txn_type=AUTH_RULE action=EDIT field=* old_value=* new_value=* constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# =================================================================================================================================================================
# =================================================================================================================================================================
# Add/Edit AML/TAA
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
# Add AML
# - Require 2 Trustee signatures
ledger auth-rule txn_type=TXN_AUTHR_AGRMT_AML action=ADD field=* old_value=* new_value=* constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Add TAA
# - Require 2 Trustee signatures
ledger auth-rule txn_type=TXN_AUTHR_AGRMT action=ADD field=* old_value=* new_value=* constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# Edit TAA
# - Require 2 Trustee signatures
ledger auth-rule txn_type=TXN_AUTHR_AGRMT action=EDIT field=* old_value=* new_value=* constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# =================================================================================================================================================================
# =================================================================================================================================================================
# Add DISABLE_ALL_TXN_AUTHR_AGRMTS (8)
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
# - Require 2 Trustee signatures
ledger auth-rule txn_type=8 action=ADD field=* old_value=* new_value=* constraint="{"sig_count":2,"role":"0","constraint_id":"ROLE","need_to_be_owner":false}"
# =================================================================================================================================================================