简体   繁体   中英

Controlling access to data in MySQL, using Node, Express, Knex and Bookshelf

I am very new to database design and structuring - I have had no formal training and am purely self taught so I apologize in advance if this is a bland question.

I am designing a web app and am thinking to the future as users will have to be able to interact with each other sharing part of their data. I am wondering if there is a standard convention to controlling access to tables in MySQL and how I should generally tackle this problem with code written in NodeJS, ExpressJS, KnexJS, and BookshelfJS.

For example: a user will be matched with another user, both users will be able to see location, favourite book, etc but not able to see last name, birth date. etc.

How do I control this?

If anyone could point me to a few resources they have found helpful that would be great as well.

You seem to have learned a bit of MySQL and its access control features. Well, database user level access control IS NOT used by modern applications -- that could make resource management, like connection pools, very hard to implement. Usually SQL databases backing web applications have a single or, at most, two users: one for general data access and one for admin purposes.

The kind of access control you mentioned MUST be handled by your application code, YOUR code. There are libraries that help take care of authentication (eg passport ) and authorization but ultimately it is YOUR CODE responsibility.

So my answer to your " How do I control this? " question is:

With YOUR code.

This is the whole point of Software Development.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM