Skip to content

Commit b62c49c

Browse files
committed
Merge branch 'master' of https://github.com/navikt/testnorge into feature/kdi-institusjonsopphold-frontend
2 parents 725bc68 + 6d9cf21 commit b62c49c

71 files changed

Lines changed: 5416 additions & 751 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: dolly-auth-local
2+
3+
on:
4+
push:
5+
paths:
6+
- plugins/**
7+
- .nais/dolly-auth-local.yaml
8+
- .github/workflows/app.dolly-auth-lokal.yml
9+
10+
jobs:
11+
deploy:
12+
name: Deploy dolly-auth-local
13+
if: github.event.pull_request.draft == false
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
id-token: write
18+
steps:
19+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20+
- uses: nais/deploy/actions/deploy@fa754451577294aae42872a69b888b3470478ec1 # v2
21+
env:
22+
CLUSTER: dev-gcp
23+
RESOURCE: ".nais/dolly-auth-local.yml"

.github/workflows/app.team-dolly-lokal-app.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
paths:
66
- plugins/**
77
- .nais/team-dolly-lokal-app.yml
8+
- .nais/dolly-lokal-auth.yaml
89
- .github/workflows/app.team-dolly-lokal-app.yml
910

1011
jobs:

.nais/dolly-auth-local.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: "nais.io/v1alpha1"
2+
kind: "Application"
3+
metadata:
4+
name: "dolly-auth-local"
5+
namespace: "dolly"
6+
spec:
7+
image: "europe-north1-docker.pkg.dev/nais-management-233d/nais/localauth:latest"
8+
port: 8080
9+
replicas:
10+
min: 1
11+
max: 1
12+
liveness:
13+
path: "/internal/healthz"
14+
readiness:
15+
path: "/internal/healthz"
16+
resources:
17+
limits:
18+
memory: "256Mi"
19+
requests:
20+
cpu: "10m"
21+
memory: "32Mi"
22+
ingresses:
23+
- https://dolly-auth-local.intern.dev.nav.no
24+
azure:
25+
application:
26+
enabled: true
27+
allowAllUsers: true
28+
env:
29+
- name: LOCALAUTH_PUBLIC_URL
30+
value: "https://dolly-auth-local.intern.dev.nav.no"

.nais/dolly-local-auth.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: "nais.io/v1alpha1"
2+
kind: "Application"
3+
metadata:
4+
name: "dolly-local-auth"
5+
namespace: "dolly"
6+
spec:
7+
image: "europe-north1-docker.pkg.dev/nais-management-233d/nais/localauth:latest"
8+
port: 8080
9+
replicas:
10+
min: 1
11+
max: 1
12+
liveness:
13+
path: "/internal/healthz"
14+
readiness:
15+
path: "/internal/healthz"
16+
resources:
17+
limits:
18+
memory: "256Mi"
19+
requests:
20+
cpu: "10m"
21+
memory: "32Mi"
22+
ingresses:
23+
- https://dolly-local-auth.intern.dev.nav.no
24+
azure:
25+
application:
26+
enabled: true
27+
allowAllUsers: true
28+
env:
29+
- name: LOCALAUTH_PUBLIC_URL
30+
value: "https://dolly-local-auth.intern.dev.nav.no"

.nais/localauth.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: "nais.io/v1alpha1"
2+
kind: "Application"
3+
metadata:
4+
name: "localauth"
5+
namespace: "dolly"
6+
spec:
7+
image: "europe-north1-docker.pkg.dev/nais-management-233d/nais/localauth:latest"
8+
port: 8080
9+
replicas:
10+
min: 1
11+
max: 1
12+
liveness:
13+
path: "/internal/healthz"
14+
readiness:
15+
path: "/internal/healthz"
16+
resources:
17+
limits:
18+
memory: "256Mi"
19+
requests:
20+
cpu: "10m"
21+
memory: "32Mi"
22+
ingresses:
23+
- https://localauth-dolly.intern.dev.nav.no
24+
azure:
25+
application:
26+
enabled: true
27+
allowAllUsers: true
28+
env:
29+
- name: LOCALAUTH_PUBLIC_URL
30+
value: "https://localauth-dolly.intern.dev.nav.no"

apps/altinn3-tilgang-service/config.dev.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ spec:
2727
accessPolicy:
2828
inbound:
2929
rules:
30+
- application: dolly-backend
31+
- application: dolly-backend-dev
3032
- application: dolly-frontend-dev
31-
- application: testnav-dolly-proxy
32-
cluster: dev-fss
3333
- application: dolly-texas-proxy
3434
- application: team-dolly-lokal-app
3535
- application: testnav-bruker-service-dev
36+
- application: testnav-dolly-proxy
37+
cluster: dev-fss
3638
- application: testnav-oversikt-frontend
3739
- application: testnorge-profil-api-dev
3840
outbound:

apps/altinn3-tilgang-service/config.prod.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,23 @@ spec:
2727
accessPolicy:
2828
inbound:
2929
rules:
30+
- application: dolly-backend
31+
cluster: dev-gcp
32+
- application: dolly-backend-dev
33+
cluster: dev-gcp
3034
- application: dolly-frontend
3135
cluster: dev-gcp
3236
- application: dolly-idporten
3337
cluster: dev-gcp
34-
- application: team-dolly-lokal-app
38+
- application: dolly-texas-proxy
3539
cluster: dev-gcp
36-
- application: testnav-oversikt-frontend
40+
- application: team-dolly-lokal-app
3741
cluster: dev-gcp
3842
- application: testnav-altinn3-tilgang-proxy
3943
cluster: dev-gcp
4044
- application: testnav-dolly-proxy
4145
cluster: dev-fss
42-
- application: dolly-texas-proxy
46+
- application: testnav-oversikt-frontend
4347
cluster: dev-gcp
4448
outbound:
4549
external:

apps/altinn3-tilgang-service/src/main/java/no/nav/testnav/altinn3tilgangservice/Altinn3TilgangServiceApplicationStarter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ public static void main(String[] args) {
2828
new NaisPkcs8ConversionInitializer())
2929
.run(args);
3030
}
31-
}
31+
}

apps/bruker-service/src/main/java/no/nav/testnav/apps/brukerservice/controller/v2/BrukerController.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.springframework.web.bind.annotation.RequestMapping;
1919
import org.springframework.web.bind.annotation.RequestParam;
2020
import org.springframework.web.bind.annotation.RestController;
21+
import reactor.core.publisher.Flux;
2122
import reactor.core.publisher.Mono;
2223

2324
import java.util.Collections;
@@ -35,17 +36,24 @@ public class BrukerController {
3536

3637
@PostMapping
3738
public Mono<BrukerDTO> createBruker(
38-
@RequestBody BrukerDTO brukerDTO
39-
) {
39+
@RequestBody BrukerDTO brukerDTO) {
40+
4041
return validateService.validateOrganiasjonsnummerAccess(brukerDTO.organisasjonsnummer())
4142
.then(userService.create(brukerDTO))
4243
.map(User::toDTO);
4344
}
4445

46+
@GetMapping("/alle")
47+
public Flux<BrukerDTO> getAlleBrukere() {
48+
49+
return userService.getAllUsers()
50+
.map(User::toDTO);
51+
}
52+
4553
@GetMapping
4654
public Mono<List<BrukerDTO>> getBrukere(
47-
@RequestParam String organisasjonsnummer
48-
) {
55+
@RequestParam String organisasjonsnummer) {
56+
4957
return validateService.validateOrganiasjonsnummerAccess(organisasjonsnummer)
5058
.then(userService.getUserFromOrganisasjonsnummer(organisasjonsnummer))
5159
.map(User::toDTO)
@@ -55,41 +63,42 @@ public Mono<List<BrukerDTO>> getBrukere(
5563
@GetMapping("/{id}")
5664
public Mono<BrukerDTO> getBruker(
5765
@PathVariable String id,
58-
@RequestHeader(UserConstant.USER_HEADER_JWT) String jwt
59-
) {
66+
@RequestHeader(UserConstant.USER_HEADER_JWT) String jwt) {
67+
6068
return jwtService.verify(jwt, id)
6169
.then(userService.getUser(id))
6270
.map(User::toDTO);
6371
}
6472

6573
@PutMapping()
6674
public Mono<BrukerDTO> updateBruker(
67-
@RequestBody BrukerDTO bruker
68-
) {
75+
@RequestBody BrukerDTO bruker) {
76+
6977
return validateService.validateOrganiasjonsnummerAccess(bruker.organisasjonsnummer())
7078
.then(userService.updateUser(bruker))
7179
.map(User::toDTO);
7280
}
7381

7482
@GetMapping("/brukernavn/{brukernavn}")
7583
public Mono<String> getBrukernavn(
76-
@PathVariable String brukernavn
77-
) {
84+
@PathVariable String brukernavn) {
85+
7886
return userService.getUserByBrukernavn(brukernavn)
7987
.map(User::getBrukernavn);
8088
}
8189

8290
@DeleteMapping("/{id}")
8391
public Mono<Void> deleteBruker(
8492
@PathVariable String id,
85-
@RequestHeader(UserConstant.USER_HEADER_JWT) String jwt
86-
) {
93+
@RequestHeader(UserConstant.USER_HEADER_JWT) String jwt) {
94+
8795
return jwtService.verify(jwt, id)
8896
.then(userService.delete(id));
8997
}
9098

9199
@PostMapping("/{id}/token")
92100
public Mono<String> getToken(@PathVariable String id) {
101+
93102
return userService.getUser(id, true)
94103
.doOnNext(user -> validateService.validateOrganiasjonsnummerAccess(user.getOrganisasjonsnummer()))
95104
.flatMap(jwtService::getToken);

apps/bruker-service/src/main/java/no/nav/testnav/apps/brukerservice/service/v2/UserService.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@
1111
import org.springframework.http.HttpStatus;
1212
import org.springframework.stereotype.Service;
1313
import org.springframework.web.server.ResponseStatusException;
14+
import reactor.core.publisher.Flux;
1415
import reactor.core.publisher.Mono;
1516

1617
import java.time.LocalDateTime;
1718

1819
@Service("userServiceV2")
1920
@RequiredArgsConstructor
2021
public class UserService {
22+
2123
private final CryptographyService cryptographyService;
22-
private final UserRepository repository;
24+
private final UserRepository userRepository;
2325
private final GetAuthenticatedUserId getAuthenticatedUserId;
2426

2527
public Mono<User> create(BrukerDTO bruker) {
@@ -35,7 +37,7 @@ public Mono<User> create(BrukerDTO bruker) {
3537
entity.setNew(true);
3638
return entity;
3739
})
38-
.flatMap(repository::save)
40+
.flatMap(userRepository::save)
3941
.map(User::new);
4042

4143
}
@@ -47,17 +49,22 @@ public Mono<User> getUserFromOrganisasjonsnummer(String organisasjonsnummer) {
4749
.flatMap(this::getUser);
4850
}
4951

52+
public Flux<User> getAllUsers() {
53+
54+
return userRepository.findAll()
55+
.map(User::new);
56+
}
5057

5158
public Mono<User> getUser(String id) {
5259
return getUser(id, false);
5360
}
5461

5562
public Mono<User> getUser(String id, boolean loggedIn) {
56-
return repository.findById(id).flatMap(entity -> {
63+
return userRepository.findById(id).flatMap(entity -> {
5764
if (loggedIn) {
5865
entity.setNew(false);
5966
entity.setSistInnlogget(LocalDateTime.now());
60-
return repository.save(entity);
67+
return userRepository.save(entity);
6168
}
6269
return Mono.just(entity);
6370
}).map(User::new);
@@ -67,26 +74,26 @@ public Mono<User> updateUser(BrukerDTO bruker) {
6774
return getAuthenticatedUserId
6875
.call()
6976
.map(userId -> cryptographyService.createId(userId, bruker.organisasjonsnummer()))
70-
.flatMap(repository::findById)
77+
.flatMap(userRepository::findById)
7178
.switchIfEmpty(Mono.error(new ResponseStatusException(HttpStatus.NOT_FOUND, "Bruker ikke funnet.")))
7279
.flatMap(entity -> {
7380
entity.setEpost(bruker.epost());
74-
return repository.save(entity);
81+
return userRepository.save(entity);
7582
})
7683
.map(User::new);
7784
}
7885

7986
public Mono<User> getUserByBrukernavn(String username) {
80-
return repository.findByBrukernavn(username).map(User::new);
87+
return userRepository.findByBrukernavn(username).map(User::new);
8188
}
8289

8390
public Mono<Void> delete(String id) {
84-
return repository.deleteById(id);
91+
return userRepository.deleteById(id);
8592
}
8693

8794
private Mono<Void> validateCreateUser(String userId, String representing) {
8895
var id = cryptographyService.createId(userId, representing);
89-
return repository.existsById(id)
96+
return userRepository.existsById(id)
9097
.doOnNext(exists -> {
9198
if (Boolean.TRUE.equals(exists)) {
9299
throw new UserAlreadyExistsException(id);

0 commit comments

Comments
 (0)