spring - Java - objects access control for users -


i don't know if question title correct - forgive if doesn't. have such problem:

my web application can accessed logged users. each user represented user entity saved in database.

there other entity classes: a, b, c... kept in database. each object of classes a, b... created user. user1 shouldn't see objects created user2.

question:

how can make such access control?

my naive idea:

i can add user property (column in case of db table) every entity class. , during object creation, property take current user id. far ok me. must add current user every database select. , problematic in way.

for example, using spring jpa instead of:

public interface messagerepository extends jparepository<message, long> {     list<message> findbyreceivedatebetween(date from, date to); } 

i must use:

public interface messagerepository extends jparepository<message, long> {     list<message> findbyreceivedatebetweenanduser(date from, date to, user user); } 

my application written in java spring.

how such access control?

you need tag each entity id of creator on database level.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -