Fireship · @fireship

Firebase Database Rules Tutorial

Uploaded June 20, 2017 · Length 5:13

Firebase Database Rules Tutorial

Summary

Learn how to set up Firebase Database security rules to control data access and validation.

  • firebase database rules
  • firebase security
  • firebase authentication
  • database security
  • data validation

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    security is a critical concern for any

  2. 0:03

    web application a secure app must

  3. 0:05

    prevent unauthorized database operations

  4. 0:07

    as well as validate the integrity of

  5. 0:10

    incoming data firebase allows you to

  6. 0:13

    define database security logic and a

  7. 0:16

    JSON file that corresponds to the

  8. 0:18

    structure of your database the no sequel

  9. 0:21

    database is essentially just a series of

  10. 0:23

    nodes and each node can have its own

  11. 0:26

    validation and security rules for

  12. 0:29

    example you might have some data that's

  13. 0:31

    accessible to everybody that visits the

  14. 0:33

    site or you might have some data that

  15. 0:35

    should only be accessed by authenticated

  16. 0:38

    users or other data that's only

  17. 0:40

    accessible to the user that created it

  18. 0:42

    and this lesson I'm going to go through

  19. 0:43

    all these different scenarios and show

  20. 0:45

    you how to implement these or Squier

  21. 0:47

    based database rules you can define

  22. 0:50

    firebase rules directly from your

  23. 0:51

    angular project or from the firebase

  24. 0:54

    clone form personally I prefer using the

  25. 0:56

    firebase console because you can send

  26. 0:58

    test requests to make sure that your

  27. 1:00

    rules are working properly there are

  28. 1:03

    three types of rules you can set read

  29. 1:05

    write and validate read controls access

  30. 1:08

    to data write controls the ability to

  31. 1:12

    create edit or delete data and validate

  32. 1:16

    control format of data you can use any

  33. 1:19

    combination of these rules together or

  34. 1:21

    none of them at all there's also a

  35. 1:23

    series of variables that give you access

  36. 1:25

    to firebase resources auth gives you

  37. 1:29

    access to the user authentication state

  38. 1:31

    roof gives you access to the root note

  39. 1:34

    of the database data gives you access to

  40. 1:37

    the data as it appears before the

  41. 1:40

    operation takes place new data shows you

  42. 1:42

    how the data will appear after an

  43. 1:44

    operation takes place now gives you the

  44. 1:47

    UNIX timestamp for the current time

  45. 1:50

    there is also a wild card variable that

  46. 1:53

    you can use to reference any child key

  47. 1:55

    throughout the database now let's run

  48. 1:58

    through some of the most common security

  49. 1:59

    scenarios Google might run into first we