Skip to content

Commit b85b8f2

Browse files
fix: modify documents storage access (#98)
1 parent e261ad3 commit b85b8f2

File tree

10 files changed

+8
-22
lines changed

10 files changed

+8
-22
lines changed

apps/institution-ms/app/src/main/resources/config/azure-storage-config.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
blob-storage.account-key=${STORAGE_CREDENTIAL_SECRET}
21
blob-storage.container=${STORAGE_CONTAINER}
32
blob-storage.checkout-template-container=${STORAGE_TEMPLATE_URL}/resources/templates/email/
43
blob-storage.endpoint-suffix = ${STORAGE_ENDPOINT}

apps/institution-ms/connector-api/src/main/java/it/pagopa/selfcare/mscore/config/AzureStorageConfig.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public class AzureStorageConfig {
1616
private String connectionString;
1717
private String accountName;
1818
private String endpointSuffix;
19-
private String accountKey;
2019

2120
private String container;
2221
private String contractPath;

apps/institution-ms/connector/azure-storage/src/main/java/it/pagopa/selfcare/mscore/connector/azure_storage/AzureBlobClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.microsoft.azure.storage.CloudStorageAccount;
44
import com.microsoft.azure.storage.StorageCredentials;
5-
import com.microsoft.azure.storage.StorageCredentialsAccountAndKey;
65
import com.microsoft.azure.storage.StorageException;
76
import com.microsoft.azure.storage.blob.*;
87
import it.pagopa.selfcare.mscore.api.FileStorageConnector;
@@ -22,6 +21,7 @@
2221
import java.io.IOException;
2322
import java.net.URISyntaxException;
2423
import java.nio.file.Paths;
24+
import java.security.InvalidKeyException;
2525

2626
import static it.pagopa.selfcare.mscore.constant.GenericError.*;
2727

@@ -34,15 +34,15 @@ class AzureBlobClient implements FileStorageConnector {
3434
private final CloudBlobClient blobClient;
3535
private final AzureStorageConfig azureStorageConfig;
3636

37-
AzureBlobClient(AzureStorageConfig azureStorageConfig) throws URISyntaxException {
37+
AzureBlobClient(AzureStorageConfig azureStorageConfig) throws URISyntaxException, InvalidKeyException, StorageException {
3838
log.trace("AzureBlobClient.AzureBlobClient");
3939
this.azureStorageConfig = azureStorageConfig;
4040
final CloudStorageAccount storageAccount = buildStorageAccount();
4141
this.blobClient = storageAccount.createCloudBlobClient();
4242
}
4343

44-
private CloudStorageAccount buildStorageAccount() throws URISyntaxException {
45-
StorageCredentials storageCredentials = new StorageCredentialsAccountAndKey(azureStorageConfig.getAccountName(), azureStorageConfig.getAccountKey());
44+
private CloudStorageAccount buildStorageAccount() throws URISyntaxException, InvalidKeyException, StorageException {
45+
StorageCredentials storageCredentials = StorageCredentials.tryParseCredentials(azureStorageConfig.getConnectionString());
4646
return new CloudStorageAccount(storageCredentials,
4747
true,
4848
azureStorageConfig.getEndpointSuffix(),

apps/institution-ms/connector/azure-storage/src/test/java/it/pagopa/selfcare/mscore/connector/azure_storage/config/AzureStorageConfigTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void testGetContractsTemplateContainer4() {
4141
azureStorageConfig.setContainer("42");
4242
azureStorageConfig.setContractPath("42");
4343

44-
assertEquals("AzureStorageConfig(connectionString=42, accountName=null, endpointSuffix=null, accountKey=null, container=42, contractPath=42, checkoutTemplateContainer=null)", azureStorageConfig.toString());
44+
assertEquals("AzureStorageConfig(connectionString=42, accountName=null, endpointSuffix=null, container=42, contractPath=42, checkoutTemplateContainer=null)", azureStorageConfig.toString());
4545
}
4646
}
4747

infra/container_apps/institution-ms/env/dev-pnpg/terraform.tfvars

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,9 @@ app_settings = [
129129
]
130130

131131
secrets_names = {
132-
"STORAGE_APPLICATION_SECRET" = "contracts-storage-access-key"
133132
"APPLICATIONINSIGHTS_CONNECTION_STRING" = "appinsights-connection-string"
134133
"MONGODB_CONNECTION_URI" = "mongodb-connection-string"
135134
"BLOB_STORAGE_CONN_STRING" = "blob-storage-contract-connection-string"
136-
"STORAGE_CREDENTIAL_SECRET" = "contracts-storage-access-key"
137135
"SMTP_USR" = "smtp-usr"
138136
"SMTP_PSW" = "smtp-psw"
139137
"ONBOARDING_INSTITUTION_ALTERNATIVE_EMAIL" = "party-test-institution-email"

infra/container_apps/institution-ms/env/dev/terraform.tfvars

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ app_settings = [
7474

7575
{
7676
name = "STORAGE_CREDENTIAL_ID"
77-
value = "selcdcontractsstorage"
77+
value = "scdweuardocumentsst01"
7878
},
7979
{
8080
name = "STORAGE_TEMPLATE_URL"
@@ -137,11 +137,9 @@ app_settings = [
137137
]
138138

139139
secrets_names = {
140-
"STORAGE_APPLICATION_SECRET" = "contracts-storage-access-key"
141140
"APPLICATIONINSIGHTS_CONNECTION_STRING" = "appinsights-connection-string"
142141
"MONGODB_CONNECTION_URI" = "mongodb-connection-string"
143142
"BLOB_STORAGE_CONN_STRING" = "documents-storage-connection-string"
144-
"STORAGE_CREDENTIAL_SECRET" = "contracts-storage-access-key"
145143
"SMTP_USR" = "smtp-usr"
146144
"SMTP_PSW" = "smtp-psw"
147145
"ONBOARDING_INSTITUTION_ALTERNATIVE_EMAIL" = "party-test-institution-email"

infra/container_apps/institution-ms/env/prod-pnpg/terraform.tfvars

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,9 @@ app_settings = [
129129

130130

131131
secrets_names = {
132-
"STORAGE_APPLICATION_SECRET" = "contracts-storage-access-key"
133132
"APPLICATIONINSIGHTS_CONNECTION_STRING" = "appinsights-connection-string"
134133
"MONGODB_CONNECTION_URI" = "mongodb-connection-string"
135134
"BLOB_STORAGE_CONN_STRING" = "blob-storage-contract-connection-string"
136-
"STORAGE_CREDENTIAL_SECRET" = "contracts-storage-access-key"
137135
"SMTP_USR" = "smtp-usr"
138136
"SMTP_PSW" = "smtp-psw"
139137
"ONBOARDING_INSTITUTION_ALTERNATIVE_EMAIL" = "party-test-institution-email"

infra/container_apps/institution-ms/env/prod/terraform.tfvars

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ app_settings = [
6969

7070
{
7171
name = "STORAGE_CREDENTIAL_ID"
72-
value = "selcpcontractsstorage"
72+
value = "scpweuardocumentsst01"
7373
},
7474
{
7575
name = "STORAGE_TEMPLATE_URL"
@@ -135,11 +135,9 @@ app_settings = [
135135
]
136136

137137
secrets_names = {
138-
"STORAGE_APPLICATION_SECRET" = "contracts-storage-access-key"
139138
"APPLICATIONINSIGHTS_CONNECTION_STRING" = "appinsights-connection-string"
140139
"MONGODB_CONNECTION_URI" = "mongodb-connection-string"
141140
"BLOB_STORAGE_CONN_STRING" = "documents-storage-connection-string"
142-
"STORAGE_CREDENTIAL_SECRET" = "contracts-storage-access-key"
143141
"SMTP_USR" = "smtp-usr"
144142
"SMTP_PSW" = "smtp-psw"
145143
"ONBOARDING_INSTITUTION_ALTERNATIVE_EMAIL" = "party-test-institution-email"

infra/container_apps/institution-ms/env/uat-pnpg/terraform.tfvars

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,9 @@ app_settings = [
134134
]
135135

136136
secrets_names = {
137-
"STORAGE_APPLICATION_SECRET" = "contracts-storage-access-key"
138137
"APPLICATIONINSIGHTS_CONNECTION_STRING" = "appinsights-connection-string"
139138
"MONGODB_CONNECTION_URI" = "mongodb-connection-string"
140139
"BLOB_STORAGE_CONN_STRING" = "blob-storage-contract-connection-string"
141-
"STORAGE_CREDENTIAL_SECRET" = "contracts-storage-access-key"
142140
"SMTP_USR" = "smtp-usr"
143141
"SMTP_PSW" = "smtp-psw"
144142
"ONBOARDING_INSTITUTION_ALTERNATIVE_EMAIL" = "party-test-institution-email"

infra/container_apps/institution-ms/env/uat/terraform.tfvars

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ app_settings = [
7070

7171
{
7272
name = "STORAGE_CREDENTIAL_ID"
73-
value = "selcucontractsstorage"
73+
value = "scuweuardocumentsst01"
7474
},
7575
{
7676
name = "STORAGE_TEMPLATE_URL"
@@ -137,11 +137,9 @@ app_settings = [
137137
]
138138

139139
secrets_names = {
140-
"STORAGE_APPLICATION_SECRET" = "contracts-storage-access-key"
141140
"APPLICATIONINSIGHTS_CONNECTION_STRING" = "appinsights-connection-string"
142141
"MONGODB_CONNECTION_URI" = "mongodb-connection-string"
143142
"BLOB_STORAGE_CONN_STRING" = "documents-storage-connection-string"
144-
"STORAGE_CREDENTIAL_SECRET" = "contracts-storage-access-key"
145143
"SMTP_USR" = "smtp-usr"
146144
"SMTP_PSW" = "smtp-psw"
147145
"ONBOARDING_INSTITUTION_ALTERNATIVE_EMAIL" = "party-test-institution-email"

0 commit comments

Comments
 (0)