how to implement row level security in spring data jpa using hibernate filter or other ways?

后端 未结 2 1552
孤独总比滥情好
孤独总比滥情好 2020-12-31 11:47

One of the very important problems in information softwares is the existence of users with different roles with different duties and access levels. For instance, think of an

2条回答
  •  我在风中等你
    2020-12-31 12:17

    Ali, That's an interesting scenario.

    There are two questions you need to answer here.

    The first question - when exposing the data, is the system just going to do filtering or will you go beyond that? For example, if you expose an operation like users/{id} - then you need to check authorization - and make sure the user has access to that operation. If you simply expose an operation like /users - then all you need is filtering, because you'll simply expose the users that the current user is authorized to see. That distinction will determine a lot of the implementation.


    The second question is - how much manual work are you OK with doing?

    One the one hand, you could adapt the data to what the framework needs - and try to rely as much as possible on the built-in functionality (security expressions, ACL). Or, on the other hand, you could adapt the code to the structure of your data - and do things more manually.

    Those are the two factors I'd focus on first, before anything else - because the implementation will look entirely different based on those 4 decisions.


    Finally, to answer your "can ACL scale" question - two quick notes. One - you need to test. Yes, ACL can scale, but can it scale to 10K or to 100K isn't a question that can be answered concretely, without testing.

    And second, when you do test, think through realistic scenarios. It's certainly important to understand the limits of your solution. But, beyond that, if you think your system will have 1M entities - great. But if it won't - then don't make that a goal.

    Hope that helps.

提交回复
热议问题