security & rules api - firebase

Upload: juank-jo

Post on 07-Jul-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/19/2019 Security & Rules API - Firebase

    1/9

    15/3/2016 Security & Rules API - Firebase

    https://www.firebase.com/docs/security/api/

    .read

    .write

    .validate

    .indexOn

    Rule

    FIREBASE

    Security & Rules API

    Types

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    Grants a client read access to a Firebase location.

    Grants a client write access to a Firebase location.

    Used once a .write  rule has granted access, to ensure that the data being

    written conforms to a specific schema.

    Improves query performance by telling Firebase against which keys you

    want your data indexed.

    https://www.firebase.com/docs/security/api/rule/indexon.htmlhttps://www.firebase.com/docs/security/api/rule/validate.htmlhttps://www.firebase.com/docs/security/api/rule/write.htmlhttps://www.firebase.com/docs/security/api/rule/read.htmlhttps://www.firebase.com/docs/security/api/rule/indexon.htmlhttps://www.firebase.com/docs/security/api/rule/validate.htmlhttps://www.firebase.com/docs/security/api/rule/write.htmlhttps://www.firebase.com/docs/security/api/rule/read.html

  • 8/19/2019 Security & Rules API - Firebase

    2/9

    15/3/2016 Security & Rules API - Firebase

    https://www.firebase.com/docs/security/api/

    auth

    $location

    now

    root

    data

    Variables

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    A variable containing the token payload if a client is authenticated or null

    if the client isn't authenticated.

    A variable that can be used to reference the key of a $location  that wasused earlier in a rule structure.

    Contains the number of milliseconds since the Unix epoch according tothe Firebase servers.

    A RuleDataSnapshot  corresponding to the current data at the root of yourFirebase.

    https://www.firebase.com/docs/security/api/rule/data.htmlhttps://www.firebase.com/docs/security/api/rule/root.htmlhttps://www.firebase.com/docs/security/api/rule/now.htmlhttps://www.firebase.com/docs/security/api/rule/path.htmlhttps://www.firebase.com/docs/security/api/rule/auth.htmlhttps://www.firebase.com/docs/security/api/rule/data.htmlhttps://www.firebase.com/docs/security/api/rule/root.htmlhttps://www.firebase.com/docs/security/api/rule/now.htmlhttps://www.firebase.com/docs/security/api/rule/path.htmlhttps://www.firebase.com/docs/security/api/rule/auth.html

  • 8/19/2019 Security & Rules API - Firebase

    3/9

    15/3/2016 Security & Rules API - Firebase

    https://www.firebase.com/docs/security/api/

    newData

    val() val()

    child() child(childPath)

    parent() parent()

    RuleDataSnapshot

    CODE EXAMPLE

    Methods

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    A RuleDataSnapshot  corresponding to the current data in Firebase at the

    location of the currently executing rule.

    A RuleDataSnapshot  corresponding to the data that will result if the write is

    allowed.

    Gets the primitive value (string, number, boolean, or null ) from this

    RuleDataSnapshot .

    Gets a RuleDataSnapshot  for the location at the specified relative path.

    Gets a RuleDataSnapshot  for the parent location.

    https://www.firebase.com/docs/security/api/ruledatasnapshot/parent.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/child.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/val.htmlhttps://www.firebase.com/docs/security/api/rule/newdata.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/parent.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/child.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/val.htmlhttps://www.firebase.com/docs/security/api/rule/newdata.html

  • 8/19/2019 Security & Rules API - Firebase

    4/9

    15/3/2016 Security & Rules API - Firebase

    https://www.firebase.com/docs/security/api/

    hasChild()  hasChild(childPath)

    hasChildren()  hasChildren([children])

    exists() exists()

    getPriority() getPriority()

    isNumber() isNumber()

    isString() isString()

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    Returns true  if the specified child exists.

    Checks for the existence of children.

    Returns true  if this RuleDataSnapshot  contains any data.

    Gets the priority of the data in a RuleDataSnapshot .

    Returns true  if this RuleDataSnapshot  contains a numeric value.

    https://www.firebase.com/docs/security/api/ruledatasnapshot/isstring.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/isnumber.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/getpriority.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/exists.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/haschildren.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/haschild.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/isstring.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/isnumber.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/getpriority.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/exists.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/haschildren.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/haschild.html

  • 8/19/2019 Security & Rules API - Firebase

    5/9

    15/3/2016 Security & Rules API - Firebase

    https://www.firebase.com/docs/security/api/

    isBoolean() isBoolean()

    length length

    contains()  contains(substring)

    beginsWith()  beginsWith(substring)

    String

    CODE EXAMPLE

    Properties

    CODE EXAMPLE

    Methods

    CODE EXAMPLE

    CODE EXAMPLE

    Returns true  if this RuleDataSnapshot  contains a string value.

    Returns true  if this RuleDataSnapshot  contains a boolean value.

    Returns the length of the string.

    Returns true  if the string contains the specified substring.

    Returns true  if the string begins with the specified substring.

    https://www.firebase.com/docs/security/api/string/beginswith.htmlhttps://www.firebase.com/docs/security/api/string/contains.htmlhttps://www.firebase.com/docs/security/api/string/length.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/isboolean.htmlhttps://www.firebase.com/docs/security/api/string/beginswith.htmlhttps://www.firebase.com/docs/security/api/string/contains.htmlhttps://www.firebase.com/docs/security/api/string/length.htmlhttps://www.firebase.com/docs/security/api/ruledatasnapshot/isboolean.html

  • 8/19/2019 Security & Rules API - Firebase

    6/9

    15/3/2016 Security & Rules API - Firebase

    https://www.firebase.com/docs/security/api/

    endsWith()  endsWidth(substring)

    replace() replace(substring, replacement)

    toLowerCase() toLowerCase()

    toUpperCase() toUpperCase()

    matches(regex) matches(regex)

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    Returns true  if the string ends with the specified substring.

    Returns a copy of the string with all instances of a specified substring

    replaced with the specified replacement string.

    Returns a copy of the string converted to lower case.

    Returns a copy of the string converted to upper case.

    Returns true  if the string matches the specified regular expression literal.

    https://www.firebase.com/docs/security/api/string/matches.htmlhttps://www.firebase.com/docs/security/api/string/touppercase.htmlhttps://www.firebase.com/docs/security/api/string/tolowercase.htmlhttps://www.firebase.com/docs/security/api/string/replace.htmlhttps://www.firebase.com/docs/security/api/string/endswith.htmlhttps://www.firebase.com/docs/security/api/string/matches.htmlhttps://www.firebase.com/docs/security/api/string/touppercase.htmlhttps://www.firebase.com/docs/security/api/string/tolowercase.htmlhttps://www.firebase.com/docs/security/api/string/replace.htmlhttps://www.firebase.com/docs/security/api/string/endswith.html

  • 8/19/2019 Security & Rules API - Firebase

    7/9

    15/3/2016 Security & Rules API - Firebase

    https://www.firebase.com/docs/security/api/

    + (add)

    - (negate or subtract)

    * (multiply)

    / (divide)

    % (modulus)

    OperatorsMethods

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    Used to add variables or for string concatenation.

    Used to negate a value or subtract two values in a rules expression.

    Used to multiply variables in a rules expression.

    Used to divide variables in a rules expression.

    Used to find the remainder of dividing one variable by another in a rules

    expression.

    https://www.firebase.com/docs/security/api/operators/modulus.htmlhttps://www.firebase.com/docs/security/api/operators/divide.htmlhttps://www.firebase.com/docs/security/api/operators/multiply.htmlhttps://www.firebase.com/docs/security/api/operators/negatesubtract.htmlhttps://www.firebase.com/docs/security/api/operators/add.htmlhttps://www.firebase.com/docs/security/api/operators/modulus.htmlhttps://www.firebase.com/docs/security/api/operators/divide.htmlhttps://www.firebase.com/docs/security/api/operators/multiply.htmlhttps://www.firebase.com/docs/security/api/operators/negatesubtract.htmlhttps://www.firebase.com/docs/security/api/operators/add.html

  • 8/19/2019 Security & Rules API - Firebase

    8/9

    15/3/2016 Security & Rules API - Firebase

    https://www.firebase.com/docs/security/api/

    === (equals)

    !== (not equals)

    && (AND)

    || (OR)

    ! (NOT)

     

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    CODE EXAMPLE

    Used to check if two variables in a rules expression have the same type

    and value.

    Used to check if two variables in a rules expression are not equal.

    Evaluates to true  if both operands are true . Used to evaluate multiple

    conditions in a rules expression.

    Evaluates to true  if one operand in the rules expression is true .

    Evaluates to true  if its single operand is false . In rules expressions, the !

    operator is often used to see if data has been written to a location.

    https://www.firebase.com/docs/security/api/operators/not.htmlhttps://www.firebase.com/docs/security/api/operators/or.htmlhttps://www.firebase.com/docs/security/api/operators/and.htmlhttps://www.firebase.com/docs/security/api/operators/notequals.htmlhttps://www.firebase.com/docs/security/api/operators/equals.htmlhttps://www.firebase.com/docs/security/api/operators/not.htmlhttps://www.firebase.com/docs/security/api/operators/or.htmlhttps://www.firebase.com/docs/security/api/operators/and.htmlhttps://www.firebase.com/docs/security/api/operators/notequals.htmlhttps://www.firebase.com/docs/security/api/operators/equals.html

  • 8/19/2019 Security & Rules API - Firebase

    9/9

    15/3/2016 Security & Rules API - Firebase

    https://www firebase com/docs/security/api/

    > (greater than)

    < (less than)

    >= (greater than or equal to)