Skip to content

Commit

Permalink
Renames TokenServices to match ClientCredentials (and property) namin…
Browse files Browse the repository at this point in the history
…g pattern.
  • Loading branch information
rfc3092 committed Dec 18, 2024
1 parent 0f72771 commit d4ec146
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import no.nav.testnav.libs.reactivesecurity.action.GetAuthenticatedToken;
import no.nav.testnav.libs.reactivesecurity.action.GetAuthenticatedUserId;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureAdTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.NavAzureAdTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.TrygdeetatenAzureAdTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureNavTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTrygdeetatenTokenService;
import no.nav.testnav.libs.securitycore.domain.azuread.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfiguration;
Expand All @@ -24,63 +24,63 @@ public class TokenServiceAutoConfiguration {
@Primary
@Bean
@Profile("test")
AzureAdTokenService azureAdTokenServiceTest(
AzureTokenService azureAdTokenServiceTest(
AzureClientCredential clientCredential,
GetAuthenticatedToken getAuthenticatedToken
) {
return new AzureAdTokenService(null, null, clientCredential, getAuthenticatedToken);
return new AzureTokenService(null, null, clientCredential, getAuthenticatedToken);
}

@Bean
@ConditionalOnDollyApplicationConfiguredForAzure
@ConditionalOnMissingBean(AzureAdTokenService.class)
AzureAdTokenService azureAdTokenService(
@ConditionalOnMissingBean(AzureTokenService.class)
AzureTokenService azureAdTokenService(
@Value("${AAD_ISSUER_URI:#{null}}") String issuerUrl,
AzureClientCredential clientCredential,
GetAuthenticatedToken getAuthenticatedToken
) {
Assert.notNull(issuerUrl, "AAD_ISSUER_URI must be set");
return new AzureAdTokenService(proxyHost, issuerUrl, clientCredential, getAuthenticatedToken);
return new AzureTokenService(proxyHost, issuerUrl, clientCredential, getAuthenticatedToken);
}

@Primary
@Bean
@Profile("test")
NavAzureAdTokenService azureNavTokenServiceTest(
AzureNavTokenService azureNavTokenServiceTest(
AzureNavClientCredential azureNavClientCredential
) {
return new NavAzureAdTokenService(null, azureNavClientCredential);
return new AzureNavTokenService(null, azureNavClientCredential);
}

@Bean
@ConditionalOnDollyApplicationConfiguredForNav
@ConditionalOnMissingBean(NavAzureAdTokenService.class)
NavAzureAdTokenService azureNavTokenService(
@ConditionalOnMissingBean(AzureNavTokenService.class)
AzureNavTokenService azureNavTokenService(
AzureNavClientCredential azureNavClientCredential
) {
return new NavAzureAdTokenService(proxyHost, azureNavClientCredential);
return new AzureNavTokenService(proxyHost, azureNavClientCredential);
}

@Primary
@Bean
@Profile("test")
TrygdeetatenAzureAdTokenService trygdeetatenAzureAdTokenServiceTest(
AzureTrygdeetatenTokenService trygdeetatenAzureAdTokenServiceTest(
AzureTrygdeetatenClientCredential clientCredential,
GetAuthenticatedUserId getAuthenticatedUserId,
ObjectMapper objectMapper
) {
return new TrygdeetatenAzureAdTokenService(null, clientCredential, getAuthenticatedUserId, objectMapper);
return new AzureTrygdeetatenTokenService(null, clientCredential, getAuthenticatedUserId, objectMapper);
}

@Bean
@ConditionalOnDollyApplicationConfiguredForTrygdeetaten
@ConditionalOnMissingBean(TrygdeetatenAzureAdTokenService.class)
TrygdeetatenAzureAdTokenService trygdeetatenAzureAdTokenService(
@ConditionalOnMissingBean(AzureTrygdeetatenTokenService.class)
AzureTrygdeetatenTokenService trygdeetatenAzureAdTokenService(
AzureTrygdeetatenClientCredential clientCredential,
GetAuthenticatedUserId getAuthenticatedUserId,
ObjectMapper objectMapper
) {
return new TrygdeetatenAzureAdTokenService(proxyHost, clientCredential, getAuthenticatedUserId, objectMapper);
return new AzureTrygdeetatenTokenService(proxyHost, clientCredential, getAuthenticatedUserId, objectMapper);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import java.net.URI;

@Slf4j
public class NavAzureAdTokenService implements TokenService {
public class AzureNavTokenService implements TokenService {

private final WebClient webClient;
private final ClientCredential clientCredential;

public NavAzureAdTokenService(
public AzureNavTokenService(
String proxyHost,
AzureNavClientCredential azureNavClientCredential
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
import static java.util.Objects.isNull;

@Slf4j
public class AzureAdTokenService implements TokenService {
public class AzureTokenService implements TokenService {
private final WebClient webClient;
private final ClientCredential clientCredential;
private final GetAuthenticatedToken getAuthenticatedToken;

public AzureAdTokenService(
public AzureTokenService(
String proxyHost,
String issuerUrl,
AzureClientCredential azureClientCredential,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
import static java.util.Objects.nonNull;

@Slf4j
public class TrygdeetatenAzureAdTokenService implements TokenService {
public class AzureTrygdeetatenTokenService implements TokenService {

private final WebClient webClient;
private final ClientCredential clientCredential;
private final ObjectMapper objectMapper;
private final Map<String, AccessToken> tokenCache;
private final GetAuthenticatedUserId getAuthenticatedUserId;

public TrygdeetatenAzureAdTokenService(
public AzureTrygdeetatenTokenService(
String proxyHost,
AzureTrygdeetatenClientCredential azureTrygdeetatenClientCredential,
GetAuthenticatedUserId getAuthenticatedUserId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import no.nav.testnav.libs.reactiveproxy.config.SecurityConfig;
import no.nav.testnav.libs.reactiveproxy.filter.AddAuthenticationRequestGatewayFilterFactory;
import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.TrygdeetatenAzureAdTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTrygdeetatenTokenService;
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
import org.springframework.cloud.gateway.filter.GatewayFilter;
Expand Down Expand Up @@ -32,7 +32,7 @@ public class RouteLocatorConfig {
@Bean
public RouteLocator customRouteLocator(
RouteLocatorBuilder builder,
TrygdeetatenAzureAdTokenService tokenService,
AzureTrygdeetatenTokenService tokenService,
Consumers consumers) {

var routes = builder.routes();
Expand All @@ -50,7 +50,7 @@ public RouteLocator customRouteLocator(
return routes.build();
}

private GatewayFilter getAuthenticationFilter(TrygdeetatenAzureAdTokenService tokenService, ServerProperties serverProperties) {
private GatewayFilter getAuthenticationFilter(AzureTrygdeetatenTokenService tokenService, ServerProperties serverProperties) {
return AddAuthenticationRequestGatewayFilterFactory
.bearerAuthenticationHeaderFilter(() -> tokenService
.exchange(serverProperties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import no.nav.testnav.libs.reactiveproxy.config.SecurityConfig;
import no.nav.testnav.libs.reactiveproxy.filter.AddAuthenticationRequestGatewayFilterFactory;
import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.TrygdeetatenAzureAdTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTrygdeetatenTokenService;
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
import no.nav.testnav.proxies.dokarkivproxy.config.Consumers;
Expand Down Expand Up @@ -35,7 +35,7 @@ public class DokarkivProxyApplicationStarter {
@Bean
public RouteLocator customRouteLocator(
RouteLocatorBuilder builder,
TrygdeetatenAzureAdTokenService tokenService,
AzureTrygdeetatenTokenService tokenService,
Consumers consumers) {
var routes = builder.routes();
Arrays
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import no.nav.testnav.libs.reactiveproxy.config.SecurityConfig;
import no.nav.testnav.libs.reactiveproxy.filter.AddAuthenticationRequestGatewayFilterFactory;
import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.TrygdeetatenAzureAdTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTrygdeetatenTokenService;
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand All @@ -28,7 +28,7 @@ public static void main(String[] args) {
@Bean
public RouteLocator customRouteLocator(
RouteLocatorBuilder builder,
TrygdeetatenAzureAdTokenService tokenService,
AzureTrygdeetatenTokenService tokenService,
Consumers consumers
) {
var addAuthenticationHeaderDevFilter = AddAuthenticationRequestGatewayFilterFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import no.nav.testnav.libs.reactiveproxy.config.SecurityConfig;
import no.nav.testnav.libs.reactiveproxy.filter.AddAuthenticationRequestGatewayFilterFactory;
import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.TrygdeetatenAzureAdTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTrygdeetatenTokenService;
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import no.nav.testnav.proxies.kontoregisterperson.config.Consumers;
import org.springframework.boot.SpringApplication;
Expand All @@ -29,7 +29,7 @@ public static void main(String[] args) {
@Bean
public RouteLocator customRouteLocator(
RouteLocatorBuilder builder,
TrygdeetatenAzureAdTokenService tokenService,
AzureTrygdeetatenTokenService tokenService,
Consumers consumers
) {
var addAuthenticationHeaderDevFilter = AddAuthenticationRequestGatewayFilterFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import no.nav.testnav.libs.reactiveproxy.config.SecurityConfig;
import no.nav.testnav.libs.reactiveproxy.filter.AddAuthenticationRequestGatewayFilterFactory;
import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.TrygdeetatenAzureAdTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTrygdeetatenTokenService;
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import no.nav.testnav.proxies.krrstubproxy.config.Consumers;
import org.springframework.boot.SpringApplication;
Expand All @@ -29,7 +29,7 @@ public static void main(String[] args) {
@Bean
public RouteLocator customRouteLocator(
RouteLocatorBuilder builder,
TrygdeetatenAzureAdTokenService tokenService,
AzureTrygdeetatenTokenService tokenService,
Consumers consumers
) {
var addAuthenticationHeaderDevFilter = AddAuthenticationRequestGatewayFilterFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import no.nav.testnav.libs.reactiveproxy.config.SecurityConfig;
import no.nav.testnav.libs.reactiveproxy.filter.AddAuthenticationRequestGatewayFilterFactory;
import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.TrygdeetatenAzureAdTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTrygdeetatenTokenService;
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import no.nav.testnav.proxies.medlproxy.config.Consumers;
import org.springframework.boot.SpringApplication;
Expand All @@ -29,7 +29,7 @@ public static void main(String[] args) {
@Bean
public RouteLocator customRouteLocator(
RouteLocatorBuilder builder,
TrygdeetatenAzureAdTokenService tokenService,
AzureTrygdeetatenTokenService tokenService,
Consumers consumers
) {
var addAuthenticationHeaderDevFilter = AddAuthenticationRequestGatewayFilterFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import no.nav.testnav.libs.reactiveproxy.config.SecurityConfig;
import no.nav.testnav.libs.reactiveproxy.filter.AddAuthenticationRequestGatewayFilterFactory;
import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.TrygdeetatenAzureAdTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTrygdeetatenTokenService;
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
import no.nav.testnav.proxies.pdlproxy.config.Consumers;
Expand Down Expand Up @@ -36,7 +36,7 @@ public static void main(String[] args) {
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder,
CredentialsHolder credentialsHolder,
TrygdeetatenAzureAdTokenService tokenService,
AzureTrygdeetatenTokenService tokenService,
Consumers consumers) {
var addHendelselagerApiKeyAuthenticationHeader = AddAuthenticationRequestGatewayFilterFactory
.apiKeyAuthenticationHeaderFilter(credentialsHolder.hendelselagerApiKey());
Expand All @@ -62,7 +62,7 @@ private Function<PredicateSpec, Buildable<Route>> createRoute(String segment, St
).uri(host);
}

private Function<PredicateSpec, Buildable<Route>> createRoute(ServerProperties serverProperties, TrygdeetatenAzureAdTokenService tokenService) {
private Function<PredicateSpec, Buildable<Route>> createRoute(ServerProperties serverProperties, AzureTrygdeetatenTokenService tokenService) {
var segment = serverProperties.getName();
var host = serverProperties.getUrl();
var filter = AddAuthenticationRequestGatewayFilterFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import no.nav.testnav.libs.reactiveproxy.config.SecurityConfig;
import no.nav.testnav.libs.reactiveproxy.filter.AddAuthenticationRequestGatewayFilterFactory;
import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.TrygdeetatenAzureAdTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTrygdeetatenTokenService;
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
import no.nav.testnav.proxies.pensjontestdatafacadeproxy.config.Consumers;
Expand All @@ -31,7 +31,7 @@ public class PensjonTestdataFacadeProxyApplicationStarter {

@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder,
TrygdeetatenAzureAdTokenService tokenService,
AzureTrygdeetatenTokenService tokenService,
Consumers consumers) {
var routes = builder.routes();
Arrays
Expand Down Expand Up @@ -67,7 +67,7 @@ public RouteLocator customRouteLocator(RouteLocatorBuilder builder,
return routes.build();
}

private GatewayFilter getAuthenticationFilter(TrygdeetatenAzureAdTokenService tokenService,
private GatewayFilter getAuthenticationFilter(AzureTrygdeetatenTokenService tokenService,
ServerProperties serverProperties) {
return AddAuthenticationRequestGatewayFilterFactory
.bearerAuthenticationHeaderFilter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import no.nav.testnav.libs.reactivecore.config.CoreConfig;
import no.nav.testnav.libs.reactiveproxy.config.SecurityConfig;
import no.nav.testnav.libs.reactiveproxy.filter.AddAuthenticationRequestGatewayFilterFactory;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.TrygdeetatenAzureAdTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTrygdeetatenTokenService;
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
import org.springframework.boot.SpringApplication;
Expand Down Expand Up @@ -32,7 +32,7 @@ public class SafProxyApplicationStarter {
@Bean
public RouteLocator customRouteLocator(
RouteLocatorBuilder builder,
TrygdeetatenAzureAdTokenService tokenService,
AzureTrygdeetatenTokenService tokenService,
Consumers consumers
) {
var routes = builder.routes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import no.nav.testnav.libs.reactiveproxy.config.SecurityConfig;
import no.nav.testnav.libs.reactiveproxy.filter.AddAuthenticationRequestGatewayFilterFactory;
import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.TrygdeetatenAzureAdTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTrygdeetatenTokenService;
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.route.RouteLocator;
Expand Down Expand Up @@ -36,7 +36,7 @@ public RouteLocator customRouteLocator(

@Bean
GatewayFilter getAuthenticationFilter(
TrygdeetatenAzureAdTokenService tokenService,
AzureTrygdeetatenTokenService tokenService,
Consumers consumers
) {
return AddAuthenticationRequestGatewayFilterFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import no.nav.testnav.libs.reactiveproxy.config.SecurityConfig;
import no.nav.testnav.libs.reactiveproxy.filter.AddAuthenticationRequestGatewayFilterFactory;
import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.TrygdeetatenAzureAdTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTrygdeetatenTokenService;
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.route.RouteLocator;
Expand Down Expand Up @@ -36,7 +36,7 @@ public RouteLocator customRouteLocator(

@Bean
GatewayFilter getAuthenticationFilter(
TrygdeetatenAzureAdTokenService tokenService,
AzureTrygdeetatenTokenService tokenService,
Consumers consumers
) {
return AddAuthenticationRequestGatewayFilterFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import no.nav.testnav.libs.reactiveproxy.config.SecurityConfig;
import no.nav.testnav.libs.reactiveproxy.filter.AddAuthenticationRequestGatewayFilterFactory;
import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.NavAzureAdTokenService;
import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureNavTokenService;
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import no.nav.testnav.proxies.synthdatameldekortproxy.config.Consumers;
import org.springframework.boot.SpringApplication;
Expand All @@ -29,7 +29,7 @@ public static void main(String[] args) {
@Bean
public RouteLocator customRouteLocator(
RouteLocatorBuilder builder,
NavAzureAdTokenService tokenService,
AzureNavTokenService tokenService,
Consumers consumers
) {
var addAuthenticationHeaderFilter = AddAuthenticationRequestGatewayFilterFactory
Expand Down

0 comments on commit d4ec146

Please sign in to comment.