hmcts / sscs-case-loader

Loader service for HMCTS Cases
MIT License
4 stars 1 forks source link

Load secrets correctly for Spring Boot >2.4 #1480

Closed timja closed 1 year ago

timja commented 1 year ago

We recommended a long time ago that teams switch to spring cloud import from 2.4 onwards, see https://spring.io/blog/2020/08/14/config-file-processing-in-spring-boot-2-4.

We have not supported properties volume since 2.4, no issues are known about it but we do not maintain that custom library anymore.

When I debugged locally the property had not been replaced and I was just getting ${GAPS2_KEY_LOCATION} as the value for the private key.

I've debugged this locally by downloading the key with:

az keyvault secret download --vault-name sscs-aat --name gaps2-service-sftp-private-key -f /tmp/gaps2-service-sftp-private-key
mkdir -p /tmp/secrets/sscs
mv /tmp/gaps2-service-sftp-private-key /tmp/secrets/sscs/GAPS2_KEY_LOCATION

Then adjusted the import to /tmp instead of /mnt and commented out the Kubernetes only activation

I then ran the main class in my IntelliJ debugger, put a breakpoint on https://github.com/hmcts/sscs-case-loader/blob/18230f3eda48307e0e1ef5b3381157f436edd21b/src/main/java/uk/gov/hmcts/reform/sscs/services/sftp/SftpChannelAdapter.java#L48

and evaluated expression to see what the values was. I wasted some time because intellij was just showing null if I looked at the variables in the debugger, but I noticed it was a proxy class, so I evaluated the code and I could see the correct value there