@@ -52,12 +52,27 @@ static int azure_kusto_get_msi_token(struct flb_azure_kusto *ctx)
5252 return 0 ;
5353}
5454
55- /* Create a new oauth2 context and get a oauth2 token */
56- static int azure_kusto_get_oauth2_token (struct flb_azure_kusto * ctx )
55+ static int azure_kusto_get_workload_identity_token (struct flb_azure_kusto * ctx )
5756{
5857 int ret ;
59- char * token ;
58+
59+ ret = flb_azure_workload_identity_token_get (ctx -> o ,
60+ ctx -> workload_identity_token_file ,
61+ ctx -> client_id ,
62+ ctx -> tenant_id );
63+ if (ret == -1 ) {
64+ flb_plg_error (ctx -> ins , "error retrieving workload identity token" );
65+ return -1 ;
66+ }
67+
68+ flb_plg_debug (ctx -> ins , "Workload identity token retrieved successfully" );
69+ return 0 ;
70+ }
6071
72+ static int azure_kusto_get_service_principal_token (struct flb_azure_kusto * ctx )
73+ {
74+ int ret ;
75+
6176 /* Clear any previous oauth2 payload content */
6277 flb_oauth2_payload_clear (ctx -> o );
6378
@@ -86,7 +101,7 @@ static int azure_kusto_get_oauth2_token(struct flb_azure_kusto *ctx)
86101 }
87102
88103 /* Retrieve access token */
89- token = flb_oauth2_token_get (ctx -> o );
104+ char * token = flb_oauth2_token_get (ctx -> o );
90105 if (!token ) {
91106 flb_plg_error (ctx -> ins , "error retrieving oauth2 access token" );
92107 return -1 ;
@@ -107,11 +122,18 @@ flb_sds_t get_azure_kusto_token(struct flb_azure_kusto *ctx)
107122 }
108123
109124 if (flb_oauth2_token_expired (ctx -> o ) == FLB_TRUE ) {
110- if (ctx -> managed_identity_client_id != NULL ) {
111- ret = azure_kusto_get_msi_token (ctx );
112- }
113- else {
114- ret = azure_kusto_get_oauth2_token (ctx );
125+ switch (ctx -> auth_type ) {
126+ case FLB_AZURE_KUSTO_AUTH_WORKLOAD_IDENTITY :
127+ ret = azure_kusto_get_workload_identity_token (ctx );
128+ break ;
129+ case FLB_AZURE_KUSTO_AUTH_MANAGED_IDENTITY_SYSTEM :
130+ case FLB_AZURE_KUSTO_AUTH_MANAGED_IDENTITY_USER :
131+ ret = azure_kusto_get_msi_token (ctx );
132+ break ;
133+ case FLB_AZURE_KUSTO_AUTH_SERVICE_PRINCIPAL :
134+ default :
135+ ret = azure_kusto_get_service_principal_token (ctx );
136+ break ;
115137 }
116138 }
117139
@@ -205,7 +227,7 @@ flb_sds_t execute_ingest_csl_command(struct flb_azure_kusto *ctx, const char *cs
205227 ctx -> ins ,
206228 "Kusto ingestion command request http_do=%i, HTTP Status: %i" ,
207229 ret , c -> resp .status );
208- flb_plg_debug (ctx -> ins , "Kusto ingestion command HTTP request payload: %.*s" , (int )c -> resp .payload_size , c -> resp .payload );
230+ flb_plg_debug (ctx -> ins , "Kusto ingestion command HTTP response payload: %.*s" , (int )c -> resp .payload_size , c -> resp .payload );
209231
210232 if (ret == 0 ) {
211233 if (c -> resp .status == 200 ) {
@@ -1413,7 +1435,7 @@ static void cb_azure_kusto_flush(struct flb_event_chunk *event_chunk,
14131435 /* Error handling and cleanup */
14141436 if (json ) {
14151437 flb_sds_destroy (json );
1416- }
1438+ }
14171439 if (is_compressed && final_payload ) {
14181440 flb_free (final_payload );
14191441 }
@@ -1494,16 +1516,18 @@ static struct flb_config_map config_map[] = {
14941516 "Set the tenant ID of the AAD application used for authentication" },
14951517 {FLB_CONFIG_MAP_STR , "client_id" , (char * )NULL , 0 , FLB_TRUE ,
14961518 offsetof(struct flb_azure_kusto , client_id ),
1497- "Set the client ID (Application ID) of the AAD application used for authentication" },
1519+ "Set the client ID (Application ID) of the AAD application or the user-assigned managed identity's client ID when using managed identity authentication" },
14981520 {FLB_CONFIG_MAP_STR , "client_secret" , (char * )NULL , 0 , FLB_TRUE ,
14991521 offsetof(struct flb_azure_kusto , client_secret ),
15001522 "Set the client secret (Application Password) of the AAD application used for "
15011523 "authentication" },
1502- {FLB_CONFIG_MAP_STR , "managed_identity_client_id" , (char * )NULL , 0 , FLB_TRUE ,
1503- offsetof(struct flb_azure_kusto , managed_identity_client_id ),
1504- "A managed identity client id to authenticate with. "
1505- "Set to 'system' for system-assigned managed identity. "
1506- "Set the MI client ID (GUID) for user-assigned managed identity." },
1524+ {FLB_CONFIG_MAP_STR , "workload_identity_token_file" , (char * )NULL , 0 , FLB_TRUE ,
1525+ offsetof(struct flb_azure_kusto , workload_identity_token_file ),
1526+ "Set the token file path for workload identity authentication" },
1527+ {FLB_CONFIG_MAP_STR , "auth_type" , "service_principal" , 0 , FLB_TRUE ,
1528+ offsetof(struct flb_azure_kusto , auth_type_str ),
1529+ "Set the authentication type: 'service_principal', 'managed_identity', or 'workload_identity'. "
1530+ "For managed_identity, use 'system' as client_id for system-assigned identity, or specify the managed identity's client ID" },
15071531 {FLB_CONFIG_MAP_STR , "ingestion_endpoint" , (char * )NULL , 0 , FLB_TRUE ,
15081532 offsetof(struct flb_azure_kusto , ingestion_endpoint ),
15091533 "Set the Kusto cluster's ingestion endpoint URL (e.g. "
0 commit comments