phlask / phlask-data-handlers

Phlask middleware to help make data ingestion and presentation more efficient!
5 stars 2 forks source link

Configuring Security Rules #7

Closed ojimba01 closed 1 year ago

ojimba01 commented 1 year ago

Overview Our current Firebase Realtime Database contains data for various resources. We need to ensure that the data remains in the correct format by creating and configuring Firebase Security Rules. Due to a lack of JavaScript experience, we need assistance in configuring these rules to their full capacity for better control and safety of our database queries.

Task We need a developer experienced in Firebase Security Rules to create rules for our Firebase Realtime Database, using the provided JSON data and example rules as a starting point.

The JSON data we want to validate is as follows: {"1": {"access": "Public", "address": "1020 Lombard St.", "city": "Philadelphia", "description": "Drinking fountain located within the Recreation Center building; subject to recreation center hours", "filtration": "No", "gp_id": "ChIJocPgsybGxokR3QyYHHmQ118", "handicap": "Unsure", "hours": [{"close": {"day": 0, "time": "2100"}, "open": {"day": 0, "time": "0700"}}, {"close": {"day": 1, "time": "2200"}, "open": {"day": 1, "time": "0700"}}, {"close": {"day": 2, "time": "2200"}, "open": {"day": 2, "time": "0700"}}, {"close": {"day": 3, "time": "2200"}, "open": {"day": 3, "time": "0700"}}, {"close": {"day": 4, "time": "2200"}, "open": {"day": 4, "time": "0700"}}, {"close": {"day": 5, "time": "2200"}, "open": {"day": 5, "time": "0700"}}, {"close": {"day": 6, "time": "2100"}, "open": {"day": 6, "time": "0700"}}], "lat": 39.943787, "lon": -75.159048, "norms_rules": "", "organization": "Seger Recreation Center", "permanently_closed": false, "phone": "(215) 686-1780", "quality": "1-4 Missing - Good", "service": "Self-serve", "statement": "", "status": "OPERATIONAL", "tap_type": "Drinking Fountain", "tapnum": 1, "vessel": "No", "zip_code": ""}}

And here's a possible example of how the Firebase rules for this could look like: { "rules": { "$id": { "access": { ".validate": "newData.isString()" }, "address": { ".validate": "newData.isString()" }, "city": { ".validate": "newData.isString()" }, "description": { ".validate": "newData.isString()" }, "filtration": { ".validate": "newData.isString()" }, "gp_id": { ".validate": "newData.isString()" }, "handicap": { ".validate": "newData.isString()" }, "hours": { ".validate": "newData.hasChildren(['close', 'open'])", "close": { ".validate": "newData.hasChildren(['day', 'time'])", "day": { ".validate": "newData.isNumber() && newData.val() >= 0 && newData.val() <= 6" }, "time": { ".validate": "newData.isString() && newData.val().matches(/^(0[0-9]|1[0-9]|2[0-3])[0-5][0-9]$/)" }, "$other": { ".validate": false } }, "open": { ".validate": "newData.hasChildren(['day', 'time'])", "day": { ".validate": "newData.isNumber() && newData.val() >= 0 && newData.val() <= 6" }, "time": { ".validate": "newData.isString() && newData.val().matches(/^(0[0-9]|1[0-9]|2[0-3])[0-5][0-9]$/)" }, "$other": { ".validate": false } }, "$other": { ".validate": false } }, "lat": { ".validate": "newData.isNumber()" }, "lon": { ".validate": "newData.isNumber()" }, "norms_rules": { ".validate": "newData.isString()" }, "organization": { ".validate": "newData.isString()" }, "permanently_closed": { ".validate": "newData.isBoolean()" }, "phone": { ".validate": "newData.isString()" }, "quality": { ".validate": "newData.isString()" }, "service": { ".validate": "newData.isString()" }, "statement": { ".validate": "newData.isString()" }, "status": { ".validate": "newData.isString()" }, "tap_type": { ".validate": "newData.isString()" }, "tapnum": { ".validate": "newData.isNumber()" }, "vessel": { ".validate": "newData.isString()" }, "zip_code": { ".validate": "newData.isString()" } } } } Requirements

Steps to complete this task

  1. Review the provided JSON data and example Firebase Security Rules.
  2. Create the Firebase Security Rules using the JSON data and example rules as a guide.
  3. Test the rules against the current Firebase Realtime Database to ensure they work as expected.
  4. Submit the final Firebase Security Rules.

Please provide an estimate of the time needed to complete this task and any other information you might need to get started. Your assistance in configuring these security rules will help us maintain better control over our database and improve its security.

ojimba01 commented 1 year ago

Since Phlask 2.0 is looking to be released within the next month we are escalating this issue to high priority and this should be handled by Tuesday 4/17 during or before the Phlask Hack Night