Правила авторизации

Файл правил авторизации – это единый источник достоверных данных для конфигурации авторизации стека связи программно-определяемого автомобиля (SDV) для пакета сервисов SDV.

Файл правил авторизации содержит список разрешений для этого пакета сервисов, в котором указано, что может делать пакет.

Схема Proto

Файл правил авторизации использует формат textproto для кодирования соответствующей информации.

Схема прототипа правила авторизации выглядит следующим образом:

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 субъекта содержит необходимое правило предоставления разрешений.
Явный отказ
AuthzPolicy субъекта или AuthzPolicy виртуальной машины не содержит необходимого правила разрешения.
Появится сообщение об ошибке с указанием отсутствующего разрешения.
Отклонено неявным образом
Системная ошибка или недопустимые данные, например отсутствует файл правил, не удалось обработать название или отсутствует определение единицы.

Пример логики принятия решений

Когда пакет сервисов пытается вызвать com.sdv.UserPreferencesManager на канале default, происходит следующее:

  1. Стек связи проверяет наличие разрешения client в файле AuthzPolicy пакета сервиса. Если разрешение отсутствует, запрос явно отклоняется, что указывает на отсутствие разрешения у субъекта.
  2. Для связи между ВМ через ячеистую сеть разрешение хост-ВМ проверяется во время обмена информацией об обнаружении сервисов (SD), а не только во время попытки доступа. Стек связи проверяет VmAuthzPolicy хоста ВМ, чтобы определить, разрешено ли ВМ взаимодействовать с сервисом.
  3. Если взаимодействие разрешено и правилом субъекта, и правилом на уровне ВМ, запрос разрешается. В противном случае будет указано значение Явно запрещено, что означает отсутствие разрешения у виртуальной машины.

Дополнительную информацию о правилах, применяемых между виртуальными машинами, можно найти в разделе Разрешения на уровне виртуальной машины.