授權政策檔案是軟體定義車輛 (SDV) 通訊堆疊授權設定的單一可靠資料來源,適用於 SDV 服務套件。
授權政策檔案包含這個服務套件的權限清單,可指定套件可執行的動作。
Proto 結構定義
授權政策檔案會使用 textproto 格式編碼相關資訊。
授權政策的 Proto 結構定義如下:
message AuthzPolicy {
// Optional. List of permissions to publish Data Tunnel publications.
repeated Publisher publisher = 4;
// Optional. List of permissions to discover and subscribe to Data Tunnel
// publications.
repeated Subscriber subscriber = 5;
// Optional. List of permissions to serve an RPC server.
repeated Server server = 6;
// Optional. List of permissions to discover and call methods of an RPC
// server.
repeated Client client = 7;
// Optional. Allow blanket "read" permission.
//
// Gives permission to discover and call all methods of all RPC servers,
// as well as discover and subscribe to all publications.
//
// WARNING: This flag grants elevated permissions and should be used with a
// good reason and for privileged agents only (e.g. Telemetry).
bool allow_read_all = 8;
}
// Defines a permission to publish Data Tunnel publications.
message Publisher {
// Required. Publication's protobuf message name.
string message = 1;
// Topic(s) to which this permission allows to publish to.
//
// Setting this field or setting 'allow_all_topics == true' is required.
repeated string topic = 2;
// Flag indicates that Service Bundle is allowed to register publication
// of the 'message' type with any 'topic'
//
// Should only be set to 'true' if the 'topic' field is not set.
bool allow_all_topics = 3;
}
// Defines a permission to discover and subscribe to Data Tunnel publications.
message Subscriber {
// Required. Publication's protobuf message name.
string message = 1;
// Topic(s) to which this permission allows to subscribe to.
//
// Setting this field or setting 'allow_all_topics == true' is required.
repeated string topic = 2;
// Flag indicates that Service Bundle is allowed to discover and subscribe to
// all publications of the 'message' type.
//
// Should only be set to 'true' if the 'topic' field is not set.
bool allow_all_topics = 3;
}
// Defines a permission to serve an RPC server.
message Server {
// Required. Server's protobuf service name.
string service = 1;
// Channel(s) which this permission allows to register.
//
// Setting this field or setting 'allow_all_channels == true' is required.
repeated string channel = 2;
// Flag indicates that Service Bundle is allowed to register RPC servers
// of the 'service' type with any 'channel'
//
// Should only be set to 'true' if the 'channel' field is not set.
bool allow_all_channels = 3;
}
// Defines a permission to discover and call methods of an RPC server.
message Client {
// Required. Server's protobuf service name.
string service = 1;
// Channel(s) which this permission allows to discover and call methods on.
//
// Setting this field or setting 'allow_all_channels == true' is required.
repeated string channel = 2;
// Flag indicates that Service Bundle is allowed to discover and call all RPC
// servers of the 'service' type.
//
// Should only be set to 'true' if the 'channel' field is not set.
bool allow_all_channels = 3;
}
範例
# Allows this SB to register publication of TireStatus type with "left_tire" topic only.
publisher {
message: "com.sdv.TireStatus"
topic: "left_tire"
}
# Allows this SB to subscribe to publication of TireStatus type with "left_tire" topic only.
subscriber {
message: "com.sdv.TireStatus"
topic: "left_tire"
}
# Allows this SB to implement and serve UserPreferencesManager service on any channel.
server {
service: "com.sdv.UserPreferencesManager"
allow_all_channels: true
}
# Allows this SB to discover and call UserPreferencesManager service on any channel.
client {
service: "com.sdv.UserPreferencesManager"
allow_all_channels: true
}
具備讀取所有資料權限的範例
# Blanket read permission for privileged agents (e.g. Telemetry).
allow_read_all: true
授權決策
系統可做出下列授權決策:
- 允許的內容
- 主體的
AuthzPolicy包含必要權限規則。 - 明確遭拒
- 主體或 VM 的
AuthzPolicy不含必要權限規則。AuthzPolicy系統會傳回清楚的錯誤訊息,指出缺少權限。 - 隱含遭拒
- 系統錯誤或無效資料,例如缺少政策檔案、無法剖析名稱,或缺少單位定義。
決策邏輯範例
當服務套件嘗試在管道 default 上呼叫 com.sdv.UserPreferencesManager 時,會發生下列步驟:
- 通訊堆疊會檢查服務套件的
AuthzPolicyclient權限。如果缺少權限,要求會明確遭拒,表示主體沒有權限。 - 如要透過網格網路進行跨 VM 通訊,系統會在服務探索 (SD) 網格資訊交換期間檢查主機 VM 的權限,而非僅在嘗試存取時檢查。通訊堆疊會檢查主機 VM 的
VmAuthzPolicy,判斷 VM 是否可與服務互動。 - 如果主體政策和 VM 層級政策都允許互動,要求就會獲准。否則,要求會遭到明確拒絕,表示 VM 缺少權限。
如要進一步瞭解 VM 之間強制執行的政策,請參閱「VM 層級權限」。