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

feat(nodo): CHK-1930 add apy-key for auth nodo ws #328

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ NODO_CONNECTION_TIMEOUT=10000
NODO_CONNECTION_STRING="{\"idPSP\":\"idPsp\",\"idChannel\":\"idChannel\",\"idBrokerPSP\":\"12345678912\",\"password\":\"password\"}"
NODO_PARALLEL_REQUESTS=5
NODO_ALL_CCP_ON_TRANSFER_IBAN_ENABLED=false
NODO_NODEFORPSP_API_KEY=KEY
NODO_CLOSEPAYMENT_API_KEY=KEY

PAYMENT_TRANSACTIONS_GATEWAY_URI="http://pagopa-ecommerce-traefik/transactions-gateway"
PAYMENT_TRANSACTIONS_GATEWAY_READ_TIMEOUT=10000
Expand Down
2 changes: 1 addition & 1 deletion .env.intellij.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
AFM_CONNECTION_TIMEOUT=10000;AFM_KEY=key;AFM_READ_TIMEOUT=10000;AFM_URI=http://pagopa-gec-mock:3000/afm/node/calculator-service/v1/fees;CLOSURE_RETRY_INTERVAL=30;ECOMMERCE_PAYMENT_INSTRUMENTS_CONNECTION_TIMEOUT=10000;ECOMMERCE_PAYMENT_INSTRUMENTS_READ_TIMEOUT=10000;ECOMMERCE_PAYMENT_INSTRUMENTS_URI=http://pagopa-ecommerce-payment-methods-service:8083;ECOMMERCE_PAYMENT_METHODS_APY_KEY=payment-methods-key;ECOMMERCE_PAYMENT_METHODS_CONNECTION_TIMEOUT=600;ECOMMERCE_PAYMENT_METHODS_READ_TIMEOUT=600;ECOMMERCE_PAYMENT_METHODS_URI=http://localhost:3000;ECOMMERCE_STORAGE_TRANSIENT_CONNECTION_STRING=DefaultEndpointsProtocol=http\;AccountName=devstoreaccount1\;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==\;QueueEndpoint=http://storage:10001/devstoreaccount1;JWT_SECRET=ODMzNUZBNTZENDg3NTYyREUyNDhGNDdCRUZDNzI3NDMzMzQwNTFEREZGQ0MyQzA5Mjc1RjY2NTQ1NDk5MDMxNzU5NDc0NUVFMTdDMDhGNzk4Q0Q3RENFMEJBODE1NURDREExNEY2Mzk4QzFEMTU0NTExNjUyMEExMzMwMTdDMDk;JWT_TOKEN_VALIDITY_TIME_MILLIS=600000;LOGO_CARD_BRANDING_MAPPING={VISA:'https://dev.checkout.pagopa.it/assets/creditcard/carta_visa.png',MASTERCARD:'https://dev.checkout.pagopa.it/assets/creditcard/carta_mc.png',DINERS:'https://dev.checkout.pagopa.it/assets/creditcard/carta_diners.png',MAESTRO:'https://dev.checkout.pagopa.it/assets/creditcard/carta_maestro.png',AMEX:'https://dev.checkout.pagopa.it/assets/creditcard/carta_amex.png',UNKNOWN:'https://dev.checkout.pagopa.it/assets/creditcard/generic.png'};MONGO_HOST=pagopa-ecommerce-mongo;MONGO_PASSWORD=password;MONGO_PORT=27017;MONGO_USERNAME=admin;NODE_FOR_PSP_URI=/webservices/pof/PagamentiTelematiciPspNodoservice;NODO_CONNECTION_STRING={"idPSP":"idPsp","idChannel":"idChannel","idBrokerPSP":"12345678912","password":"password"};NODO_CONNECTION_TIMEOUT=10000;NODO_HOSTNAME=http://pagopa-node-mock:3002;NODO_PARALLEL_REQUESTS=5;NODO_READ_TIMEOUT=10000;NODOPERPM_CONNECTION_TIMEOUT=10000;NODOPERPM_READ_TIMEOUT=10000;NODOPERPM_URI=/nodo/nodo-per-pm/v1/informazioniPagamento;NOTIFICATIONS_SERVICE_API_KEY=api-key;NOTIFICATIONS_SERVICE_CONNECTION_TIMEOUT=10000;NOTIFICATIONS_SERVICE_READ_TIMEOUT=10000;NOTIFICATIONS_SERVICE_URI=http://pagopa-ecommerce-traefik/notifications-service;PAYMENT_TOKEN_VALIDITY_TIME=120;PAYMENT_TRANSACTIONS_GATEWAY_API_KEY=key;PAYMENT_TRANSACTIONS_GATEWAY_CONNECTION_TIMEOUT=10000;PAYMENT_TRANSACTIONS_GATEWAY_READ_TIMEOUT=10000;PAYMENT_TRANSACTIONS_GATEWAY_URI=http://pagopa-ecommerce-traefik/transactions-gateway;PERSONAL_DATA_VAULT_API_BASE_PATH=http://pagopa-pdv-mock:8092;PERSONAL_DATA_VAULT_API_KEY=personal-data-vault-api-key;QueueEndpoint=http://storage:10001/devstoreaccount1;REDIS_HOST=pagopa-ecommerce-redis;REDIS_PASSWORD=redis_password;REDIS_PORT=6379;REDIS_SSL_ENABLED=false;TRANSACTION_CLOSE_PAYMENT_QUEUE_NAME=pagopa-ecommerce-transactions-close-payment-queue;TRANSACTION_CLOSE_PAYMENT_RETRY_QUEUE_NAME=pagopa-ecommerce-transactions-close-payment-retry-queue;TRANSACTION_EXPIRATION_QUEUE_NAME=pagopa-ecommerce-transactions-expiration-queue;TRANSACTION_NOTIFICATIONS_QUEUE_NAME=pagopa-ecommerce-transactions-notifications-queue;TRANSACTION_REFUND_QUEUE_NAME=pagopa-ecommerce-transactions-refund-queue;TRANSACTIONS_RETRY_OFFSET=60;NODO_ALL_CCP_ON_TRANSFER_IBAN_ENABLED=false
AFM_CONNECTION_TIMEOUT=10000;AFM_KEY=key;AFM_READ_TIMEOUT=10000;AFM_URI=http://pagopa-gec-mock:3000/afm/node/calculator-service/v1/fees;CLOSURE_RETRY_INTERVAL=30;ECOMMERCE_PAYMENT_INSTRUMENTS_CONNECTION_TIMEOUT=10000;ECOMMERCE_PAYMENT_INSTRUMENTS_READ_TIMEOUT=10000;ECOMMERCE_PAYMENT_INSTRUMENTS_URI=http://pagopa-ecommerce-payment-methods-service:8083;ECOMMERCE_PAYMENT_METHODS_APY_KEY=payment-methods-key;ECOMMERCE_PAYMENT_METHODS_CONNECTION_TIMEOUT=600;ECOMMERCE_PAYMENT_METHODS_READ_TIMEOUT=600;ECOMMERCE_PAYMENT_METHODS_URI=http://localhost:3000;ECOMMERCE_STORAGE_TRANSIENT_CONNECTION_STRING=DefaultEndpointsProtocol=http\;AccountName=devstoreaccount1\;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==\;QueueEndpoint=http://storage:10001/devstoreaccount1;JWT_SECRET=ODMzNUZBNTZENDg3NTYyREUyNDhGNDdCRUZDNzI3NDMzMzQwNTFEREZGQ0MyQzA5Mjc1RjY2NTQ1NDk5MDMxNzU5NDc0NUVFMTdDMDhGNzk4Q0Q3RENFMEJBODE1NURDREExNEY2Mzk4QzFEMTU0NTExNjUyMEExMzMwMTdDMDk;JWT_TOKEN_VALIDITY_TIME_MILLIS=600000;LOGO_CARD_BRANDING_MAPPING={VISA:'https://dev.checkout.pagopa.it/assets/creditcard/carta_visa.png',MASTERCARD:'https://dev.checkout.pagopa.it/assets/creditcard/carta_mc.png',DINERS:'https://dev.checkout.pagopa.it/assets/creditcard/carta_diners.png',MAESTRO:'https://dev.checkout.pagopa.it/assets/creditcard/carta_maestro.png',AMEX:'https://dev.checkout.pagopa.it/assets/creditcard/carta_amex.png',UNKNOWN:'https://dev.checkout.pagopa.it/assets/creditcard/generic.png'};MONGO_HOST=pagopa-ecommerce-mongo;MONGO_PASSWORD=password;MONGO_PORT=27017;MONGO_USERNAME=admin;NODE_FOR_PSP_URI=/webservices/pof/PagamentiTelematiciPspNodoservice;NODO_CONNECTION_STRING={"idPSP":"idPsp","idChannel":"idChannel","idBrokerPSP":"12345678912","password":"password"};NODO_CONNECTION_TIMEOUT=10000;NODO_HOSTNAME=http://pagopa-node-mock:3002;NODO_PARALLEL_REQUESTS=5;NODO_READ_TIMEOUT=10000;NODO_NODEFORPSP_API_KEY=KEY;NODO_CLOSEPAYMENT_API_KEY=KEY;NODOPERPM_CONNECTION_TIMEOUT=10000;NODOPERPM_READ_TIMEOUT=10000;NODOPERPM_URI=/nodo/nodo-per-pm/v1/informazioniPagamento;NOTIFICATIONS_SERVICE_API_KEY=api-key;NOTIFICATIONS_SERVICE_CONNECTION_TIMEOUT=10000;NOTIFICATIONS_SERVICE_READ_TIMEOUT=10000;NOTIFICATIONS_SERVICE_URI=http://pagopa-ecommerce-traefik/notifications-service;PAYMENT_TOKEN_VALIDITY_TIME=120;PAYMENT_TRANSACTIONS_GATEWAY_API_KEY=key;PAYMENT_TRANSACTIONS_GATEWAY_CONNECTION_TIMEOUT=10000;PAYMENT_TRANSACTIONS_GATEWAY_READ_TIMEOUT=10000;PAYMENT_TRANSACTIONS_GATEWAY_URI=http://pagopa-ecommerce-traefik/transactions-gateway;PERSONAL_DATA_VAULT_API_BASE_PATH=http://pagopa-pdv-mock:8092;PERSONAL_DATA_VAULT_API_KEY=personal-data-vault-api-key;QueueEndpoint=http://storage:10001/devstoreaccount1;REDIS_HOST=pagopa-ecommerce-redis;REDIS_PASSWORD=redis_password;REDIS_PORT=6379;REDIS_SSL_ENABLED=false;TRANSACTION_CLOSE_PAYMENT_QUEUE_NAME=pagopa-ecommerce-transactions-close-payment-queue;TRANSACTION_CLOSE_PAYMENT_RETRY_QUEUE_NAME=pagopa-ecommerce-transactions-close-payment-retry-queue;TRANSACTION_EXPIRATION_QUEUE_NAME=pagopa-ecommerce-transactions-expiration-queue;TRANSACTION_NOTIFICATIONS_QUEUE_NAME=pagopa-ecommerce-transactions-notifications-queue;TRANSACTION_REFUND_QUEUE_NAME=pagopa-ecommerce-transactions-refund-queue;TRANSACTIONS_RETRY_OFFSET=60;NODO_ALL_CCP_ON_TRANSFER_IBAN_ENABLED=false
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ These are all environment variables needed by the application:
| NODO_READ_TIMEOUT | | Timeout for requests towards Nodo | number | |
| NODO_CONNECTION_TIMEOUT | | Timeout for establishing connections towards Nodo | number | |
| NODO_ALL_CCP_ON_TRANSFER_IBAN_ENABLED | | Flag to enable light check for allCCP. If true it checks only all transfers' iban. If false, it checks also metadata | boolean | |
| NODO_NODEFORPSP_API_KEY | | API Key for NODE FOR PSP WS | string | |
| NODO_CLOSEPAYMENT_API_KEY | | API Key for Nodo closePayment API | string | |
| ECOMMERCE_PAYMENT_METHODS_URI | | eCommerce payment methods service connection URI | string | |
| ECOMMERCE_PAYMENT_METHODS_READ_TIMEOUT | | Timeout for requests towards eCommerce payment methods service | number | |
| ECOMMERCE_PAYMENT_METHODS_CONNECTION_TIMEOUT | | Timeout for establishing connections towards eCommerce payment methods service | number | |
Expand Down
4 changes: 3 additions & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ microservice-chart:
REDIS_PORT: "6380"
REDIS_SSL_ENABLED: "true"
NODO_HOSTNAME: https://api.dev.platform.pagopa.it
NODE_FOR_PSP_URI: /nodo/node-for-psp/v1
NODE_FOR_PSP_URI: /nodo-auth/node-for-psp/v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing NODO_NODEFORPSP_API_KEY and NODO_CLOSEPAYMENT_API_KEY env secrets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

