Firebase database

I want to build an app in which both people can chat together and take notes individually (in different pages) but when I use firebase database it become open to everybody. How can I solve this problem?

Use secure rules.....