Zasada autoryzacji

Plik zasad autoryzacji jest jedynym źródłem wiarygodnych danych dotyczących konfiguracji autoryzacji stosu komunikacyjnego pojazdu definiowanego programowo (SDV) w przypadku pakietu usług SDV.

Plik zasad autoryzacji zawiera listę uprawnień dla tego pakietu usług, która określa, co pakiet może robić.

Schemat proto

Plik zasad autoryzacji używa formatu textproto do kodowania odpowiednich informacji.

Schemat proto zasady autoryzacji wygląda tak:

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;
}

Przykład

# 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
}

Przykład uprawnień do odczytu wszystkiego

# Blanket read permission for privileged agents (e.g. Telemetry).
allow_read_all: true

Decyzja o autoryzacji

System może podejmować te decyzje dotyczące autoryzacji:

Dozwolone:
AuthzPolicy podmiotu zawiera wymaganą regułę zatwierdzania działań.
Bezpośrednia odmowa
AuthzPolicy podmiotu lub AuthzPolicy maszyny wirtualnej nie zawiera wymaganej reguły zatwierdzania działań. Zwracany jest czytelny komunikat o błędzie wskazujący brak uprawnień.
Niejawna odmowa
Błąd systemu lub nieprawidłowe dane, np. brak pliku zasad, niepowodzenie analizy nazwy lub brak definicji jednostki.

Przykładowa logika decyzyjna

Gdy pakiet usług próbuje wywołać com.sdv.UserPreferencesManager na kanale default, wykonywane są te czynności:

  1. Stos komunikacyjny sprawdza, czy pakiet usługi AuthzPolicy ma uprawnienie client. Jeśli uprawnienia brakuje, żądanie jest bezpośrednio odrzucane, co oznacza, że podmiot nie ma uprawnień.
  2. W przypadku komunikacji między maszynami wirtualnymi w sieci typu mesh uprawnienia maszyny wirtualnej hosta są sprawdzane podczas wymiany informacji o sieci typu mesh w ramach wykrywania usług, a nie tylko podczas próby uzyskania dostępu. Stos komunikacyjny sprawdza VmAuthzPolicy maszyny wirtualnej hosta, aby określić, czy maszyna wirtualna może wchodzić w interakcje z usługą.
  3. Jeśli zarówno zasada podmiotu, jak i zasada na poziomie maszyny wirtualnej zezwalają na interakcję, żądanie jest dozwolone. W przeciwnym razie jest to Wyraźna odmowa, co oznacza, że maszyna wirtualna nie ma uprawnień.

Więcej informacji o zasadach egzekwowanych między maszynami wirtualnymi znajdziesz w artykule o uprawnieniach na poziomie maszyny wirtualnej.