<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jorge Menjivar on Medium]]></title>
        <description><![CDATA[Stories by Jorge Menjivar on Medium]]></description>
        <link>https://medium.com/@jorgemenjivar?source=rss-96add070ea15------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*c5gZtvMG6LlfMYWIgAVy3g.jpeg</url>
            <title>Stories by Jorge Menjivar on Medium</title>
            <link>https://medium.com/@jorgemenjivar?source=rss-96add070ea15------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 15:13:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jorgemenjivar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A List of Firestore Security Rules for Your Firebase Project]]></title>
            <link>https://medium.com/firebase-developers/a-list-of-firebase-firestore-security-rules-for-your-project-fe46cfaf8b2a?source=rss-96add070ea15------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe46cfaf8b2a</guid>
            <category><![CDATA[firestore-rules]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[firestore]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Jorge Menjivar]]></dc:creator>
            <pubDate>Mon, 29 Jun 2020 02:46:01 GMT</pubDate>
            <atom:updated>2020-08-05T05:50:33.393Z</atom:updated>
            <content:encoded><![CDATA[<p>Security is the most important part of a database. If you don’t properly secure your database, then the data inside is just waiting to be stolen, corrupted, or completely wiped.</p><p>Firestore has some smart and straightforward security rules to help keep the database running safe and smooth. These rules decide what behaviors to allow for the client side.</p><p>Ideally, you want to double check all data on the client side, before it is uploaded to the database. But from time to time, you may run into a bug that is introducing wrong data into Firestore, or even worse, someone modifies your client app (whether it’s your mobile app, web app, or even a server-side component that calls Firebase’s REST API) and attempts to corrupt or steal the data in Firestore.</p><p>That’s why you always want to check requests on the database side as well.</p><blockquote><strong>Have in mind </strong>that Firestore rules do not apply to the Firebase Admin SDK, commonly used in Cloud Functions and other trusted environments.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tylZEzWd8K4jNXry" /><figcaption>Photo by <a href="https://unsplash.com/@donovan_valdivia?utm_source=medium&amp;utm_medium=referral">Andrew &quot;Donovan&quot; Valdivia</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>List of Rules</h3><p>This is a list of simple and complex Firebase Security rules that you can use in your project today. I hope you will find them helpful.</p><h4>Allow only authenticated reads</h4><p>Allow only Firebase <strong>authenticated users</strong> to read documents under the collection named documents:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eca9611e2c9cdb24d736b1481f203a77/href">https://medium.com/media/eca9611e2c9cdb24d736b1481f203a77/href</a></iframe><h4>Allow only users with a verified email to read data</h4><p>Allow only Firebase <strong>authenticated users</strong> with a <strong>verified email</strong> to read documents under the collection named documents:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c58c77f38edf3fc04e18cfbbbe736e4/href">https://medium.com/media/1c58c77f38edf3fc04e18cfbbbe736e4/href</a></iframe><h4>Restrict read/write access to user data</h4><p>Allow a user to read or write only to the document that contains <strong>their user data.</strong></p><p>In this case, we do this by setting the document ID to the <strong>user authentication ID:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae17ddefb221723bf2c38cc38adea7f2/href">https://medium.com/media/ae17ddefb221723bf2c38cc38adea7f2/href</a></iframe><h4>Restrict read/write access to user data, take 2</h4><p>Allow a user to read or write only to the document that contains <strong>their user data.</strong></p><p>In this case, we do this by storing the <strong>user authentication ID </strong>in a field inside the document. The name we gave this variable is <em>userID</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f3da938e7bdd32339b85fb65af226bf/href">https://medium.com/media/6f3da938e7bdd32339b85fb65af226bf/href</a></iframe><h4>Check variable type</h4><p>Allow a field to be written only <strong>if it is a certain variable type</strong>. In this case we ensure the variable score is a number.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dfe74f6c1ba68ae7e471ef46164fe44a/href">https://medium.com/media/dfe74f6c1ba68ae7e471ef46164fe44a/href</a></iframe><h4>Prevent invalid field modifications</h4><p>Allow a number variable named claps to be updated only <strong>if the new value is greater than the one stored inside the database</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/378226efcd3e3a07fa53bfc56d059f3e/href">https://medium.com/media/378226efcd3e3a07fa53bfc56d059f3e/href</a></iframe><h4>Ensure values are in range</h4><p>Allow a <strong>rating of 1 through 5 stars</strong> to be written for a document under the variable name rating<em> </em>only if the rating is a whole number, and a rating does not already exist in the document.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/516e986f72fc059d181f25fc78aa5dfc/href">https://medium.com/media/516e986f72fc059d181f25fc78aa5dfc/href</a></iframe><p>Allow a client to <strong>switch between different modes</strong> in their account. We don’t want the client to create a new mode. So in this case we can choose between two account modes, normal<em> </em>and advanced.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ae9c1b7966a27d2c9e657c020109520/href">https://medium.com/media/8ae9c1b7966a27d2c9e657c020109520/href</a></iframe><p>Allow a client to only <strong>write to certain fields in a map</strong>.</p><p>In this case, we have a map named pants<em> </em>where we have three different colors: black<em>, </em>blue<em>,</em> and pink<em>. </em>We want the client to be able to update the number of pants in inventory, but not create new pants colors.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf1dbe1a80328869fae3d125e0874381/href">https://medium.com/media/bf1dbe1a80328869fae3d125e0874381/href</a></iframe><h4>Ensure documents are complete</h4><p>Allow a client to <strong>write to a map only if the request has all the necessary fields</strong>.</p><p>In this case, we have a map named name<em> </em>where we have three fields: first_name<em>, </em>middle_name<em>,</em> and last_name<em>. </em>We want the client to be able to create a document only if it has the first name and last name set. The middle name is optional.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5c856b87588a29a781a432a164d9b83/href">https://medium.com/media/c5c856b87588a29a781a432a164d9b83/href</a></iframe><p>Allow write to string field named name<em> </em>only if the new string <strong>contains only letters</strong>.</p><p>In this case, we use <strong>regular expressions (RegEx)</strong> to accomplish this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00aa194ddbc4f17c75b680a81af32e70/href">https://medium.com/media/00aa194ddbc4f17c75b680a81af32e70/href</a></iframe><h4>Implement expiration</h4><p>Allow writing to a document only <strong>if the document has not yet expired.</strong></p><p>In this case, the expiration date is in the form of milliseconds since epoch, and is stored in a field named <em>expiration. </em>We use the time in milliseconds that the write request was sent to validate the action.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/da6a7fa789c1628ee863875ad22c8565/href">https://medium.com/media/da6a7fa789c1628ee863875ad22c8565/href</a></iframe><h3>Conclusion</h3><p>The rules above cover a broad field of security, and each case is just a simple way to implement them. To have a secure database, you want to use them in conjunction and improve on the rules listed here. Think of these rules as a starting point, not the finish line. I hope this list of rules is able to guide you and inspire you to write your own custom rules.</p><p>Feel free to respond with some nifty security rules that you come up with.</p><p>You can also check out these links that helped me come out with these rules:</p><ul><li><a href="https://firebase.google.com/docs/firestore/security/get-started">Get started with Cloud Firestore Security Rules | Firebase</a></li><li><a href="https://firebase.google.com/docs/reference/rules/rules">Namespace: rules | Firebase</a></li><li><a href="https://github.com/google/re2/wiki/Syntax">Syntax</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe46cfaf8b2a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/firebase-developers/a-list-of-firebase-firestore-security-rules-for-your-project-fe46cfaf8b2a">A List of Firestore Security Rules for Your Firebase Project</a> was originally published in <a href="https://medium.com/firebase-developers">Firebase Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debugging Firebase Functions in VS Code]]></title>
            <link>https://medium.com/firebase-developers/debugging-firebase-functions-in-vs-code-a1caf22db0b2?source=rss-96add070ea15------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1caf22db0b2</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[visual-studio-code]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[firebase-cloud-functions]]></category>
            <dc:creator><![CDATA[Jorge Menjivar]]></dc:creator>
            <pubDate>Fri, 03 Apr 2020 09:01:58 GMT</pubDate>
            <atom:updated>2020-04-22T07:03:00.567Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fUlRhS5K3tQZg7E4hXojhg.png" /></figure><h3>Introduction</h3><p>Debugging Firebase Cloud Functions as simple as possible. We will assume that you have already set up your project on your computer and that you are using TypeScript, but it should work for JavaScript too.</p><p>The following requires:</p><p>firebase-admin version 8.0.0 or higher.</p><p>firebase-functions version 3.0.0 or higher.</p><h3>Building Project</h3><p>Let’s start by adding the following line in the <strong>package.json file </strong>inside your project, to include <strong>-w</strong>:</p><pre>{</pre><pre>&quot;scripts&quot;: {<br>  ...</pre><pre><strong>  &quot;build:watch&quot;: &quot;tsc -w&quot;,</strong></pre><pre>...<br>}</pre><p>This will help us watch for changes in the code.</p><p>Now for the fun part, open the <strong>terminal in VS Code, </strong>and navigate to the functions folder and build:</p><pre>cd functions</pre><pre>npm run build:watch</pre><p>You should get something like the following:</p><pre>Starting compilation in watch mode...</pre><pre>Found 0 errors. Watching for file changes.</pre><p>Now keep this terminal screen open as it will be watching for changes in case that you modify the code later.</p><h3>Admin Credentials</h3><p>You will need your admin credentials key to access the Firebase and Google APIs locally.</p><p>Go to <a href="https://console.cloud.google.com/iam-admin/serviceaccounts">https://console.cloud.google.com/iam-admin/serviceaccounts</a></p><p>and <strong>select your current project </strong>from the top left, then a few service accounts should appear. Make sure to select <strong>App Engine default service account</strong> then click the three dots on the right side and select <strong>create key</strong>.</p><p>Download this key and place it where you find it most appropriate. <strong>You don’t want it swimming around in GitHub for everyone to see.</strong></p><p>Now open a <strong>second terminal window inside VS Code</strong> by clicking the + sign in the terminal window and point GOOGLE_APPLICATION_CREDENTIALS to the file location. Make sure not to close this terminal window as the credentials are only valid for the current session. You have to load your credentials every time you run an emulator.</p><p>Windows:</p><pre>set GOOGLE_APPLICATION_CREDENTIALS=path\to\key.json</pre><p>Unix:</p><pre>export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json</pre><p>If you accidentally close the terminal just set the credentials location again in a new terminal window and continue using that one.</p><p>For more information, read: <a href="https://cloud.google.com/docs/authentication/getting-started">https://cloud.google.com/docs/authentication/getting-started</a></p><h3>Running Firebase Emulator</h3><p><strong>In the same terminal where you just provided your credentials</strong>, navigate to your functions folder and start the emulator in <strong>inspect functions </strong>mode:</p><pre>firebase emulators:start --inspect-functions</pre><p>You will see something like this for every http function you have in your project:</p><pre>functions[myFunction]: http function initialized (http://localhost:5001/project-name/us-central1/myFunction).<br>✔  emulators: All emulators started, it is now safe to connect.</pre><p>We will use the link returned here to send requests, so keep it handy.</p><p>If you see something like this when calling a function:</p><pre>Error: Could not load the default credentials. Browse to <a href="https://cloud.google.com/docs/authentication/getting-started">https://cloud.google.com/docs/authentication/getting-started</a> for more information.</pre><p>It means you did not load your credentials correctly or you are not using the same terminal where you loaded your credentials. You have to load your credentials every time you run the emulator.</p><p>To stop the emulator, simply close this terminal window.</p><h3>Debugging Configuration</h3><p>Click on the run/debug icon in VS Code on the left side. Then click the gear to edit the <strong>launch.json</strong> file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*6MgUqvSqN4TUDsxV70N4hQ.png" /></figure><p>Edit the file so it looks like this:</p><pre>{</pre><pre>  &quot;version&quot;: &quot;0.2.0&quot;,</pre><pre>  &quot;configurations&quot;: [</pre><pre>    {</pre><pre>      &quot;type&quot;: &quot;node&quot;,</pre><pre>      &quot;request&quot;: &quot;attach&quot;,</pre><pre>      &quot;name&quot;: &quot;Debug&quot;,</pre><pre>      &quot;port&quot;: 9229</pre><pre>    }<br>  ]</pre><pre>}</pre><p>Here we are specifying the debug settings. The debugger should attach to port 9229 (default for firebase emulator) to debug the emulator we previously started.</p><p>Now click the green outlined triangle next to “RUN” to attach the the VS Code debugging tools to the emulator.</p><p>Now we are all set to go.</p><h3>Sending Requests</h3><p>Postman will make it easy to send requests to your functions locally. So let’s install it.</p><p><a href="https://www.postman.com/downloads/">Download Postman | Get Started for Free</a></p><p>Create a request in Postman by using the link that the second VS Code terminal returned earlier, which should be something like this:</p><pre>http://localhost:5001/project-name/us-central1/function</pre><p>And now VS Code should be able to debug that function whenever you call it. It will show debugging information and stop at any breakpoints that you have set up. That is, as long as the debugger is attached.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HzweedBqEuBuQvvVdyZA3A.png" /></figure><h3>Editing Code</h3><p>To rebuild new code after you have made changes all you have to do is save it and click the green outlined triangle to re-attach the debugging tools to the port.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1caf22db0b2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/firebase-developers/debugging-firebase-functions-in-vs-code-a1caf22db0b2">Debugging Firebase Functions in VS Code</a> was originally published in <a href="https://medium.com/firebase-developers">Firebase Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>