-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Altinn access integration and update service dependencies
Replaces PersonOrganisasjonTilgang functionality with Altinn3Tilgang integration, including adjustments to DTOs, commands, service logic, and configuration. Renamed classes and endpoints to reflect the updated functionality. Added dependency on shared data-transfer-objects library for streamlined DTO management.
- Loading branch information
Showing
16 changed files
with
100 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
...uker-service/src/main/java/no/nav/testnav/apps/brukerservice/service/ValidateService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...main/java/no/nav/testnav/apps/oversiktfrontend/consumer/AltinnTilgangServiceConsumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package no.nav.testnav.apps.oversiktfrontend.consumer; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import no.nav.testnav.apps.oversiktfrontend.config.Consumers; | ||
import no.nav.testnav.apps.oversiktfrontend.consumer.command.GetAltinnBrukertilgangTilgangCommand; | ||
import no.nav.testnav.libs.dto.altinn3.v1.OrganisasjonDTO; | ||
import no.nav.testnav.libs.reactivesecurity.action.GetAuthenticatedUserId; | ||
import no.nav.testnav.libs.reactivesecurity.exchange.TokenExchange; | ||
import no.nav.testnav.libs.securitycore.domain.ServerProperties; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import org.springframework.web.reactive.function.client.WebClientResponseException; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
|
||
@Slf4j | ||
@Component | ||
public class AltinnTilgangServiceConsumer { | ||
private final WebClient webClient; | ||
private final ServerProperties serverProperties; | ||
private final TokenExchange tokenExchange; | ||
private final GetAuthenticatedUserId getAuthenticatedUserId; | ||
|
||
public AltinnTilgangServiceConsumer( | ||
Consumers consumers, | ||
TokenExchange tokenExchange, | ||
WebClient.Builder webClientBuilder, | ||
GetAuthenticatedUserId getAuthenticatedUserId) { | ||
|
||
serverProperties = consumers.getTestnavAltinn3TilgangService(); | ||
this.tokenExchange = tokenExchange; | ||
this.webClient = webClientBuilder | ||
.baseUrl(serverProperties.getUrl()) | ||
.build(); | ||
this.getAuthenticatedUserId = getAuthenticatedUserId; | ||
} | ||
|
||
public Flux<OrganisasjonDTO> getOrganisasjoner() { | ||
|
||
return getAuthenticatedUserId.call() | ||
.flatMapMany(userId -> tokenExchange.exchange(serverProperties) | ||
.flatMapMany(accessToken -> | ||
new GetAltinnBrukertilgangTilgangCommand(webClient, userId, accessToken.getTokenValue()).call())); | ||
} | ||
|
||
public Mono<Boolean> hasAccess(String organisasjonsnummer) { | ||
|
||
return Mono.from(getOrganisasjoner() | ||
.filter(org -> org.getOrganisasjonsnummer().equals(organisasjonsnummer)) | ||
.onErrorResume( | ||
WebClientResponseException.class::isInstance, | ||
throwable -> { | ||
log.warn("Person har ikke tilgang til organisasjon {}.", organisasjonsnummer); | ||
return Mono.empty(); | ||
}) | ||
.flatMap(value -> Mono.just(true)) | ||
.switchIfEmpty(Mono.just(false))); | ||
} | ||
} |
71 changes: 0 additions & 71 deletions
71
...java/no/nav/testnav/apps/oversiktfrontend/consumer/PersonOrganisasjonTilgangConsumer.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
...v/testnav/apps/oversiktfrontend/consumer/command/GetPersonOrganisasjonTilgangCommand.java
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
.../src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/dto/AltinnBrukerRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package no.nav.testnav.apps.oversiktfrontend.consumer.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class AltinnBrukerRequest { | ||
|
||
private String ident; | ||
} |
11 changes: 0 additions & 11 deletions
11
...tend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/dto/OrganisasjonDTO.java
This file was deleted.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
...kt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/service/AccessService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
package no.nav.testnav.apps.oversiktfrontend.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import no.nav.testnav.apps.oversiktfrontend.consumer.PersonOrganisasjonTilgangConsumer; | ||
import no.nav.testnav.apps.oversiktfrontend.consumer.AltinnTilgangServiceConsumer; | ||
import org.springframework.stereotype.Service; | ||
import reactor.core.publisher.Mono; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class AccessService { | ||
private final PersonOrganisasjonTilgangConsumer personOrganisasjonTilgangConsumer; | ||
private final AltinnTilgangServiceConsumer altinnTilgangServiceConsumer; | ||
|
||
public Mono<Boolean> hasAccess(String organisasjonsnummer) { | ||
return personOrganisasjonTilgangConsumer.hasAccess(organisasjonsnummer); | ||
return altinnTilgangServiceConsumer.hasAccess(organisasjonsnummer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.