Skip to content

Commit

Permalink
Merge pull request #11474 from rouault/better_s3_gcs_az_auth_err_msg
Browse files Browse the repository at this point in the history
/vsis3/, /vsigs/, /vsiaz/: better error message when credentials aren't found
  • Loading branch information
rouault authored Dec 12, 2024
2 parents 87f83c8 + 535fe46 commit 759c902
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 15 deletions.
18 changes: 14 additions & 4 deletions port/cpl_aws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1973,10 +1973,20 @@ bool VSIS3HandleHelper::GetConfiguration(
return true;
}

VSIError(VSIE_AWSInvalidCredentials,
"AWS_SECRET_ACCESS_KEY and AWS_NO_SIGN_REQUEST configuration "
"options not defined, and %s not filled",
osCredentials.c_str());
CPLString osMsg;
osMsg.Printf(
"No valid AWS credentials found. "
"For authenticated requests, you need to set "
"AWS_SECRET_ACCESS_KEY, AWS_ACCESS_KEY_ID or other configuration "
"options, or create a %s file. Consult "
"https://gdal.org/en/stable/user/"
"virtual_file_systems.html#vsis3-aws-s3-files for more details. "
"For unauthenticated requests on public resources, set the "
"AWS_NO_SIGN_REQUEST configuration option to YES.",
osCredentials.c_str());
CPLDebug("GS", "%s", osMsg.c_str());
VSIError(VSIE_AWSInvalidCredentials, "%s", osMsg.c_str());

return false;
}

Expand Down
16 changes: 11 additions & 5 deletions port/cpl_azure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,11 +788,17 @@ bool VSIAzureBlobHandleHelper::GetConfiguration(
}

const char *pszMsg =
"Missing AZURE_STORAGE_ACCOUNT+"
"(AZURE_STORAGE_ACCESS_KEY or AZURE_STORAGE_SAS_TOKEN or "
"AZURE_NO_SIGN_REQUEST) or "
"AZURE_STORAGE_CONNECTION_STRING "
"configuration options or Azure CLI configuration file";
"No valid Azure credentials found. "
"For authenticated requests, you need to set "
"AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_ACCESS_KEY, "
"AZURE_STORAGE_SAS_TOKEN, "
"AZURE_STORAGE_CONNECTION_STRING, or other configuration "
"options. Consult "
"https://gdal.org/en/stable/user/"
"virtual_file_systems.html#vsiaz-microsoft-azure-blob-files "
"for more details. "
"For unauthenticated requests on public resources, set the "
"AZURE_NO_SIGN_REQUEST configuration option to YES.";
CPLDebug("AZURE", "%s", pszMsg);
VSIError(VSIE_AWSInvalidCredentials, "%s", pszMsg);
return false;
Expand Down
18 changes: 12 additions & 6 deletions port/cpl_google_cloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,12 +706,18 @@ bool VSIGSHandleHelper::GetConfiguration(const std::string &osPathForOption,
}

CPLString osMsg;
osMsg.Printf("GS_SECRET_ACCESS_KEY+GS_ACCESS_KEY_ID, "
"GS_OAUTH2_REFRESH_TOKEN or "
"GOOGLE_APPLICATION_CREDENTIALS or "
"GS_OAUTH2_PRIVATE_KEY+GS_OAUTH2_CLIENT_EMAIL and %s, "
"or GS_NO_SIGN_REQUEST=YES configuration options not defined",
osCredentials.c_str());
osMsg.Printf(
"No valid GCS credentials found. "
"For authenticated requests, you need to set "
"GS_SECRET_ACCESS_KEY, GS_ACCESS_KEY_ID, GS_OAUTH2_REFRESH_TOKEN, "
"GOOGLE_APPLICATION_CREDENTIALS, or other configuration "
"options, or create a %s file. Consult "
"https://gdal.org/en/stable/user/"
"virtual_file_systems.html#vsigs-google-cloud-storage-files "
"for more details. "
"For unauthenticated requests on public resources, set the "
"GS_NO_SIGN_REQUEST configuration option to YES.",
osCredentials.c_str());

CPLDebug("GS", "%s", osMsg.c_str());
VSIError(VSIE_AWSInvalidCredentials, "%s", osMsg.c_str());
Expand Down

0 comments on commit 759c902

Please sign in to comment.