-
Greetings community. I am working on a project that has several tables with sensitive information, such as personal data, financial information or credentials. The goal is to be able to omit these properties while keeping the metadata intact. To do this, I came up with the idea of adding an attribute that inherits from EnableQuery, adding a property that allows me to parameterize possible related entities and their properties that can be read, but trying to prevent the end user from incorporating sensitive properties, as long as they request an expansion, otherwise everything above is omitted. Attribute:
Usage:
Original query: https://localhost:7219/sapcore/SegUsuarioRol?$expand=Usuario($select=Password)
Original query: https://localhost:7219/sapcore/SegPermiso?$expand=Rol,Modulo($select=Small;$expand=Grupo($expand=Categoria($expand=CategoriaPrincipal))) Thank you very much for any comments you can provide me, as well as if there is already something that I am ignoring, I ask that you share a link or your knowledge with me. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The best way to assess the performance impact on your service is to measure. You can benchmark your service and see how much CPU time is spent on your From a high-level view, the method does seem like it has a lot of room for optimizations. It performs a lot nested O(n) operations that could be expensive if the query string is large and if this occurs on a hot path, e.g. Finally, I think this approach may work well for simple cases but fail for slightly more complex scenarios or edge cases. For a more robust solution, you may consider using a parsed representation of the OData query options (e.g. But if the solution works for your use cases, I don't think this will present the biggest performance bottleneck. But if it does, consider avoiding nested O(n) operations and consider using spans ( |
Beta Was this translation helpful? Give feedback.
-
There are recurring questions and attempts at restricting access to fields and nested properties. I think the library should provide an easier and flexible way for users to control what can be selected and expanded in which contexts. |
Beta Was this translation helpful? Give feedback.
There are recurring questions and attempts at restricting access to fields and nested properties. I think the library should provide an easier and flexible way for users to control what can be selected and expanded in which contexts.