From ae480a42b5ce168355f89046cd4ce597fb33bff6 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Mon, 9 Dec 2024 10:51:41 +0100 Subject: [PATCH] =?UTF-8?q?Endret=20oppslag=20av=20client=20ID/secret=20ti?= =?UTF-8?q?l=20=C3=A5=20hente=20verdi=20fra=20NAIS-variabler=20hvis=20satt?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/azuread/AzureNavClientCredential.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/azuread/AzureNavClientCredential.java b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/azuread/AzureNavClientCredential.java index caf3c8a43b4..ee2909d5b6a 100644 --- a/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/azuread/AzureNavClientCredential.java +++ b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/azuread/AzureNavClientCredential.java @@ -3,12 +3,20 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; +/** + * Get configuration from, in prioritized order: + *
    + *
  1. {@code AZURE_APP_CLIENT_[ID|SECRET]} (provided by NAIS when running in pod)
  2. + *
  3. {@code spring.security.oauth2.client.registration.aad.client-[id|secret]} (configured when running locally)
  4. + *
  5. {@code null} (for test purposes)
  6. + *
+ */ @Configuration public class AzureNavClientCredential extends ClientCredential { public AzureNavClientCredential( - @Value("${spring.security.oauth2.client.registration.aad.client-id:#{null}}") String clientId, - @Value("${spring.security.oauth2.client.registration.aad.client-secret:#{null}}") String clientSecret + @Value("#{systemProperties['AZURE_APP_CLIENT_ID'] ?: '${spring.security.oauth2.client.registration.aad.client-id:#{null}}'}") String clientId, + @Value("#{systemProperties['AZURE_APP_CLIENT_SECRET'] ?: '${spring.security.oauth2.client.registration.aad.client-secret:#{null}}'}") String clientSecret ) { super(clientId, clientSecret); }