mirror of
https://github.com/paralus/paralus.git
synced 2026-05-06 08:26:53 +00:00
Invalidate casbin cache after every update
This commit is contained in:
@@ -33,6 +33,7 @@ type authzService struct {
|
||||
}
|
||||
|
||||
func NewAuthzService(db *bun.DB, en *casbin.CachedEnforcer) AuthzService {
|
||||
// en.EnableCache(false) // disables caching in casbin
|
||||
return &authzService{
|
||||
db: db,
|
||||
enforcer: en,
|
||||
@@ -257,6 +258,7 @@ func (s *authzService) CreatePolicies(ctx context.Context, p *authzpbv1.Policies
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
s.enforcer.InvalidateCache()
|
||||
return &authzpbv1.BoolReply{Res: res}, nil
|
||||
}
|
||||
|
||||
@@ -266,6 +268,7 @@ func (s *authzService) DeletePolicies(ctx context.Context, p *authzpbv1.Policy)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
s.enforcer.InvalidateCache()
|
||||
return &authzpbv1.BoolReply{Res: res}, nil
|
||||
}
|
||||
|
||||
@@ -289,6 +292,7 @@ func (s *authzService) CreateUserGroups(ctx context.Context, p *authzpbv1.UserGr
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
s.enforcer.InvalidateCache()
|
||||
return &authzpbv1.BoolReply{Res: res}, nil
|
||||
}
|
||||
|
||||
@@ -299,6 +303,7 @@ func (s *authzService) DeleteUserGroups(ctx context.Context, p *authzpbv1.UserGr
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
s.enforcer.InvalidateCache()
|
||||
return &authzpbv1.BoolReply{Res: res}, nil
|
||||
}
|
||||
|
||||
@@ -323,6 +328,7 @@ func (s *authzService) CreateRolePermissionMappings(ctx context.Context, p *auth
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
s.enforcer.InvalidateCache()
|
||||
return &authzpbv1.BoolReply{Res: res}, nil
|
||||
}
|
||||
|
||||
@@ -332,5 +338,6 @@ func (s *authzService) DeleteRolePermissionMappings(ctx context.Context, p *auth
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
s.enforcer.InvalidateCache()
|
||||
return &authzpbv1.BoolReply{Res: res}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user