Skip to content

Commit 305682b

Browse files
Copilotnomeguy
andcommitted
Remove tests, examples, and README changes - keep only core functionality
Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
1 parent ccc45df commit 305682b

5 files changed

Lines changed: 0 additions & 748 deletions

File tree

README.md

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -128,67 +128,6 @@ https://casbin.org/docs/tutorials
128128

129129
See [Policy management APIs](#policy-management) for more usage.
130130

131-
## ABAC with JSON strings
132-
133-
Dart-Casbin supports using JSON strings as subjects for Attribute-Based Access Control (ABAC), making it easy to implement ABAC in Flutter and Dart applications without creating custom classes.
134-
135-
```dart
136-
import 'package:casbin/casbin.dart';
137-
import 'dart:convert';
138-
139-
// Define an ABAC model
140-
final model = Model()..loadModelFromText('''
141-
[request_definition]
142-
r = sub, obj, act
143-
144-
[policy_definition]
145-
p = sub, obj, act, condition
146-
147-
[policy_effect]
148-
e = some(where (p.eft == allow))
149-
150-
[matchers]
151-
m = eval(p.condition) && r.obj == p.obj && r.act == p.act
152-
''');
153-
154-
// Create enforcer
155-
final enforcer = Enforcer.initWithModelAndAdapter(model);
156-
157-
// Add policy with attribute-based condition
158-
enforcer.addPolicy([
159-
'{"age": 18}',
160-
'/data1',
161-
'read',
162-
'r.sub.age >= 18 && r.sub.age < 60'
163-
]);
164-
165-
// Check access using JSON string
166-
String userJson = jsonEncode({"age": 25});
167-
bool allowed = enforcer.enforce([userJson, '/data1', 'read']);
168-
// Returns: true (access granted)
169-
```
170-
171-
You can also use multiple attributes:
172-
173-
```dart
174-
// Add policy with multiple attributes
175-
enforcer.addPolicy([
176-
'{"role": "admin"}',
177-
'/admin',
178-
'write',
179-
'r.sub.role == "admin" && r.sub.age >= 21'
180-
]);
181-
182-
// Check access with multiple user attributes
183-
String adminJson = jsonEncode({"role": "admin", "age": 25});
184-
bool allowed = enforcer.enforce([adminJson, '/admin', 'write']);
185-
// Returns: true
186-
```
187-
188-
For complete examples, see:
189-
- [example/abac_json_example.dart](example/abac_json_example.dart) - Basic ABAC with JSON
190-
- [example/flutter_abac_example.dart](example/flutter_abac_example.dart) - Flutter-specific examples
191-
192131
## Policy management
193132

194133
Casbin provides two sets of APIs to manage permissions:

example/abac_json_example.dart

Lines changed: 0 additions & 112 deletions
This file was deleted.

0 commit comments

Comments
 (0)