@@ -3,27 +3,29 @@ import {FileAdapter, Model} from 'casbin';
33import PostgresAdapter from 'casbin-pg-adapter' ;
44
55/**
6- * Authorize action method interface
6+ * Authorize action method type
7+ *
8+ * @param userPermissions - Array of permission keys granted to the user
9+ * This is actually a union of permissions picked up based on role
10+ * attached to the user and allowed permissions at specific user level
711 */
8- export interface AuthorizeFn {
9- // userPermissions - Array of permission keys granted to the user
10- // This is actually a union of permissions picked up based on role
11- // attached to the user and allowed permissions at specific user level
12- ( userPermissions : string [ ] , request ?: Request ) : Promise < boolean > ;
13- }
12+ export type AuthorizeFn = (
13+ userPermissions : string [ ] ,
14+ request ?: Request ,
15+ ) => Promise < boolean > ;
1416
1517/**
16- * Casbin authorize action method interface
18+ * Casbin authorize action method type
19+ * @param user - User object corresponding to the logged in user
20+ * @param resVal - value of the resource for which authorisation is being sought
21+ *
1722 */
18- export interface CasbinAuthorizeFn {
19- // user - User object corresponding to the logged in user
20- // resVal - value of the resource for which authorisation is being sought
21- (
22- user : IAuthUserWithPermissions ,
23- resVal : string ,
24- request : Request ,
25- ) : Promise < boolean > ;
26- }
23+ export type CasbinAuthorizeFn = (
24+ user : IAuthUserWithPermissions ,
25+ resVal : string ,
26+ request : Request ,
27+ ) => Promise < boolean > ;
28+
2729export type PermissionObject = {
2830 [ controller : string ] : {
2931 [ method : string ] : string [ ] ;
@@ -82,40 +84,40 @@ export interface UserPermission<T> {
8284}
8385
8486/**
85- * User permissions manipulation method interface .
87+ * User permissions manipulation method type .
8688 *
8789 * This is where we can add our business logic to read and
8890 * union permissions associated to user via role with
8991 * those associated directly to the user.
9092 *
9193 */
92- export interface UserPermissionsFn < T > {
93- ( userPermissions : UserPermission < T > [ ] , rolePermissions : T [ ] ) : T [ ] ;
94- }
94+ export type UserPermissionsFn < T > = (
95+ userPermissions : UserPermission < T > [ ] ,
96+ rolePermissions : T [ ] ,
97+ ) => T [ ] ;
9598
9699/**
97- * Casbin enforcer getter method interface
100+ * Casbin enforcer getter method type
98101 *
99102 * This method provides the Casbin config
100103 * required to initialise a Casbin enforcer
101104 */
102- export interface CasbinEnforcerConfigGetterFn {
103- (
104- authUser : IAuthUserWithPermissions ,
105- resource : string ,
106- isCasbinPolicy ?: boolean ,
107- ) : Promise < CasbinConfig > ;
108- }
105+ export type CasbinEnforcerConfigGetterFn = (
106+ authUser : IAuthUserWithPermissions ,
107+ resource : string ,
108+ isCasbinPolicy ?: boolean ,
109+ ) => Promise < CasbinConfig > ;
109110
110111/**
111- * Casbin resource value modifier method interface
112+ * Casbin resource value modifier method type
112113 *
113114 * This method can help modify the resource value
114115 * for integration with casbin, as per business logic
115116 */
116- export interface CasbinResourceModifierFn {
117- ( pathParams : string [ ] , req : Request ) : Promise < string > ;
118- }
117+ export type CasbinResourceModifierFn = (
118+ pathParams : string [ ] ,
119+ req : Request ,
120+ ) => Promise < string > ;
119121
120122/**
121123 * Casbin config object
0 commit comments