From 491112db696d9a5e80d85ec49ab8af1a9fdfad21 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 8 Feb 2026 10:23:22 -0600 Subject: [PATCH] Generate auth check unconditionally in read_message If all messages required auth (both no_conn_ids and conn_only_ids empty), the auth check block would be skipped entirely. Now generates a simple check_authenticated_() call as fallback when there are no exceptions to the default auth requirement. --- script/api_protobuf/api_protobuf.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/script/api_protobuf/api_protobuf.py b/script/api_protobuf/api_protobuf.py index e022b9e2d2a..ece0b5692f4 100755 --- a/script/api_protobuf/api_protobuf.py +++ b/script/api_protobuf/api_protobuf.py @@ -2930,8 +2930,8 @@ static const char *const TAG = "api.service"; out = f"void {class_name}::read_message(uint32_t msg_size, uint32_t msg_type, const uint8_t *msg_data) {{\n" # Auth check block before dispatch switch + out += " // Check authentication/connection requirements\n" if no_conn_ids or conn_only_ids: - out += " // Check authentication/connection requirements\n" out += " switch (msg_type) {\n" if no_conn_ids: @@ -2951,6 +2951,10 @@ static const char *const TAG = "api.service"; out += " }\n" out += " break;\n" out += " }\n" + else: + out += " if (!this->check_authenticated_()) {\n" + out += " return;\n" + out += " }\n" # Dispatch switch out += " switch (msg_type) {\n"