firebase-admin.security-rules package

Cloud Firestore 和 Cloud Storage 的安全性規則。

函式

函式 說明
getSecurityRules(應用程式) 取得預設應用程式或特定應用程式的 SecurityRules 服務。admin.securityRules()不需引數即可存取預設應用程式的 SecurityRules 服務,或以 admin.securityRules(app) 存取與 SecurityRules特定應用程式相關的特定服務。

等級

類別 說明
規則集 一組 Firebase 安全性規則。
RulesetMetadataList 規則集中繼資料頁面。
SecurityRules Firebase SecurityRules 服務介面。

介面

介面 說明
RulesetMetadata 與規則集相關聯的必要中繼資料。
RulesFile 包含部分 Firebase 安全性規則的來源檔案。內容包含原始原始碼,包括文字格式、縮排和註解。使用 SecurityRules.createRulesFileFromSource() 方法建立此類型的新執行個體。

getSecurityRules(應用程式)

取得預設應用程式或特定應用程式的 SecurityRules 服務。

呼叫 admin.securityRules() 時無需使用引數,即可存取預設應用程式的 SecurityRules 服務,或做為 admin.securityRules(app) 來存取與特定應用程式相關聯的 SecurityRules 服務。

簽名:

export declare function getSecurityRules(app?: App): SecurityRules;

參數

參數 類型 說明
app 應用程式 用於傳回 SecurityRules 服務 (選用) 的應用程式。如未提供,系統會傳回預設的 SecurityRules 服務。

傳回:

SecurityRules

預設的 SecurityRules 服務 (如未提供應用程式),或與所提供應用程式相關聯的 SecurityRules 服務。

範例 1

// Get the SecurityRules service for the default app
const defaultSecurityRules = getSecurityRules();

範例 2

// Get the SecurityRules service for a given app
const otherSecurityRules = getSecurityRules(otherApp);