SlideShare a Scribd company logo
Hey yo, can I see your
firebase stuff, AUTH
course you can
An emotionally fraught memoir of database authorization
Firebase - Apps not Ops
 Not just a database it’s an entire application framework and offers….
 Hosting
 Authentication (leveraging many providers or custom email/password)
 File Storage
 Analytics
 Cloud Functions – Server Side Execution.
 Cloud Messaging – By ID, Group or subscribed to a topic
 A strong feeling of belonging
Database Authorization
 This isn’t about who you are but what it is you can do
 Often it’s managed at a user/role level in terms of SQL and can be quite
heavyweight
 Other times with NoSQL DB it can be just lacking altogether
 Firebase is lighter in all regards. It’s essentially a JSON document with some
lovely wrapping tooling around it. You don’t need to install a heavy JDBC
client or management studio to use it. Restful API or through management
console
 So it should be no surprise that setting up the Authorization is pretty lovely as
well.
 The rules we are about to see for controlling access can also put input
validation on fields and indexes for querying
Database Authorization
Example DB Rules
{"rules": {
"foo": {
".read": true,
".write": false
} }}
Or this which allows write operations as long as the value of the /allow_writes/ node is true, there is a
sibling node called ‘Admins’, and there is a child named foo in the newly written data:
"rules": {
"ruleDemo" : {
".read": "auth != null",
".write": "root.child('allow_writes').val() === true &&
newData.child('foo').exists() && data.parent().child('Admins').exists()"
}
Database Authorization
Rules Simulator
 Sandbox for testing your rules out. Try different operations and different data
 Tired of being you? Be someone different
 Spoof authentication to show what happens if you are a certain user
Rules Simulator
Syntax – Helper Methods
 References ala DOM operations (root/child)
 Variables Auth Object including UserID. Below compares it to a variable.
"users": {
"$uid": {
".write": "$uid === auth.uid"
}
 Existing Data vs New Data
// we can write as long as old data or new data does not exist
// in other words, if this is a delete or a create, but not an update
".write": "!data.exists() || !newData.exists()"
Rules as Filters
 Let’s say our successful website selling erotic cakes and other less erotic baked goods is doing
well. We would like for users to be able to only view products which are suitable for work
 We could just write a rule that let’s us do that and then query Products right… NO! Cries and
runs away
 .read and .write rules work from top-down, with shallower rules overriding deeper rules. If
a rule grants read or write permissions at a particular path, then it also grants access to all
child nodes under it.
 Deny by Default so unless we have an explicit rule on /Products we can’t view it even if we
can view 100% of it’s children
Rules not as Filters then fine
 RULES ARE NOT FILTERS says google in a kind of passive aggressive way
https://firebase.google.com/docs/database/security/securing-
data#rules_are_not_filters
 You need to restructure your data and reprioritise your life
 All Public or All Private
Summary
 Firebase allows you to put fine grained control on your data in a nice
declarative way
 You can use helper methods and functions to do some neat things
 You can use the simulator to test your rules after you’ve set them
 Do not use Rules as Filters. It doesn’t work like that but there’s ways around
it
 Firebase got me like
Resources
 https://firebase.google.com/docs/database/security/
 https://www.youtube.com/watch?v=DBKB6r5BFqo
 https://www.youtube.com/watch?v=PUBnlbjZFAI&t=771s
 https://www.youtube.com/watch?v=rtoxRg-kbt0
 https://www.youtube.com/watch?v=6sIZvHOEw6Q

More Related Content

PPTX
Intro to Firebase Realtime Database and Authentication
PDF
Firebase_not_really_yohoho
PPTX
Firebase not really_yohoho
PDF
Five Things You Didn't Know About Firebase Auth
PDF
Introduction, Examples - Firebase
PDF
Firebase-ized your mobile app
PPTX
Tech Winter Break - GDG OnCampus International Institute of Information Techn...
PDF
Modernizing authorization with OpenFGA (Presentation)
Intro to Firebase Realtime Database and Authentication
Firebase_not_really_yohoho
Firebase not really_yohoho
Five Things You Didn't Know About Firebase Auth
Introduction, Examples - Firebase
Firebase-ized your mobile app
Tech Winter Break - GDG OnCampus International Institute of Information Techn...
Modernizing authorization with OpenFGA (Presentation)

Similar to Firebase Authorization (20)

PPTX
Firebase Authentication with Android
PPTX
Firebase ng2 zurich
PPTX
Fire up your mobile app!
PPTX
Introduction to Firebase
PDF
Firebase: Totally Not Parse All Over Again (Unless It Is) (CocoaConf San Jose...
PDF
Firebase: Totally Not Parse All Over Again (Unless It Is)
PDF
"Easy and scalable serverless backend for your next mobile or web app", Arman...
PDF
Workshop "Building Modern Web Applications with Firebase (and Angular)", Arm...
PDF
6 Things You Didn't Know About Firebase Auth
PPT
PDF
Firebase in action 2021
PPTX
Intoduction of FIrebase Realtime Database
PPTX
Day 2 ppt
PDF
Online mobile game server use Firebase realtime aatabase
PDF
MongoDB vs Firebase
PDF
Firebase Tech Talk By Atlogys
PPTX
Advance Mobile Application Development class 07
PPTX
Firebase - A real-time server
PDF
Introduction to Firebase
PPTX
Android and firebase database
Firebase Authentication with Android
Firebase ng2 zurich
Fire up your mobile app!
Introduction to Firebase
Firebase: Totally Not Parse All Over Again (Unless It Is) (CocoaConf San Jose...
Firebase: Totally Not Parse All Over Again (Unless It Is)
"Easy and scalable serverless backend for your next mobile or web app", Arman...
Workshop "Building Modern Web Applications with Firebase (and Angular)", Arm...
6 Things You Didn't Know About Firebase Auth
Firebase in action 2021
Intoduction of FIrebase Realtime Database
Day 2 ppt
Online mobile game server use Firebase realtime aatabase
MongoDB vs Firebase
Firebase Tech Talk By Atlogys
Advance Mobile Application Development class 07
Firebase - A real-time server
Introduction to Firebase
Android and firebase database
Ad

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Big Data Technologies - Introduction.pptx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
NewMind AI Monthly Chronicles - July 2025
PPT
Teaching material agriculture food technology
PDF
Electronic commerce courselecture one. Pdf
PDF
Modernizing your data center with Dell and AMD
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Cloud computing and distributed systems.
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Encapsulation theory and applications.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Network Security Unit 5.pdf for BCA BBA.
NewMind AI Weekly Chronicles - August'25 Week I
Unlocking AI with Model Context Protocol (MCP)
Diabetes mellitus diagnosis method based random forest with bat algorithm
Big Data Technologies - Introduction.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
NewMind AI Monthly Chronicles - July 2025
Teaching material agriculture food technology
Electronic commerce courselecture one. Pdf
Modernizing your data center with Dell and AMD
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Cloud computing and distributed systems.
“AI and Expert System Decision Support & Business Intelligence Systems”
Encapsulation theory and applications.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Ad

Firebase Authorization

  • 1. Hey yo, can I see your firebase stuff, AUTH course you can An emotionally fraught memoir of database authorization
  • 2. Firebase - Apps not Ops  Not just a database it’s an entire application framework and offers….  Hosting  Authentication (leveraging many providers or custom email/password)  File Storage  Analytics  Cloud Functions – Server Side Execution.  Cloud Messaging – By ID, Group or subscribed to a topic  A strong feeling of belonging
  • 3. Database Authorization  This isn’t about who you are but what it is you can do  Often it’s managed at a user/role level in terms of SQL and can be quite heavyweight  Other times with NoSQL DB it can be just lacking altogether  Firebase is lighter in all regards. It’s essentially a JSON document with some lovely wrapping tooling around it. You don’t need to install a heavy JDBC client or management studio to use it. Restful API or through management console  So it should be no surprise that setting up the Authorization is pretty lovely as well.  The rules we are about to see for controlling access can also put input validation on fields and indexes for querying
  • 4. Database Authorization Example DB Rules {"rules": { "foo": { ".read": true, ".write": false } }} Or this which allows write operations as long as the value of the /allow_writes/ node is true, there is a sibling node called ‘Admins’, and there is a child named foo in the newly written data: "rules": { "ruleDemo" : { ".read": "auth != null", ".write": "root.child('allow_writes').val() === true && newData.child('foo').exists() && data.parent().child('Admins').exists()" }
  • 6. Rules Simulator  Sandbox for testing your rules out. Try different operations and different data  Tired of being you? Be someone different  Spoof authentication to show what happens if you are a certain user
  • 8. Syntax – Helper Methods  References ala DOM operations (root/child)  Variables Auth Object including UserID. Below compares it to a variable. "users": { "$uid": { ".write": "$uid === auth.uid" }  Existing Data vs New Data // we can write as long as old data or new data does not exist // in other words, if this is a delete or a create, but not an update ".write": "!data.exists() || !newData.exists()"
  • 9. Rules as Filters  Let’s say our successful website selling erotic cakes and other less erotic baked goods is doing well. We would like for users to be able to only view products which are suitable for work  We could just write a rule that let’s us do that and then query Products right… NO! Cries and runs away  .read and .write rules work from top-down, with shallower rules overriding deeper rules. If a rule grants read or write permissions at a particular path, then it also grants access to all child nodes under it.  Deny by Default so unless we have an explicit rule on /Products we can’t view it even if we can view 100% of it’s children
  • 10. Rules not as Filters then fine  RULES ARE NOT FILTERS says google in a kind of passive aggressive way https://firebase.google.com/docs/database/security/securing- data#rules_are_not_filters  You need to restructure your data and reprioritise your life  All Public or All Private
  • 11. Summary  Firebase allows you to put fine grained control on your data in a nice declarative way  You can use helper methods and functions to do some neat things  You can use the simulator to test your rules after you’ve set them  Do not use Rules as Filters. It doesn’t work like that but there’s ways around it  Firebase got me like
  • 12. Resources  https://firebase.google.com/docs/database/security/  https://www.youtube.com/watch?v=DBKB6r5BFqo  https://www.youtube.com/watch?v=PUBnlbjZFAI&t=771s  https://www.youtube.com/watch?v=rtoxRg-kbt0  https://www.youtube.com/watch?v=6sIZvHOEw6Q

Editor's Notes

  • #11: Rules are applied in an atomic manner. That means that a read or write operation is failed immediately if there isn't a rule at that location or at a parent location that grants access. Even if every affected child path is accessible, reading at the parent location will fail completely. Consider this structure: