Introduction to Security Rules

This chapter provides an overview of the security rules and the rule evaluation model.

Purpose and Scope

Security Rules in Oracle Oracle Backend with Firebase APIs are written using a CEL (Common Expression Language)-based syntax and are evaluated at runtime to determine whether a request should be allowed or denied.

Unlike traditional role-based access control, Oracle Backend with Firebase APIs’s security rules are context-aware, meaning they can inspect both the request metadata and the resource data to make dynamic decisions. This allows developers to enforce policies like:

Security rules in Oracle Backend with Firebase APIs are written using CEL (Common Expression Language) expressions. These rules control access to database operations like read, write, delete, list, and get.

Following are the key points of security rules:

Example 31-1 Security Rules

IF you have a collection called Cities. You want to allow users to read documents only if the Country field is "India", define the rule as follows:

{
  "read": "resource.data.Country == 'India'",
  "write": "request.auth != null && request.auth.uid == resource.data.ownerId"
}

The following variables are available:

Evaluation Model and Application Scope

Rule Evaluation Model

Security rules are evaluated based on three primary components:

  1. Request Context (request)

    • Represents the incoming request from the client SDK or REST API

    • Includes authentication details, request method, path, and payload

  2. Resource Context (resource)

    • Represents the existing data stored in the backend

    • Used to compare against the request data for conditional access

  3. Rule Expression

    • A CEL-based boolean expression that determines access

    • If the expression evaluates to true, the request is allowed

Rule Application Scope

Security rules are applied to the following Oracle Backend with Firebase APIs services:

Rules can be defined, tested, and deployed using the Console UI or SDK methods

Key Capabilities

The Oracle Backend with Firebase APIs rule engine supports:

These capabilities allow developers to write expressive, maintainable, and secure access policies.

See Also:

For a complete list of supported operators and functions, see:

Operators and Functions

Security rules are:

The Console UI provides a rule editor with syntax validation, and the Console allows rule simulation and testing before deployment. Each service allows rules to be defined using the Console UI: