Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new lines and comments in rules.json #30

Closed
sebastianovide opened this issue Jun 14, 2016 · 5 comments · Fixed by #112
Closed

new lines and comments in rules.json #30

sebastianovide opened this issue Jun 14, 2016 · 5 comments · Fixed by #112
Milestone

Comments

@sebastianovide
Copy link
Contributor

Hi all,

we are evaluating how to test firebase rules and this seems to be the only real solution. Our rules.json is getting big, and to keep things clear we add comments and new lines using the same syntax accepted by firebase. Nevertheless targaryen complains about the json format. It doesn't like new lines nor comments in the json.

(Of course I could clean up the file before using targaryen.)

Is there any plans to support new lines and comments ?

thanks

@goldibex
Copy link
Owner

I wasn't actually aware that Firebase permits deviations from conventional
JSON in the format of the security rules. I'll look into this and get back
to you.

On Tue, Jun 14, 2016 at 5:43 AM Sebastian Ovide [email protected]
wrote:

Hi all,

we are evaluating how to test firebase rules and this seems to be the only
real solution. Our rules.json is getting big, and to keep things clear we
add comments and new lines using the same syntax accepted by firebase.
Nevertheless targaryen complains about the json format. It doesn't like new
lines nor comments in the json.

(Of course I could clean up the file before using targaryen.)

Is there any plans to support new lines and comments ?

thanks


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#30, or mute the thread
https://github.com/notifications/unsubscribe/AAK7eyp7eIfvOq9BufxSZU1C4DArqAxaks5qLqHRgaJpZM4I1R5I
.

@SingaporeClouds
Copy link

Here are a few examples that I have seen in valid security rules.

{
    "rules": {
        //anyone can read
        ".read": true,
        ".write": true, // anyone can write
        "users":{
         /* Even multiline comments work
          * TODO: Users should only be able to write their own records. 
          */
        }
    }
}

@alexweber
Copy link

@sebastianovide You can get a better dev experience using the Firebase Bolt Compiler, there's a SublimeText bundle you can use in IDEA too for syntax highlighting. I've found it makes it a bit easier to work with complex rules.

@dinoboff
Copy link
Collaborator

AFAIK it only affected the CLI (and support for comments is implemented in v2.2.0).

When using the API (i.e targaryen.setFirebaseRules(someRule)), targaryen doesn't load the rules and you can parse the rules with something supporting comments and new lines in strings. You can use something like json5 or even yaml if you don't mind converting it to json before uploading the rules.

@dinoboff dinoboff added wontfix and removed wontfix labels Oct 8, 2016
@dinoboff
Copy link
Collaborator

dinoboff commented Oct 8, 2016

AFAIK there's no node parser that support both comments and new lines in json string and writing a JSON parser is out of the scope of this project at this point.

If there's a parser available that support the same features than Firebase, fell free to reopen this issue.

@dinoboff dinoboff closed this as completed Oct 8, 2016
@dinoboff dinoboff removed the wontfix label Jan 4, 2017
dinoboff added a commit to dinoboff/targaryen that referenced this issue Jan 4, 2017
targaryen cli now load rules using firebase-json which support comments and multi lines string.

Fix goldibex#30
@dinoboff dinoboff added this to the 3.0.0 milestone Jan 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants