Offline/Online Sync in a Real World Ionic Application with CouchDB
This is supposed to be a longer description
Restricting Document Updates
Increase security by restricting who can update documents
PROModule Outline
- Source Code & Resources PRO
- Lesson 1: Introduction PUBLIC
- Lesson 2: Application Requirements PUBLIC
- Lesson 3: A Brief Introduction to NoSQL PUBLIC
- Lesson 4: Introduction to CouchDB PRO
- Lesson 5: Introduction to PouchDB PRO
- Lesson 6: Structuring Data in CouchDB PRO
- Lesson 7: Installing CouchDB Locally PRO
- Lesson 8: Adding Data to Futon PRO
- Lesson 9: Starting the Application PRO
- Lesson 10: Setting up the Basic User Interface PRO
- Lesson 11: Using Design Documents to Create Views in CouchDB PRO
- Lesson 12: Getting Data From CouchDB into Ionic PRO
- Lesson 13: Using Node, Express, and SuperLogin PRO
- Lesson 14: Login and Registration PRO
- Lesson 15: Offline Access and Reauthentication PRO
- Lesson 16: Advanced Form Validation PRO
- Lesson 17: Restricting Document Updates PRO
- Lesson 18: Filtering Data from CouchDB PRO
- Lesson 19: Improving User Experience PRO
- Lesson 20: Migrating to Production PRO
- Lesson 21: Conclusion PRO
Lesson Outline
Restricting Document Updates
Earlier, we added some buttons to edit and delete notices, and we only display those buttons if the author of the notice matches the currently logged in user (we only want users to be able to edit and delete their own notices).
However, you should never rely on the front end to enforce security rules. Javascript is client side, so it's easy enough for people to modify it and get around whatever kind of security you implement to restrict this. In order to enforce these rules, we need to do it outside of the front end. Typically this means having the server handle access control, but in the case of CouchDB we are going to implement security rules directly into the database itself with validate_doc_update
functions.
Using validate_doc_update to Implement Access Control
Previously in this module, we used design documents to implement views for the database. We created a view that allows us to grab a list of notices ordered by the date they were last updated and a list of chats by the date they were created.
We are going to extend our design documents to include a validate_doc_update
function, which is implemented in a very similar way to a view. Instead of supplying a map
function to the view, we will supply a different kind of function to validate_doc_update
.
Let's take a look at the function we will be using right now because I think it will be easier to explain if you can see it first.
Thanks for checking out the preview of this lesson!
You do not have the appropriate membership to view the full lesson. If you would like full access to this module you can view membership options (or log in if you are already have an appropriate membership).