Política de autorização

O arquivo de política de autorização é uma única fonte de verdade para a configuração de autorização da pilha de comunicações do veículo definido por software (SDV) para um pacote de serviços de SDV.

O arquivo de política de autorização contém a lista de permissões para esse pacote de serviços, que especifica o que o pacote pode fazer.

Esquema proto

O arquivo de política de autorização usa o formato textproto para codificar informações relevantes.

O esquema proto da política de autorização é o seguinte:

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

Exemplo

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

Exemplo de leitura privilegiada de tudo

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

Decisão de autorização

O sistema pode tomar as seguintes decisões de autorização:

Permitido
O AuthzPolicy do assunto contém a regra de permissão necessária.
Negado explicitamente
O AuthzPolicy do assunto ou da VM não contém a regra de permissão necessária.AuthzPolicy Uma mensagem de erro clara é retornada indicando a permissão ausente.
Negado implicitamente
Erro do sistema ou dados inválidos, como um arquivo de política ausente, falha ao analisar um nome ou uma definição de unidade ausente.

Exemplo de lógica de decisão

As etapas a seguir ocorrem quando um pacote de serviços tenta chamar com.sdv.UserPreferencesManager no canal default:

  1. A pilha de comunicações verifica o AuthzPolicy do pacote de serviços para a permissão client. Se a permissão estiver ausente, a solicitação será negada explicitamente, indicando que o assunto não tem permissão.
  2. Para comunicação entre VMs na rede mesh, a permissão da VM host é verificada durante a troca de informações da rede de descoberta de serviços (SD, na sigla em inglês), e não apenas durante a tentativa de acesso. A pilha de comunicações verifica o VmAuthzPolicy da VM host para determinar se ela pode interagir com o serviço.
  3. Se a política do assunto e a política no nível da VM permitirem a interação, a solicitação será Permitida. Caso contrário, será Negado explicitamente, indicando que a VM não tem permissão.

Para mais informações sobre políticas aplicadas entre VMs, consulte Permissões no nível da VM.