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

cleanup/azure_aad_issuer_uri #3709

Draft
wants to merge 31 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4665911
Remove explicit reference to AAD_ISSUER_URI - already in received Azu…
rfc3092 Dec 19, 2024
0b75b21
Removed usage of AAD_ISSUER_URI for pdl-proxy, for initial sanity check.
rfc3092 Dec 19, 2024
8cb87b9
- Setting issuer-uri from AZURE_OPENID_CONFIG_ISSUER.
rfc3092 Dec 20, 2024
349c293
Used AAD_ISSUER_URI directly to resolve token endpoint. Now using tok…
rfc3092 Dec 20, 2024
1128e92
Test cleanup.
rfc3092 Dec 20, 2024
afac231
Testing use of issuer-uri instead of authorization-uri.
rfc3092 Dec 20, 2024
a10f9f0
Fixed test by mocking ReactiveClientRegistrationRepository.
rfc3092 Dec 20, 2024
7dfe000
Testing with only issuer-uri (relying on well-known).
rfc3092 Dec 20, 2024
ad21b6c
Revert "Testing with only issuer-uri (relying on well-known)."
rfc3092 Dec 20, 2024
bf6f263
Removes SpEL magic with hardcoding (for now).
rfc3092 Dec 20, 2024
e4c30b1
Testing with only issuer-uri (relying on well-known).
rfc3092 Dec 20, 2024
4210958
- Added Spring Security debug logging.
rfc3092 Dec 20, 2024
67b0185
Changes reply URLs.
rfc3092 Dec 20, 2024
8362c37
Test using AZURE_APP_TENANT_ID.
rfc3092 Dec 20, 2024
da5e8d5
Back to issuer-uri, but now with a CustomOidcUserService that dont' l…
rfc3092 Dec 21, 2024
3b1c2d2
- Added a CustomOidcReactiveOAuth2UserService bean.
rfc3092 Dec 24, 2024
f57bcb7
Moved custom user info classes into security-core lib and created aut…
rfc3092 Dec 30, 2024
4887073
Merge branch 'master' into cleanup/azure_aad_issuer_uri
rfc3092 Dec 30, 2024
1ffc37f
Added placeholder AZURE_OPENID_CONFIG_ISSUER value in test configs.
rfc3092 Jan 9, 2025
918fb0d
Reverted reply URL patterns from /azure to /aad.
rfc3092 Jan 9, 2025
2bc29f9
Merge branch 'master' into cleanup/azure_aad_issuer_uri
rfc3092 Jan 9, 2025
c6f3868
Clarified TODO.
rfc3092 Jan 9, 2025
8105104
Added a TODO.
rfc3092 Jan 9, 2025
439b712
- Changed usage from old AAD_ISSUER_URI to NAIS provided AZURE_OPENID…
rfc3092 Jan 9, 2025
cc0189d
Added JwtDecoder beans for test profile, to avoid boilerplate mocks i…
rfc3092 Jan 9, 2025
69def70
- Removed boilerplate JwtDecoder mocks.
rfc3092 Jan 9, 2025
73ebba6
Removed a warning.
rfc3092 Jan 9, 2025
929f910
- Added missing AZURE_OPENID_CONFIG_TOKEN_ENDPOINT test profile config.
rfc3092 Jan 9, 2025
d59ed22
Merge branch 'master' into cleanup/azure_aad_issuer_uri
rfc3092 Jan 9, 2025
2a285a9
- Fixed incorrect context path for testnav-altinn3-tilgang-service.
rfc3092 Jan 9, 2025
ce5b7d7
Removed mocks of JwtDecoder.
rfc3092 Jan 9, 2025
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
1 change: 1 addition & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Integration Tests
on:
push:
paths:
- 'docker-compose.yml'
- 'apps/bruker-service/**'
workflow_dispatch:

Expand Down
6 changes: 2 additions & 4 deletions apps/adresse-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b

spring:
application:
name: adresse-service
Expand All @@ -9,8 +7,8 @@ spring:
oauth2:
resourceserver:
aad:
issuer-uri: ${AAD_ISSUER_URI}/v2.0
jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys
issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER}
jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI}
accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID}
tokenx:
issuer-uri: ${TOKEN_X_ISSUER}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@SpringBootTest
@ActiveProfiles("test")
class ApplicationContextTest {

@MockBean
public JwtDecoder jwtDecoder;

@Test
@SuppressWarnings("java:S2699")
void load_app_context() {
assertThat(true).isTrue();
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder
TOKEN_X_ISSUER: dummy

spring:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b

spring:
application:
version: application.version.todo
Expand All @@ -9,8 +7,8 @@ spring:
oauth2:
resourceserver:
aad:
issuer-uri: ${AAD_ISSUER_URI}/v2.0
jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys
issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER}
jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI}
accepted-audience: ${AZURE_APP_CLIENT_ID}, api://${AZURE_APP_CLIENT_ID}
tokenx:
issuer-uri: ${TOKEN_X_ISSUER}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.ReactiveJwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@SpringBootTest
@ActiveProfiles("test")
class ApplicationContextTest {

@MockBean
public ReactiveJwtDecoder jwtDecoder;

@MockBean
@SuppressWarnings("unused")
public SecretManagerServiceClient secretManagerClient;

@Test
@SuppressWarnings("java:S2699")
void load_app_context() {
assertThat(true).isTrue();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ALTINN_URL: http://localhost:8080
ALTINN_API_KEY: dummy
ALTINN_URL: http://localhost:8080
AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder
MASKINPORTEN_CLIENT_ID: dummy
MASKINPORTEN_CLIENT_JWK: dummy
MASKINPORTEN_SCOPES: dummy
Expand Down
6 changes: 2 additions & 4 deletions apps/amelding-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b

spring:
application:
name: testnav-amelding-service
Expand All @@ -9,8 +7,8 @@ spring:
oauth2:
resourceserver:
aad:
issuer-uri: ${AAD_ISSUER_URI}/v2.0
jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys
issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER}
jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI}
accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID}

springdoc:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder
TOKEN_X_ISSUER: dummy

spring:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b

spring:
application:
version: application.version.todo #TODO Finn ut hvordan denne kan settes fra gradle
Expand All @@ -9,8 +7,8 @@ spring:
oauth2:
resourceserver:
aad:
issuer-uri: ${AAD_ISSUER_URI}/v2.0
jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys
issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER}
jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI}
accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID}
tokenx:
issuer-uri: ${TOKEN_X_ISSUER}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@SpringBootTest
@ActiveProfiles("test")
class ApplicationContextTest {

@MockBean
public JwtDecoder jwtDecoder;

@Test
@SuppressWarnings("java:S2699")
void load_app_context() {
assertThat(true).isTrue();
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder
DOLLY_READER_TOKEN: test
TOKEN_X_ISSUER: dummy

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b

spring:
application:
name: testnav-arbeidsforhold-service
Expand All @@ -8,8 +6,8 @@ spring:
oauth2:
resourceserver:
aad:
issuer-uri: ${AAD_ISSUER_URI}/v2.0
jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys
issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER}
jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI}
accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID}
tokenx:
issuer-uri: ${TOKEN_X_ISSUER}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package no.nav.registre.testnorge.arbeidsforholdservice;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
Expand All @@ -13,12 +10,7 @@
@ActiveProfiles("test")
class ApplicationContextTest {

@MockBean
@SuppressWarnings("unused")
private JwtDecoder jwtDecoder;

@Test
@DisplayName("Application context should load")
void load_app_context() {
assertThat(true).isTrue();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder
TOKEN_X_ISSUER: dummy

spring:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b

spring:
main:
banner-mode: off
Expand All @@ -10,8 +8,8 @@ spring:
oauth2:
resourceserver:
aad:
issuer-uri: ${AAD_ISSUER_URI}/v2.0
jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys
issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER}
jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI}
accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID}
tokenx:
issuer-uri: ${TOKEN_X_ISSUER}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@ActiveProfiles("test")
@SpringBootTest
public class ApplicationContextTest {

@MockBean
public JwtDecoder jwtDecoder;
class ApplicationContextTest {

@Test
@SuppressWarnings("java:S2699")
void load_app_context() {
assertThat(true).isTrue();
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder
AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder
TOKEN_X_ISSUER: dummy

spring:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,22 @@
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.junit.jupiter.api.*;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.client.WebClient;

import java.io.IOException;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@Tag("integration")
class BrukerServiceIntegrationTest {

private static final String PID = "01810048413";
private static final String ORGNUMMER = "811306312";
public static MockWebServer mockBackEnd;
@MockBean
JwtDecoder jwtDecoder;

private ObjectMapper objectMapper;
private WebClient webClient;
Expand Down Expand Up @@ -65,7 +58,7 @@ void should_create_new_user_login_change_username_and_then_delete_user() throws
.setBody(objectMapper.writeValueAsString(new AccessToken("test"))));

var token = tokendingsClient.generateToken("dev-gcp:dolly:testnav-bruker-service", PID).block();

assertThat(token).isNotNull();

// Create user
var expected = new BrukerDTO(null, "username", ORGNUMMER, null, null);
Expand All @@ -83,7 +76,8 @@ void should_create_new_user_login_change_username_and_then_delete_user() throws
.bodyToMono(BrukerDTO.class)
.block();

Assertions.assertThat(bruker)
assertThat(bruker)
.isNotNull()
.usingRecursiveComparison()
.comparingOnlyFields("brukernavn", "organisasjonsnummer")
.isEqualTo(expected);
Expand Down Expand Up @@ -132,7 +126,8 @@ void should_create_new_user_login_change_username_and_then_delete_user() throws
.bodyToMono(BrukerDTO.class)
.block();

Assertions.assertThat(updatedUser.brukernavn()).isEqualTo("new-username");
assertThat(updatedUser).isNotNull();
assertThat(updatedUser.brukernavn()).isEqualTo("new-username");

mockBackEnd.enqueue(
new MockResponse().setResponseCode(200)
Expand Down
6 changes: 2 additions & 4 deletions apps/budpro-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b

spring:
security:
oauth2:
resourceserver:
aad:
issuer-uri: ${AAD_ISSUER_URI}/v2.0
jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys
issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER}
jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI}
accepted-audience: ${AZURE_APP_CLIENT_ID}, api://${AZURE_APP_CLIENT_ID}

management:
Expand Down
6 changes: 2 additions & 4 deletions apps/dolly-backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b

dolly:
api:
v1:
Expand Down Expand Up @@ -45,8 +43,8 @@ spring:
oauth2:
resourceserver:
aad:
issuer-uri: ${AAD_ISSUER_URI}/v2.0
jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys
issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER}
jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI}
accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID}
jackson:
parser:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
APP_NAME: dolly
APP_VERSION: ${application.version}
environment: localhost
AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder
AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: placeholder
TOKEN_X_ISSUER: dummy
environment: localhost

jira:
host: http://localhost:${wiremock.server.port:0}/jira
Expand Down
Loading
Loading