You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by kd...@apache.org on 2022/04/24 02:12:10 UTC
[nifi] branch main updated: NIFI-9888 Fix Azure header datetime format
This is an automated email from the ASF dual-hosted git repository.
kdoran pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 83a9e965d2 NIFI-9888 Fix Azure header datetime format
83a9e965d2 is described below
commit 83a9e965d285d77e7f85bd0df7d18e774d20d845
Author: Malthe Borch <mb...@gmail.com>
AuthorDate: Thu Apr 7 07:15:09 2022 +0000
NIFI-9888 Fix Azure header datetime format
This fixes the occasional "403 Forbidden" bug that we have seen, simply because
the signature ends up being invalid due to an invalid datetime format used.
Issue: NIFI-9888
Reference: https://stackoverflow.com/a/51636763/647151
Use statically defined formatter and explain why
This closes #5943.
Signed-off-by: Kevin Doran <kd...@apache.org>
---
.../azure/loganalytics/AbstractAzureLogAnalyticsReportingTask.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/nifi-nar-bundles/nifi-azure-bundle/nifi-azure-reporting-task/src/main/java/org/apache/nifi/reporting/azure/loganalytics/AbstractAzureLogAnalyticsReportingTask.java b/nifi-nar-bundles/nifi-azure-bundle/nifi-azure-reporting-task/src/main/java/org/apache/nifi/reporting/azure/loganalytics/AbstractAzureLogAnalyticsReportingTask.java
index 1017ee54ea..056d05d2a8 100644
--- a/nifi-nar-bundles/nifi-azure-bundle/nifi-azure-reporting-task/src/main/java/org/apache/nifi/reporting/azure/loganalytics/AbstractAzureLogAnalyticsReportingTask.java
+++ b/nifi-nar-bundles/nifi-azure-bundle/nifi-azure-reporting-task/src/main/java/org/apache/nifi/reporting/azure/loganalytics/AbstractAzureLogAnalyticsReportingTask.java
@@ -50,6 +50,9 @@ public abstract class AbstractAzureLogAnalyticsReportingTask extends AbstractRep
private static final Charset UTF8 = Charset.forName("UTF-8");
private static final String HMAC_SHA256_ALG = "HmacSHA256";
+
+ // DateTimeFormatter.RFC_1123_DATE_TIME does not work in every case, such as when a
+ // two-digit day of month is always required, so we are defining our own formatter here.
private static final DateTimeFormatter RFC_1123_DATE_TIME = DateTimeFormatter
.ofPattern("EEE, dd MMM yyyy HH:mm:ss O");
@@ -136,7 +139,7 @@ public abstract class AbstractAzureLogAnalyticsReportingTask extends AbstractRep
final int bodyLength = rawJson.getBytes(UTF8).length;
final ZonedDateTime zNow = ZonedDateTime.now(ZoneOffset.UTC);
- final String nowRfc1123 = zNow.format(DateTimeFormatter.RFC_1123_DATE_TIME);
+ final String nowRfc1123 = zNow.format(RFC_1123_DATE_TIME);
final String nowISO8601 = zNow.format(DateTimeFormatter.ISO_DATE_TIME);
final String createAuthorization = createAuthorization(workspaceId, linuxPrimaryKey, bodyLength, nowRfc1123);
request.addHeader("Authorization", createAuthorization);