Skip to content

Commit c18a11f

Browse files
committed
Merge branch 'feature/aws_credential_api' into 'master'
Added AWS credential provider APIs See merge request app-frameworks/esp-rainmaker!567
2 parents 6229722 + 54ff0fa commit c18a11f

File tree

6 files changed

+502
-17
lines changed

6 files changed

+502
-17
lines changed

components/esp_rainmaker/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ set(core_srcs "src/core/esp_rmaker_core.c"
1313
"src/core/esp_rmaker_schedule.c"
1414
"src/core/esp_rmaker_scenes.c"
1515
"src/core/esp_rmaker_secure_boot_digest.c"
16-
)
16+
"src/core/esp_rmaker_aws_credentials.c"
17+
)
1718

1819
set(priv_req protobuf-c json_parser json_generator
1920
nvs_flash esp_http_client app_update esp-tls mbedtls esp_https_ota

components/esp_rainmaker/Kconfig.projbuild

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ menu "ESP RainMaker Config"
9090
help
9191
ESP RainMaker MQTT Host name.
9292

93+
config ESP_RMAKER_MQTT_CRED_HOST
94+
string "ESP RainMaker MQTT credentials Host"
95+
depends on ESP_RMAKER_SELF_CLAIM || ESP_RMAKER_ASSISTED_CLAIM || ESP_RMAKER_READ_MQTT_HOST_FROM_CONFIG
96+
default "c10yordfvrjdjb.credentials.iot.us-east-1.amazonaws.com"
97+
help
98+
ESP RainMaker MQTT Credential Host.
99+
This endpoint can be used to get expirable AWS security token with different node_policies if available.
100+
For example, With `esp-videostream-v1-NodeRole`, token is issued which grants access to videostream service.
101+
93102
config ESP_RMAKER_MQTT_USE_BASIC_INGEST_TOPICS
94103
bool "Use Basic Ingest Topics"
95104
default y

components/esp_rainmaker/idf_component.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## IDF Component Manager Manifest File
2-
version: "1.7.6"
2+
version: "1.7.7"
33
description: ESP RainMaker firmware agent
44
url: https://github.com/espressif/esp-rainmaker/tree/master/components/esp_rainmaker
55
repository: https://github.com/espressif/esp-rainmaker.git
@@ -13,7 +13,7 @@ dependencies:
1313
espressif/esp_secure_cert_mgr:
1414
version: "^2.2.1"
1515
espressif/rmaker_common:
16-
version: "~1.5.0"
16+
version: ">=1.5.2"
1717
espressif/json_parser:
1818
version: "~1.0.3"
1919
espressif/json_generator:

components/esp_rainmaker/include/esp_rmaker_core.h

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
1+
/*
2+
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
147
#pragma once
8+
159
#include <stdint.h>
1610
#include <stdbool.h>
1711
#include <esp_err.h>
@@ -1129,6 +1123,50 @@ esp_err_t esp_rmaker_param_report_simple_ts_data(const esp_rmaker_param_t *param
11291123
* @return ESP_OK on success, appropriate error on failure.
11301124
*/
11311125
esp_err_t esp_rmaker_cmd_response_publish(void *output, size_t output_len);
1126+
1127+
/**
1128+
* @brief Structure to hold AWS temporary credentials.
1129+
*/
1130+
typedef struct {
1131+
char *access_key; /*!< AWS Access Key ID (null-terminated string, heap-allocated) */
1132+
uint32_t access_key_len; /*!< Length of the access key string (excluding null terminator) */
1133+
char *secret_key; /*!< AWS Secret Access Key (null-terminated string, heap-allocated) */
1134+
uint32_t secret_key_len; /*!< Length of the secret key string (excluding null terminator) */
1135+
char *session_token; /*!< AWS Session Token (null-terminated string, heap-allocated) */
1136+
uint32_t session_token_len; /*!< Length of the session token string (excluding null terminator) */
1137+
uint32_t expiration; /*!< Expiration time of the credentials (seconds from now) */
1138+
} esp_rmaker_aws_credentials_t;
1139+
1140+
/** Get AWS region from credential endpoint
1141+
*
1142+
* This function extracts the AWS region from the credential endpoint stored in factory.
1143+
* The region string is allocated on the heap and should be freed by the caller.
1144+
*
1145+
* @return Pointer to allocated region string on success
1146+
* @return NULL on failure
1147+
*/
1148+
char* esp_rmaker_get_aws_region(void);
1149+
1150+
/** Get AWS security token credentials
1151+
*
1152+
* This function fetches AWS temporary credentials by assuming the specified role alias.
1153+
* The credentials are allocated on the heap and should be freed using esp_rmaker_free_aws_credentials().
1154+
*
1155+
* @param[in] role_alias AWS IoT role alias to assume
1156+
*
1157+
* @return Pointer to allocated credentials structure on success
1158+
* @return NULL on failure
1159+
*/
1160+
esp_rmaker_aws_credentials_t* esp_rmaker_get_aws_security_token(const char *role_alias);
1161+
1162+
/** Free AWS credentials structure
1163+
*
1164+
* This function frees the memory allocated for AWS credentials structure and all its members.
1165+
*
1166+
* @param[in] credentials Pointer to credentials structure to free
1167+
*/
1168+
void esp_rmaker_free_aws_credentials(esp_rmaker_aws_credentials_t *credentials);
1169+
11321170
#ifdef __cplusplus
11331171
}
11341172
#endif

0 commit comments

Comments
 (0)