Skip to content

Commit

Permalink
- Also overriding client credentials in other subclasses of ClientCre…
Browse files Browse the repository at this point in the history
…dential.
  • Loading branch information
rfc3092 committed Dec 11, 2024
1 parent 99f099d commit 7aaef7d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
@EqualsAndHashCode(callSuper = false)
@Configuration
public class AzureNavProxyClientCredential extends ClientCredential {

private final String tokenEndpoint;

public AzureNavProxyClientCredential(
@Value("${AZURE_NAV_OPENID_CONFIG_TOKEN_ENDPOINT:#{null}}") String tokenEndpoint,
@Value("${AZURE_NAV_APP_CLIENT_ID:#{null}}") String clientId,
@Value("${AZURE_NAV_APP_CLIENT_SECRET:#{null}}") String clientSecret
@Value("#{systemProperties['spring.profiles.active'] == 'test' ? 'test-client-id' : '${AZURE_APP_CLIENT_ID:#{null}}'}") String clientId,
@Value("#{systemProperties['spring.profiles.active'] == 'test' ? 'test-client-secret' : '${AZURE_APP_CLIENT_SECRET:#{null}}'}") String clientSecret
) {
super(clientId, clientSecret);
this.tokenEndpoint = tokenEndpoint;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.nav.testnav.libs.reactivesecurity.domain;

import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

Expand All @@ -8,23 +9,20 @@
import no.nav.testnav.libs.securitycore.domain.azuread.ClientCredential;

@Configuration
@Getter
public class AzureTrygdeetatenClientCredential extends ClientCredential {

private final String tokenEndpoint;

public AzureTrygdeetatenClientCredential(
@Value("${AZURE_TRYGDEETATEN_OPENID_CONFIG_TOKEN_ENDPOINT:#{null}}") String tokenEndpoint,
@Value("${AZURE_TRYGDEETATEN_APP_CLIENT_ID:#{null}}") String clientId,
@Value("${AZURE_TRYGDEETATEN_APP_CLIENT_SECRET:#{null}}") String clientSecret
@Value("#{systemProperties['spring.profiles.active'] == 'test' ? 'test-client-id' : '${AZURE_APP_CLIENT_ID:#{null}}'}") String clientId,
@Value("#{systemProperties['spring.profiles.active'] == 'test' ? 'test-client-secret' : '${AZURE_APP_CLIENT_SECRET:#{null}}'}") String clientSecret
) {
super(clientId, clientSecret);
this.tokenEndpoint = tokenEndpoint;
}

public String getTokenEndpoint() {
return tokenEndpoint;
}


@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -38,4 +36,5 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(super.hashCode(), tokenEndpoint);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class AzureNavClientCredential extends ClientCredential {
TODO: A better solution, for another day:
1. No longer import AzureNavClientCredential - generify this, or use factories. It cannot be a @Configuration for its own @Bean.
2. Create two beans, one for @Profile("test"), one on @ConditionalOnMissingBean.
3. Check if we really need subclasses for this, or if ClientCredential will suffice.
3. Check if we really need subclasses for this, or if ClientCredential will suffice. Check all other extends ClientCredential
*/
public AzureNavClientCredential(
@Value("#{systemProperties['spring.profiles.active'] == 'test' ? 'test-client-id' : '${AZURE_APP_CLIENT_ID:#{null}}'}") String clientId,
Expand Down

0 comments on commit 7aaef7d

Please sign in to comment.