@@ -52,12 +52,27 @@ static int azure_kusto_get_msi_token(struct flb_azure_kusto *ctx)
52
52
return 0 ;
53
53
}
54
54
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 )
57
56
{
58
57
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
+ }
60
71
72
+ static int azure_kusto_get_service_principal_token (struct flb_azure_kusto * ctx )
73
+ {
74
+ int ret ;
75
+
61
76
/* Clear any previous oauth2 payload content */
62
77
flb_oauth2_payload_clear (ctx -> o );
63
78
@@ -86,7 +101,7 @@ static int azure_kusto_get_oauth2_token(struct flb_azure_kusto *ctx)
86
101
}
87
102
88
103
/* Retrieve access token */
89
- token = flb_oauth2_token_get (ctx -> o );
104
+ char * token = flb_oauth2_token_get (ctx -> o );
90
105
if (!token ) {
91
106
flb_plg_error (ctx -> ins , "error retrieving oauth2 access token" );
92
107
return -1 ;
@@ -107,11 +122,18 @@ flb_sds_t get_azure_kusto_token(struct flb_azure_kusto *ctx)
107
122
}
108
123
109
124
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 ;
115
137
}
116
138
}
117
139
@@ -205,7 +227,7 @@ flb_sds_t execute_ingest_csl_command(struct flb_azure_kusto *ctx, const char *cs
205
227
ctx -> ins ,
206
228
"Kusto ingestion command request http_do=%i, HTTP Status: %i" ,
207
229
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 );
209
231
210
232
if (ret == 0 ) {
211
233
if (c -> resp .status == 200 ) {
@@ -1413,7 +1435,7 @@ static void cb_azure_kusto_flush(struct flb_event_chunk *event_chunk,
1413
1435
/* Error handling and cleanup */
1414
1436
if (json ) {
1415
1437
flb_sds_destroy (json );
1416
- }
1438
+ }
1417
1439
if (is_compressed && final_payload ) {
1418
1440
flb_free (final_payload );
1419
1441
}
@@ -1494,16 +1516,18 @@ static struct flb_config_map config_map[] = {
1494
1516
"Set the tenant ID of the AAD application used for authentication" },
1495
1517
{FLB_CONFIG_MAP_STR , "client_id" , (char * )NULL , 0 , FLB_TRUE ,
1496
1518
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" },
1498
1520
{FLB_CONFIG_MAP_STR , "client_secret" , (char * )NULL , 0 , FLB_TRUE ,
1499
1521
offsetof(struct flb_azure_kusto , client_secret ),
1500
1522
"Set the client secret (Application Password) of the AAD application used for "
1501
1523
"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" },
1507
1531
{FLB_CONFIG_MAP_STR , "ingestion_endpoint" , (char * )NULL , 0 , FLB_TRUE ,
1508
1532
offsetof(struct flb_azure_kusto , ingestion_endpoint ),
1509
1533
"Set the Kusto cluster's ingestion endpoint URL (e.g. "
0 commit comments