Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,210 --> 00:00:04,680
In this lecture, we're going to review the rules generated by Firebase.
2
00:00:04,680 --> 00:00:09,380
The rules we selected allow anyone to read or write to the database.
3
00:00:09,390 --> 00:00:14,550
It's not an ideal set of rules, but it'll work for the development phase of our application.
4
00:00:14,550 --> 00:00:19,050
I want to take a moment to review the rules to understand better what's going on.
5
00:00:19,320 --> 00:00:25,890
You can navigate to the rules by going to your project's dashboard in Firebase on the sidebar under
6
00:00:25,890 --> 00:00:32,159
the developer section, click the database menu item, then switch over to the Rules tab.
7
00:00:34,400 --> 00:00:37,990
Firebase has an editor we can use to modify the rules.
8
00:00:38,000 --> 00:00:43,030
You may notice that the syntax is similar to Java Scripts object syntax.
9
00:00:43,040 --> 00:00:47,180
Firebase adopts similar syntax, but there are differences.
10
00:00:47,210 --> 00:00:49,940
Let's go through the rules line by line.
11
00:00:50,210 --> 00:00:54,550
The first thing that's being set is the rules version variable.
12
00:00:54,560 --> 00:00:56,390
It's being set to two.
13
00:00:56,420 --> 00:01:00,480
The version must be set before you can proceed to write some rules.
14
00:01:00,500 --> 00:01:06,350
The version determines the syntax you may use different versions, support different features.
15
00:01:06,380 --> 00:01:08,750
Version two is the latest version.
16
00:01:09,020 --> 00:01:12,750
After setting the version, you can start to create the rules.
17
00:01:12,770 --> 00:01:16,600
Creating rules is similar to creating CSS properties.
18
00:01:16,610 --> 00:01:18,770
I don't mean that syntax wise.
19
00:01:18,770 --> 00:01:21,500
In CSS you need to make a selection.
20
00:01:21,500 --> 00:01:25,720
Once you've made a selection, you can start to add different properties.
21
00:01:25,730 --> 00:01:29,300
The properties are applied exclusively to the selection.
22
00:01:29,750 --> 00:01:32,270
That same idea is represented here.
23
00:01:32,270 --> 00:01:34,700
The first step is to select your resource.
24
00:01:34,700 --> 00:01:36,350
The rules should apply to.
25
00:01:36,380 --> 00:01:40,250
After making a selection, we can begin to add the rules.
26
00:01:40,250 --> 00:01:42,590
Rules can be applied universally.
27
00:01:42,590 --> 00:01:43,850
In some cases.
28
00:01:43,850 --> 00:01:48,470
You may want to apply rules to specific resources in your database.
29
00:01:48,470 --> 00:01:53,600
Firebase provides everything you'll need to apply rules to different resources.
30
00:01:53,960 --> 00:01:56,510
The second line is selecting a service.
31
00:01:56,510 --> 00:02:02,780
I mentioned in the previous lecture how Firebase transitioned from a database solution to a back end
32
00:02:02,780 --> 00:02:03,620
solution.
33
00:02:03,830 --> 00:02:06,110
Firebase offers various products.
34
00:02:06,110 --> 00:02:07,760
It calls services.
35
00:02:07,760 --> 00:02:11,030
You can have different rules for different services.
36
00:02:11,060 --> 00:02:14,810
The service keyword allows you to select a service.
37
00:02:14,810 --> 00:02:20,030
In this example, we are selecting the cloud dot firestorm service.
38
00:02:20,030 --> 00:02:23,060
This service refers to the database product.
39
00:02:23,420 --> 00:02:26,990
After selecting the service, we're adding curly brackets.
40
00:02:26,990 --> 00:02:32,060
Anything inside the curly brackets is how you can group selections or rules.
41
00:02:32,060 --> 00:02:34,850
Then we're using the match keyword.
42
00:02:34,850 --> 00:02:40,280
Any time a request is made to the database, it must be to a specific resource.
43
00:02:40,280 --> 00:02:46,940
The match keyword can be used to check if a request is being made to a particular resource.
44
00:02:47,150 --> 00:02:54,080
In this example, we're checking if the request is being made to the databases slash database, slash
45
00:02:54,080 --> 00:02:55,700
documents resource.
46
00:02:55,700 --> 00:02:59,360
The database is directory is where databases are stored.
47
00:02:59,390 --> 00:03:03,410
You can have multiple databases for a Firebase application.
48
00:03:03,410 --> 00:03:05,600
Currently we're on the free plan.
49
00:03:05,600 --> 00:03:07,580
We're allotted one database.
50
00:03:07,580 --> 00:03:12,620
If you'd like to have multiple databases, you'll need to upgrade to a premium plan.
51
00:03:12,620 --> 00:03:16,700
We won't need to upgrade because one database is more than enough.
52
00:03:16,970 --> 00:03:21,050
Every database is listed under the databases directory.
53
00:03:21,200 --> 00:03:28,100
Afterward, we're using a placeholder called Database Fire Store will replace this placeholder with
54
00:03:28,100 --> 00:03:31,730
the name of the database the request is trying to access.
55
00:03:31,730 --> 00:03:37,820
If you want to apply a set of rules to a specific database, you'll need to change this to the name
56
00:03:37,820 --> 00:03:39,050
of the database.
57
00:03:39,200 --> 00:03:43,250
The last segment in the path is the documents directory.
58
00:03:43,280 --> 00:03:47,300
Documents is the terminology for the objects in your database.
59
00:03:47,300 --> 00:03:51,020
We'll discuss documents more in depth in a later lecture.
60
00:03:51,290 --> 00:03:54,620
Inside this condition, we're making another condition.
61
00:03:54,650 --> 00:03:58,940
The condition is checking if the document is equal to two stars.
62
00:03:58,940 --> 00:04:01,610
Two stars are treated as wild cards.
63
00:04:01,610 --> 00:04:07,430
This wild card means the rules inside this condition will apply to any document.
64
00:04:07,790 --> 00:04:11,570
The last thing we're doing inside this condition is adding the rules.
65
00:04:11,570 --> 00:04:14,780
We'll want to have different conditions for reading and writing.
66
00:04:14,900 --> 00:04:17,240
Add the following if true.
67
00:04:19,290 --> 00:04:22,530
After making any changes, you will need to publish them.
68
00:04:22,560 --> 00:04:24,780
There's not much else going in the rules.
69
00:04:24,780 --> 00:04:27,270
The way they're set is fine for now.
70
00:04:27,300 --> 00:04:30,180
If we ever do need to modify them, we will.
71
00:04:30,420 --> 00:04:36,270
In the resource section of this lecture, I provide a link to the rules documentation page.
72
00:04:38,700 --> 00:04:45,120
Everything you'd want to learn about rules can be found here from the syntax to how you can test rules.
73
00:04:45,150 --> 00:04:49,710
I recommend checking it out if you would like to learn more about security rules.
7033
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.