Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/vsis3/, /vsigs/, /vsiaz/: better error message when credentials aren't found #11474

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading