Repository navigation
Expand file tree
/
Copy pathenforcer_context_synced.go
More file actions
485 lines (417 loc) · 21.6 KB
/
Copy pathenforcer_context_synced.go
File metadata and controls
485 lines (417 loc) · 21.6 KB
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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package casbin
import "context"
var _ IEnforcerContext = &SyncedContextEnforcer{}
// SyncedContextEnforcer wraps ContextEnforcer and provides synchronized access.
type SyncedContextEnforcer struct {
*SyncedEnforcer
ctxEnforcer *ContextEnforcer
}
// NewSyncedContextEnforcer creates a synchronized context-aware enforcer via file or DB.
func NewSyncedContextEnforcer(params ...interface{}) (*SyncedContextEnforcer, error) {
e, err := NewContextEnforcer(params...)
if err != nil {
return nil, err
}
ctxEnforcer := e.(*ContextEnforcer)
return &SyncedContextEnforcer{
SyncedEnforcer: &SyncedEnforcer{
Enforcer: ctxEnforcer.Enforcer,
stopAutoLoad: make(chan struct{}, 1),
},
ctxEnforcer: ctxEnforcer,
}, nil
}
// LoadPolicyCtx loads all policy rules from the storage with context and synchronization.
func (e *SyncedContextEnforcer) LoadPolicyCtx(ctx context.Context) error {
e.m.RLock()
newModel, err := e.ctxEnforcer.loadPolicyFromAdapterCtx(ctx, e.model)
e.m.RUnlock()
if err != nil {
return err
}
e.m.Lock()
defer e.m.Unlock()
return e.applyModifiedModel(newModel)
}
// LoadFilteredPolicyCtx loads all policy rules from the storage with context and filter with synchronization.
func (e *SyncedContextEnforcer) LoadFilteredPolicyCtx(ctx context.Context, filter interface{}) error {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.LoadFilteredPolicyCtx(ctx, filter)
}
// LoadIncrementalFilteredPolicyCtx append a filtered policy from file/database with context and synchronization.
func (e *SyncedContextEnforcer) LoadIncrementalFilteredPolicyCtx(ctx context.Context, filter interface{}) error {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.LoadIncrementalFilteredPolicyCtx(ctx, filter)
}
// IsFilteredCtx returns true if the loaded policy has been filtered with context and synchronization.
func (e *SyncedContextEnforcer) IsFilteredCtx(ctx context.Context) bool {
e.m.RLock()
defer e.m.RUnlock()
return e.ctxEnforcer.IsFilteredCtx(ctx)
}
// SavePolicyCtx calls ContextEnforcer.SavePolicyCtx with synchronization.
func (e *SyncedContextEnforcer) SavePolicyCtx(ctx context.Context) error {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.SavePolicyCtx(ctx)
}
// AddPolicyCtx adds a policy rule to the storage with context and synchronization.
func (e *SyncedContextEnforcer) AddPolicyCtx(ctx context.Context, params ...interface{}) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddPolicyCtx(ctx, params...)
}
// AddPoliciesCtx adds policy rules to the storage with context and synchronization.
func (e *SyncedContextEnforcer) AddPoliciesCtx(ctx context.Context, rules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddPoliciesCtx(ctx, rules)
}
// AddNamedPolicyCtx adds a named policy rule to the storage with context and synchronization.
func (e *SyncedContextEnforcer) AddNamedPolicyCtx(ctx context.Context, ptype string, params ...interface{}) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddNamedPolicyCtx(ctx, ptype, params...)
}
// AddNamedPoliciesCtx adds named policy rules to the storage with context and synchronization.
func (e *SyncedContextEnforcer) AddNamedPoliciesCtx(ctx context.Context, ptype string, rules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddNamedPoliciesCtx(ctx, ptype, rules)
}
// AddPoliciesExCtx calls ContextEnforcer.AddPoliciesExCtx with synchronization.
func (e *SyncedContextEnforcer) AddPoliciesExCtx(ctx context.Context, rules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddPoliciesExCtx(ctx, rules)
}
// AddNamedPoliciesExCtx calls ContextEnforcer.AddNamedPoliciesExCtx with synchronization.
func (e *SyncedContextEnforcer) AddNamedPoliciesExCtx(ctx context.Context, ptype string, rules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddNamedPoliciesExCtx(ctx, ptype, rules)
}
// RemovePolicyCtx removes a policy rule from the storage with context and synchronization.
func (e *SyncedContextEnforcer) RemovePolicyCtx(ctx context.Context, params ...interface{}) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.RemovePolicyCtx(ctx, params...)
}
// RemoveNamedPolicyCtx removes a named policy rule from the storage with context and synchronization.
func (e *SyncedContextEnforcer) RemoveNamedPolicyCtx(ctx context.Context, ptype string, params ...interface{}) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.RemoveNamedPolicyCtx(ctx, ptype, params...)
}
// RemovePoliciesCtx removes policy rules from the storage with context and synchronization.
func (e *SyncedContextEnforcer) RemovePoliciesCtx(ctx context.Context, rules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.RemovePoliciesCtx(ctx, rules)
}
// RemoveNamedPoliciesCtx removes named policy rules from the storage with context and synchronization.
func (e *SyncedContextEnforcer) RemoveNamedPoliciesCtx(ctx context.Context, ptype string, rules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.RemoveNamedPoliciesCtx(ctx, ptype, rules)
}
// RemoveFilteredPolicyCtx removes policy rules that match the filter from the storage with context and synchronization.
func (e *SyncedContextEnforcer) RemoveFilteredPolicyCtx(ctx context.Context, fieldIndex int, fieldValues ...string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.RemoveFilteredPolicyCtx(ctx, fieldIndex, fieldValues...)
}
// RemoveFilteredNamedPolicyCtx removes named policy rules that match the filter from the storage with context and synchronization.
func (e *SyncedContextEnforcer) RemoveFilteredNamedPolicyCtx(ctx context.Context, ptype string, fieldIndex int, fieldValues ...string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.RemoveFilteredNamedPolicyCtx(ctx, ptype, fieldIndex, fieldValues...)
}
// UpdatePolicyCtx updates a policy rule in the storage with context and synchronization.
func (e *SyncedContextEnforcer) UpdatePolicyCtx(ctx context.Context, oldPolicy []string, newPolicy []string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.UpdatePolicyCtx(ctx, oldPolicy, newPolicy)
}
// UpdateNamedPolicyCtx updates a named policy rule in the storage with context and synchronization.
func (e *SyncedContextEnforcer) UpdateNamedPolicyCtx(ctx context.Context, ptype string, p1 []string, p2 []string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.UpdateNamedPolicyCtx(ctx, ptype, p1, p2)
}
// UpdatePoliciesCtx updates policy rules in the storage with context and synchronization.
func (e *SyncedContextEnforcer) UpdatePoliciesCtx(ctx context.Context, oldPolicies [][]string, newPolicies [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.UpdatePoliciesCtx(ctx, oldPolicies, newPolicies)
}
// UpdateNamedPoliciesCtx updates named policy rules in the storage with context and synchronization.
func (e *SyncedContextEnforcer) UpdateNamedPoliciesCtx(ctx context.Context, ptype string, p1 [][]string, p2 [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.UpdateNamedPoliciesCtx(ctx, ptype, p1, p2)
}
// UpdateFilteredPoliciesCtx updates policy rules that match the filter in the storage with context and synchronization.
func (e *SyncedContextEnforcer) UpdateFilteredPoliciesCtx(ctx context.Context, newPolicies [][]string, fieldIndex int, fieldValues ...string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.UpdateFilteredPoliciesCtx(ctx, newPolicies, fieldIndex, fieldValues...)
}
// UpdateFilteredNamedPoliciesCtx updates named policy rules that match the filter in the storage with context and synchronization.
func (e *SyncedContextEnforcer) UpdateFilteredNamedPoliciesCtx(ctx context.Context, ptype string, newPolicies [][]string, fieldIndex int, fieldValues ...string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.UpdateFilteredNamedPoliciesCtx(ctx, ptype, newPolicies, fieldIndex, fieldValues...)
}
// AddGroupingPolicyCtx adds a grouping policy rule to the storage with context and synchronization.
func (e *SyncedContextEnforcer) AddGroupingPolicyCtx(ctx context.Context, params ...interface{}) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddGroupingPolicyCtx(ctx, params...)
}
// AddGroupingPoliciesCtx adds grouping policy rules to the storage with context and synchronization.
func (e *SyncedContextEnforcer) AddGroupingPoliciesCtx(ctx context.Context, rules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddGroupingPoliciesCtx(ctx, rules)
}
// AddGroupingPoliciesExCtx calls ContextEnforcer.AddGroupingPoliciesExCtx with synchronization.
func (e *SyncedContextEnforcer) AddGroupingPoliciesExCtx(ctx context.Context, rules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddGroupingPoliciesExCtx(ctx, rules)
}
// AddNamedGroupingPolicyCtx adds a named grouping policy rule to the storage with context and synchronization.
func (e *SyncedContextEnforcer) AddNamedGroupingPolicyCtx(ctx context.Context, ptype string, params ...interface{}) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddNamedGroupingPolicyCtx(ctx, ptype, params...)
}
// AddNamedGroupingPoliciesCtx adds named grouping policy rules to the storage with context and synchronization.
func (e *SyncedContextEnforcer) AddNamedGroupingPoliciesCtx(ctx context.Context, ptype string, rules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddNamedGroupingPoliciesCtx(ctx, ptype, rules)
}
// AddNamedGroupingPoliciesExCtx calls ContextEnforcer.AddNamedGroupingPoliciesExCtx with synchronization.
func (e *SyncedContextEnforcer) AddNamedGroupingPoliciesExCtx(ctx context.Context, ptype string, rules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddNamedGroupingPoliciesExCtx(ctx, ptype, rules)
}
// RemoveGroupingPolicyCtx removes a grouping policy rule from the storage with context and synchronization.
func (e *SyncedContextEnforcer) RemoveGroupingPolicyCtx(ctx context.Context, params ...interface{}) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.RemoveGroupingPolicyCtx(ctx, params...)
}
// RemoveNamedGroupingPolicyCtx removes a named grouping policy rule from the storage with context and synchronization.
func (e *SyncedContextEnforcer) RemoveNamedGroupingPolicyCtx(ctx context.Context, ptype string, params ...interface{}) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.RemoveNamedGroupingPolicyCtx(ctx, ptype, params...)
}
// RemoveGroupingPoliciesCtx removes grouping policy rules from the storage with context and synchronization.
func (e *SyncedContextEnforcer) RemoveGroupingPoliciesCtx(ctx context.Context, rules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.RemoveGroupingPoliciesCtx(ctx, rules)
}
// RemoveNamedGroupingPoliciesCtx removes named grouping policy rules from the storage with context and synchronization.
func (e *SyncedContextEnforcer) RemoveNamedGroupingPoliciesCtx(ctx context.Context, ptype string, rules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.RemoveNamedGroupingPoliciesCtx(ctx, ptype, rules)
}
// RemoveFilteredGroupingPolicyCtx removes grouping policy rules that match the filter from the storage with context and synchronization.
func (e *SyncedContextEnforcer) RemoveFilteredGroupingPolicyCtx(ctx context.Context, fieldIndex int, fieldValues ...string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.RemoveFilteredGroupingPolicyCtx(ctx, fieldIndex, fieldValues...)
}
// RemoveFilteredNamedGroupingPolicyCtx removes named grouping policy rules that match the filter from the storage with context and synchronization.
func (e *SyncedContextEnforcer) RemoveFilteredNamedGroupingPolicyCtx(ctx context.Context, ptype string, fieldIndex int, fieldValues ...string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.RemoveFilteredNamedGroupingPolicyCtx(ctx, ptype, fieldIndex, fieldValues...)
}
// UpdateGroupingPolicyCtx updates a grouping policy rule in the storage with context and synchronization.
func (e *SyncedContextEnforcer) UpdateGroupingPolicyCtx(ctx context.Context, oldRule []string, newRule []string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.UpdateGroupingPolicyCtx(ctx, oldRule, newRule)
}
// UpdateNamedGroupingPolicyCtx updates a named grouping policy rule in the storage with context and synchronization.
func (e *SyncedContextEnforcer) UpdateNamedGroupingPolicyCtx(ctx context.Context, ptype string, oldRule []string, newRule []string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.UpdateNamedGroupingPolicyCtx(ctx, ptype, oldRule, newRule)
}
// UpdateGroupingPoliciesCtx updates grouping policy rules in the storage with context and synchronization.
func (e *SyncedContextEnforcer) UpdateGroupingPoliciesCtx(ctx context.Context, oldRules [][]string, newRules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.UpdateGroupingPoliciesCtx(ctx, oldRules, newRules)
}
// UpdateNamedGroupingPoliciesCtx updates named grouping policy rules in the storage with context and synchronization.
func (e *SyncedContextEnforcer) UpdateNamedGroupingPoliciesCtx(ctx context.Context, ptype string, oldRules [][]string, newRules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.UpdateNamedGroupingPoliciesCtx(ctx, ptype, oldRules, newRules)
}
// SelfAddPolicyCtx adds a policy rule to the current policy with context and synchronization.
func (e *SyncedContextEnforcer) SelfAddPolicyCtx(ctx context.Context, sec string, ptype string, rule []string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.SelfAddPolicyCtx(ctx, sec, ptype, rule)
}
// SelfAddPoliciesCtx adds policy rules to the current policy with context and synchronization.
func (e *SyncedContextEnforcer) SelfAddPoliciesCtx(ctx context.Context, sec string, ptype string, rules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.SelfAddPoliciesCtx(ctx, sec, ptype, rules)
}
// SelfAddPoliciesExCtx calls ContextEnforcer.SelfAddPoliciesExCtx with synchronization.
func (e *SyncedContextEnforcer) SelfAddPoliciesExCtx(ctx context.Context, sec string, ptype string, rules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.SelfAddPoliciesExCtx(ctx, sec, ptype, rules)
}
// SelfRemovePolicyCtx removes a policy rule from the current policy with context and synchronization.
func (e *SyncedContextEnforcer) SelfRemovePolicyCtx(ctx context.Context, sec string, ptype string, rule []string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.SelfRemovePolicyCtx(ctx, sec, ptype, rule)
}
// SelfRemovePoliciesCtx removes policy rules from the current policy with context and synchronization.
func (e *SyncedContextEnforcer) SelfRemovePoliciesCtx(ctx context.Context, sec string, ptype string, rules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.SelfRemovePoliciesCtx(ctx, sec, ptype, rules)
}
// SelfRemoveFilteredPolicyCtx removes policy rules that match the filter from the current policy with context and synchronization.
func (e *SyncedContextEnforcer) SelfRemoveFilteredPolicyCtx(ctx context.Context, sec string, ptype string, fieldIndex int, fieldValues ...string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.SelfRemoveFilteredPolicyCtx(ctx, sec, ptype, fieldIndex, fieldValues...)
}
// SelfUpdatePolicyCtx updates a policy rule in the current policy with context and synchronization.
func (e *SyncedContextEnforcer) SelfUpdatePolicyCtx(ctx context.Context, sec string, ptype string, oldRule, newRule []string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.SelfUpdatePolicyCtx(ctx, sec, ptype, oldRule, newRule)
}
// SelfUpdatePoliciesCtx updates policy rules in the current policy with context and synchronization.
func (e *SyncedContextEnforcer) SelfUpdatePoliciesCtx(ctx context.Context, sec string, ptype string, oldRules, newRules [][]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.SelfUpdatePoliciesCtx(ctx, sec, ptype, oldRules, newRules)
}
// AddRoleForUserCtx adds a role for a user with context and synchronization.
func (e *SyncedContextEnforcer) AddRoleForUserCtx(ctx context.Context, user string, role string, domain ...string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddRoleForUserCtx(ctx, user, role, domain...)
}
// DeleteRoleForUserCtx deletes a role for a user with context and synchronization.
func (e *SyncedContextEnforcer) DeleteRoleForUserCtx(ctx context.Context, user string, role string, domain ...string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.DeleteRoleForUserCtx(ctx, user, role, domain...)
}
// DeleteRolesForUserCtx deletes all roles for a user with context and synchronization.
func (e *SyncedContextEnforcer) DeleteRolesForUserCtx(ctx context.Context, user string, domain ...string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.DeleteRolesForUserCtx(ctx, user, domain...)
}
// DeleteUserCtx deletes a user with context and synchronization.
func (e *SyncedContextEnforcer) DeleteUserCtx(ctx context.Context, user string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.DeleteUserCtx(ctx, user)
}
// DeleteRoleCtx deletes a role with context and synchronization.
func (e *SyncedContextEnforcer) DeleteRoleCtx(ctx context.Context, role string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.DeleteRoleCtx(ctx, role)
}
// DeletePermissionCtx deletes a permission with context and synchronization.
func (e *SyncedContextEnforcer) DeletePermissionCtx(ctx context.Context, permission ...string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.DeletePermissionCtx(ctx, permission...)
}
// AddPermissionForUserCtx adds a permission for a user or role with context and synchronization.
func (e *SyncedContextEnforcer) AddPermissionForUserCtx(ctx context.Context, user string, permission ...string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddPermissionForUserCtx(ctx, user, permission...)
}
// AddPermissionsForUserCtx adds multiple permissions for a user or role with context and synchronization.
func (e *SyncedContextEnforcer) AddPermissionsForUserCtx(ctx context.Context, user string, permissions ...[]string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddPermissionsForUserCtx(ctx, user, permissions...)
}
// DeletePermissionForUserCtx deletes a permission for a user or role with context and synchronization.
func (e *SyncedContextEnforcer) DeletePermissionForUserCtx(ctx context.Context, user string, permission ...string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.DeletePermissionForUserCtx(ctx, user, permission...)
}
// DeletePermissionsForUserCtx deletes permissions for a user or role with context and synchronization.
func (e *SyncedContextEnforcer) DeletePermissionsForUserCtx(ctx context.Context, user string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.DeletePermissionsForUserCtx(ctx, user)
}
// AddRoleForUserInDomainCtx adds a role for a user inside a domain with context and synchronization.
func (e *SyncedContextEnforcer) AddRoleForUserInDomainCtx(ctx context.Context, user string, role string, domain string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.AddRoleForUserInDomainCtx(ctx, user, role, domain)
}
// DeleteRoleForUserInDomainCtx deletes a role for a user inside a domain with context and synchronization.
func (e *SyncedContextEnforcer) DeleteRoleForUserInDomainCtx(ctx context.Context, user string, role string, domain string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.DeleteRoleForUserInDomainCtx(ctx, user, role, domain)
}
// DeleteRolesForUserInDomainCtx deletes all roles for a user inside a domain with context and synchronization.
func (e *SyncedContextEnforcer) DeleteRolesForUserInDomainCtx(ctx context.Context, user string, domain string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.DeleteRolesForUserInDomainCtx(ctx, user, domain)
}
// DeleteAllUsersByDomainCtx deletes all users associated with the domain with context and synchronization.
func (e *SyncedContextEnforcer) DeleteAllUsersByDomainCtx(ctx context.Context, domain string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.DeleteAllUsersByDomainCtx(ctx, domain)
}
// DeleteDomainsCtx deletes all associated policies for domains with context and synchronization.
func (e *SyncedContextEnforcer) DeleteDomainsCtx(ctx context.Context, domains ...string) (bool, error) {
e.m.Lock()
defer e.m.Unlock()
return e.ctxEnforcer.DeleteDomainsCtx(ctx, domains...)
}