NODO_READ_TIMEOUT: "10000"
NODO_CONNECTION_TIMEOUT: "10000"
NODO_PARALLEL_REQUESTS: "5"
Expand Down Expand Up @@ -123,6 +123,8 @@ microservice-chart:
MONGO_PASSWORD: mongo-ecommerce-password
REDIS_PASSWORD: redis-ecommerce-password
NODO_CONNECTION_STRING: nodo-connection-string
NODO_CLOSEPAYMENT_API_KEY: nodo-nodeforpm-api-key
NODO_NODEFORPSP_API_KEY: nodo-nodeforpsp-api-key
NOTIFICATIONS_SERVICE_API_KEY: notifications-service-api-key
ECOMMERCE_STORAGE_TRANSIENT_CONNECTION_STRING: ecommerce-storage-transient-connection-string
PAYMENT_TRANSACTIONS_GATEWAY_API_KEY: payment-transactions-gateway-api-key
Expand Down
8 changes: 6 additions & 2 deletions helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ microservice-chart:
REDIS_PORT: "6380"
REDIS_SSL_ENABLED: "true"
NODO_HOSTNAME: https://api.platform.pagopa.it
NODE_FOR_PSP_URI: /nodo/node-for-psp/v1
NODE_FOR_PSP_URI: /nodo-auth/node-for-psp/v1
NODO_READ_TIMEOUT: "10000"
NODO_CONNECTION_TIMEOUT: "10000"
NODO_PARALLEL_REQUESTS: "5"
Expand Down Expand Up @@ -74,6 +74,8 @@ microservice-chart:
MONGO_PASSWORD: mongo-ecommerce-password
REDIS_PASSWORD: redis-ecommerce-password
NODO_CONNECTION_STRING: nodo-connection-string
NODO_CLOSEPAYMENT_API_KEY: nodo-nodeforpm-api-key
NODO_NODEFORPSP_API_KEY: nodo-nodeforpsp-api-key
PAYMENT_TRANSACTIONS_GATEWAY_API_KEY: payment-transactions-gateway-api-key
JWT_SECRET: sessions-jwt-secret
PERSONAL_DATA_VAULT_API_KEY: personal-data-vault-api-key
Expand Down Expand Up @@ -147,7 +149,7 @@ microservice-chart:
REDIS_PORT: "6380"
REDIS_SSL_ENABLED: "true"
NODO_HOSTNAME: https://api.platform.pagopa.it
NODE_FOR_PSP_URI: /nodo/node-for-psp/v1
NODE_FOR_PSP_URI: /nodo-auth/node-for-psp/v1
NODO_READ_TIMEOUT: "10000"
NODO_CONNECTION_TIMEOUT: "10000"
NODO_PARALLEL_REQUESTS: "5"
Expand Down Expand Up @@ -196,6 +198,8 @@ microservice-chart:
MONGO_PASSWORD: mongo-ecommerce-password
REDIS_PASSWORD: redis-ecommerce-password
NODO_CONNECTION_STRING: nodo-connection-string
NODO_CLOSEPAYMENT_API_KEY: nodo-nodeforpm-api-key
NODO_NODEFORPSP_API_KEY: nodo-nodeforpsp-api-key
NOTIFICATIONS_SERVICE_API_KEY: notifications-service-api-key
ECOMMERCE_STORAGE_TRANSIENT_CONNECTION_STRING: ecommerce-storage-transient-connection-string
PAYMENT_TRANSACTIONS_GATEWAY_API_KEY: payment-transactions-gateway-api-key
Expand Down
8 changes: 6 additions & 2 deletions helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ microservice-chart:
REDIS_PORT: "6380"
REDIS_SSL_ENABLED: "true"
NODO_HOSTNAME: https://api.uat.platform.pagopa.it
NODE_FOR_PSP_URI: /nodo/node-for-psp/v1
NODE_FOR_PSP_URI: /nodo-auth/node-for-psp/v1
NODO_READ_TIMEOUT: "10000"
NODO_CONNECTION_TIMEOUT: "10000"
NODO_PARALLEL_REQUESTS: "5"
Expand Down Expand Up @@ -73,6 +73,8 @@ microservice-chart:
MONGO_PASSWORD: mongo-ecommerce-password
REDIS_PASSWORD: redis-ecommerce-password
NODO_CONNECTION_STRING: nodo-connection-string
NODO_CLOSEPAYMENT_API_KEY: nodo-nodeforpm-api-key
NODO_NODEFORPSP_API_KEY: nodo-nodeforpsp-api-key
PAYMENT_TRANSACTIONS_GATEWAY_API_KEY: payment-transactions-gateway-api-key
JWT_SECRET: sessions-jwt-secret
PERSONAL_DATA_VAULT_API_KEY: personal-data-vault-api-key
Expand Down Expand Up @@ -146,7 +148,7 @@ microservice-chart:
REDIS_PORT: "6380"
REDIS_SSL_ENABLED: "true"
NODO_HOSTNAME: https://api.uat.platform.pagopa.it
NODE_FOR_PSP_URI: /nodo/node-for-psp/v1
NODE_FOR_PSP_URI: /nodo-auth/node-for-psp/v1
NODO_READ_TIMEOUT: "10000"
NODO_CONNECTION_TIMEOUT: "10000"
NODO_PARALLEL_REQUESTS: "5"
Expand Down Expand Up @@ -194,6 +196,8 @@ microservice-chart:
MONGO_PASSWORD: mongo-ecommerce-password
REDIS_PASSWORD: redis-ecommerce-password
NODO_CONNECTION_STRING: nodo-connection-string
NODO_CLOSEPAYMENT_API_KEY: nodo-nodeforpm-api-key
NODO_NODEFORPSP_API_KEY: nodo-nodeforpsp-api-key
NOTIFICATIONS_SERVICE_API_KEY: notifications-service-api-key
ECOMMERCE_STORAGE_TRANSIENT_CONNECTION_STRING: ecommerce-storage-transient-connection-string
PAYMENT_TRANSACTIONS_GATEWAY_API_KEY: payment-transactions-gateway-api-key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public class NodeForPspClient {
@Value("${nodo.nodeforpsp.uri}")
private String nodoPerPspUri;

@Value("${nodo.nodeforpsp.apikey}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe here we can refactor this class to use constructor injection? what do you think? this way we can avoid reflection to set those api key into test class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, but better to do it in a dedicated PR

private String nodoPerPspApiKey;

@Value("${nodo.closepayment.apikey}")
private String nodoClosePaymentApiKey;

public Mono<ActivatePaymentNoticeV2Response> activatePaymentNoticeV2(
JAXBElement<ActivatePaymentNoticeV2Request> request
) {
Expand All @@ -41,6 +47,7 @@ public Mono<ActivatePaymentNoticeV2Response> activatePaymentNoticeV2(
.uri(nodoPerPspUri)
.header("Content-Type", MediaType.TEXT_XML_VALUE)
.header("SOAPAction", "activatePaymentNoticeV2")
.header("ocp-apim-subscription-key", nodoPerPspApiKey)
.body(Mono.just(new SoapEnvelope("", request)), SoapEnvelope.class)
.retrieve()
.onStatus(
Expand Down Expand Up @@ -81,10 +88,11 @@ public Mono<ClosePaymentResponseDto> closePaymentV2(ClosePaymentRequestV2Dto req
);
return nodoWebClient.post()
.uri(
uriBuilder -> uriBuilder.path("/nodo/nodo-per-pm/v2/closepayment")
uriBuilder -> uriBuilder.path("/nodo-auth/nodo-per-pm/v2/closepayment")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would parameterized (maybe in another PR) this path in order to change it's value upgrading helm instead of modifying code. What do you think?

.queryParam("clientId", CLOSE_PAYMENT_CLIENT_ID).build()
)
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.header("ocp-apim-subscription-key", nodoClosePaymentApiKey)
.body(Mono.just(request), ClosePaymentRequestV2Dto.class)
.retrieve()
.onStatus(
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ nodo.connectionTimeout=${NODO_CONNECTION_TIMEOUT}
nodo.connection.string=${NODO_CONNECTION_STRING}
nodo.parallelRequests=${NODO_PARALLEL_REQUESTS}
nodo.allCCPOnTransferIbanEnabled=${NODO_ALL_CCP_ON_TRANSFER_IBAN_ENABLED}

nodo.nodeforpsp.apikey=${NODO_NODEFORPSP_API_KEY}
nodo.closepayment.apikey=${NODO_CLOSEPAYMENT_API_KEY}
paymentTransactionsGateway.uri=${PAYMENT_TRANSACTIONS_GATEWAY_URI}/
paymentTransactionsGateway.readTimeout=${PAYMENT_TRANSACTIONS_GATEWAY_READ_TIMEOUT}
paymentTransactionsGateway.connectionTimeout=${PAYMENT_TRANSACTIONS_GATEWAY_CONNECTION_TIMEOUT}
Expand Down
Loading