1
1
import 'package:ht_api/src/rbac/permission_service.dart' show PermissionService;
2
2
import 'package:ht_api/src/rbac/permissions.dart' ;
3
- import 'package:ht_shared/ht_shared.dart' ; // Assuming UserRole is defined here
3
+ import 'package:ht_shared/ht_shared.dart' ;
4
+
5
+ final Set <String > _guestUserPermissions = {
6
+ Permissions .headlineRead,
7
+ Permissions .categoryRead,
8
+ Permissions .sourceRead,
9
+ Permissions .countryRead,
10
+ Permissions .appSettingsReadOwned,
11
+ Permissions .appSettingsUpdateOwned,
12
+ Permissions .userPreferencesReadOwned,
13
+ Permissions .userPreferencesUpdateOwned,
14
+ Permissions .appConfigRead,
15
+ };
16
+
17
+ final Set <String > _standardUserPermissions = {
18
+ ..._guestUserPermissions,
19
+ Permissions .userReadOwned,
20
+ Permissions .userUpdateOwned,
21
+ Permissions .userDeleteOwned,
22
+ };
23
+
24
+ final Set <String > _adminPermissions = {
25
+ ..._standardUserPermissions,
26
+ Permissions .headlineCreate,
27
+ Permissions .headlineUpdate,
28
+ Permissions .headlineDelete,
29
+ Permissions .categoryCreate,
30
+ Permissions .categoryUpdate,
31
+ Permissions .categoryDelete,
32
+ Permissions .sourceCreate,
33
+ Permissions .sourceUpdate,
34
+ Permissions .sourceDelete,
35
+ Permissions .countryCreate,
36
+ Permissions .countryUpdate,
37
+ Permissions .countryDelete,
38
+ Permissions .userRead,
39
+ Permissions .appConfigCreate,
40
+ Permissions .appConfigUpdate,
41
+ Permissions .appConfigDelete,
42
+ };
4
43
5
44
/// Defines the mapping between user roles and the permissions they possess.
6
45
///
@@ -13,64 +52,7 @@ import 'package:ht_shared/ht_shared.dart'; // Assuming UserRole is defined here
13
52
/// documentation and clarity. The [PermissionService] should handle the
14
53
/// explicit admin bypass if desired.
15
54
final Map <UserRole , Set <String >> rolePermissions = {
16
- UserRole .admin: {
17
- // Admins typically have all permissions. Listing them explicitly
18
- // or handling the admin bypass in PermissionService are options.
19
- // For clarity, listing some key admin permissions here:
20
- Permissions .headlineCreate,
21
- Permissions .headlineRead,
22
- Permissions .headlineUpdate,
23
- Permissions .headlineDelete,
24
- Permissions .categoryCreate,
25
- Permissions .categoryRead,
26
- Permissions .categoryUpdate,
27
- Permissions .categoryDelete,
28
- Permissions .sourceCreate,
29
- Permissions .sourceRead,
30
- Permissions .sourceUpdate,
31
- Permissions .sourceDelete,
32
- Permissions .countryCreate,
33
- Permissions .countryRead,
34
- Permissions .countryUpdate,
35
- Permissions .countryDelete,
36
- Permissions .userRead, // Admins can read any user profile
37
- Permissions .userReadOwned,
38
- Permissions .userUpdateOwned,
39
- Permissions .userDeleteOwned,
40
- Permissions .appSettingsReadOwned,
41
- Permissions .appSettingsUpdateOwned,
42
- Permissions .userPreferencesReadOwned,
43
- Permissions .userPreferencesUpdateOwned,
44
- Permissions .remoteConfigReadAdmin,
45
- Permissions .remoteConfigUpdateAdmin,
46
- // Add all other permissions here for completeness if not using admin bypass
47
- },
48
- UserRole .standardUser: {
49
- // Standard users can read public/shared data
50
- Permissions .headlineRead,
51
- Permissions .categoryRead,
52
- Permissions .sourceRead,
53
- Permissions .countryRead,
54
- // Standard users can manage their own user-owned data
55
- Permissions .userReadOwned,
56
- Permissions .userUpdateOwned,
57
- Permissions .userDeleteOwned,
58
- Permissions .appSettingsReadOwned,
59
- Permissions .appSettingsUpdateOwned,
60
- Permissions .userPreferencesReadOwned,
61
- Permissions .userPreferencesUpdateOwned,
62
- // Add other permissions for standard users as needed
63
- },
64
- UserRole .guestUser: {
65
- // Guest users have very limited permissions, primarily reading public data
66
- Permissions .headlineRead,
67
- Permissions .categoryRead,
68
- Permissions .sourceRead,
69
- Permissions .countryRead,
70
- // Standard users can manage their own anonymous-owned data
71
- Permissions .appSettingsReadOwned,
72
- Permissions .appSettingsUpdateOwned,
73
- Permissions .userPreferencesReadOwned,
74
- Permissions .userPreferencesUpdateOwned,
75
- },
55
+ UserRole .guestUser: _guestUserPermissions,
56
+ UserRole .standardUser: _standardUserPermissions,
57
+ UserRole .admin: _adminPermissions,
76
58
};
0 commit comments