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

Pc 726 vac items vindbaar maken voor beheer #996

Merged
merged 13 commits into from
Jan 14, 2025
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Change history


## vX.X.X

### New features

- Herontwerp Contactverzoek invoeren #705
- Verplaatsen van OnderwerpLinks #805
- Genereren KISS mockup content [interne data] #977
- Versienummer zichtbaar in de website #978
- Anonieme Contactverzoeken zoeken #810
- Klantcontacten bij een Zaak tonen #809
- Soorten digitaal adres aanpassen naar gebruik enums #891
- Tonen van digitale adressen aanpassen naar gebruik enums #974
- Digitale adressen opslaan conform validatieregels OK2 #939
- Partij-identificatoren aanpassen naar gebruik enums #890
- Contactverzoekformuliertjes / vragensetjes óók voor groepen #954
- Pagesize meegeven bij ophalen contactverzoeken en contactmomenten #896
- VAC items vindbaar maken voor beheer #1004

### Warnings and deployment notes
Zie installatiehandleiding voor instructies
- Nieuwe Environment Variabelen nodig: `VAC_OBJECTEN_BASE_URL`, `VAC_OBJECT_TYPE_URL` , `VAC_OBJECT_TYPE_VERSION`, `VAC_OBJECTEN_TOKEN`
- Minimale lengte van secrets is verhoogd van 16 naar 32 tekens

### Bugfixes

- Afdwingen max token lifetime van /api/contactmomentendetails #915
- Duidelijker paginering in /api/contactmomentendetails #914
- Verschillen objecttypes met community concepts wegwerken #986

### Maintenance
- Upgrade vue from 3.4.31 to 3.5.11 PR #928
- Upgrade vue from 3.5.11 to 3.5.12 PR #966
- 3 vulnerabilities in the nuget dependencies of this project PR #927
- Upgrade ckeditor5 from 42.0.0 to 42.0.2 PR #929
- Upgrade ckeditor5 from 42.0.2 to 43.1.1 PR #963
- Upgrade ckeditor5 from 43.1.1 to 43.3.0 PR #964
- Upgrade pinia from 2.1.7 to 2.2.4 PR #930
- Upgrade pinia from 2.2.4 to 2.2.5 PR #967
- Upgrade vue-router from 4.4.0 to 4.4.5 PR #931
- Upgrade dompurify from 2.5.5 to 2.5.7 PR #965
- Upgrade .Net naar v8 PR #968

77 changes: 77 additions & 0 deletions Kiss.Bff/Extern/Vacs/VacsProxyConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System.Net.Http.Headers;
using Microsoft.AspNetCore.Authorization;
using Yarp.ReverseProxy.Transforms;

namespace Kiss.Bff.Vacs
{
public static class VacsExtensions
{
public static IServiceCollection AddVacsProxy(this IServiceCollection services, string destination, string token, string objectTypeUrl, string typeVersion)
{
return services.AddSingleton<IKissProxyRoute>(s =>
{
var authorizationService = s.GetRequiredService<IAuthorizationService>();
var policyProvider = s.GetRequiredService<IAuthorizationPolicyProvider>();

return new VacsProxyConfig(destination, token, objectTypeUrl, typeVersion, authorizationService, policyProvider);
});
}
}

public class VacsProxyConfig : IKissProxyRoute
{
private readonly IAuthorizationService _authorizationService;
private readonly IAuthorizationPolicyProvider _policyProvider;
private readonly string _token;

public VacsProxyConfig(string destination, string token, string objectTypeUrl, string typeVersion,
IAuthorizationService authorizationService,
IAuthorizationPolicyProvider policyProvider)
{
Destination = destination;
ObjectTypeUrl = objectTypeUrl;
TypeVersion = typeVersion ?? "1";
_authorizationService = authorizationService;
_policyProvider = policyProvider;
_token = token;
}

public string Route => "vacs";

public string Destination { get; }
public string ObjectTypeUrl { get; }
public string TypeVersion { get; }

public async ValueTask ApplyRequestTransform(RequestTransformContext context)
{
var policy = await _policyProvider.GetPolicyAsync(Policies.RedactiePolicy);
if (policy == null)
{
context.HttpContext.Response.StatusCode = StatusCodes.Status403Forbidden;
return;
}

var authResult = await _authorizationService.AuthorizeAsync(context.HttpContext.User, null, policy);
mstokericatt marked this conversation as resolved.
Show resolved Hide resolved
if (!authResult.Succeeded)
{
context.HttpContext.Response.StatusCode = StatusCodes.Status403Forbidden;
return;
}

ApplyHeaders(context.ProxyRequest.Headers);

var request = context.HttpContext.Request;
var isObjectsEndpoint = request.Path.Value?.AsSpan().TrimEnd('/').EndsWith("objects") ?? false;
if (request.Method == HttpMethods.Get && isObjectsEndpoint)
{
context.Query.Collection["type"] = new(ObjectTypeUrl);
}
}

public void ApplyHeaders(HttpRequestHeaders headers)
{
headers.Authorization = new AuthenticationHeaderValue("Token", _token);
headers.Add("Content-Crs", "EPSG:4326");
}
}
}
2 changes: 2 additions & 0 deletions Kiss.Bff/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Microsoft.EntityFrameworkCore;
using Serilog;
using Kiss.Bff.Intern.Seed.Features;
using Kiss.Bff.Vacs;

var builder = WebApplication.CreateBuilder(args);

Expand Down Expand Up @@ -111,6 +112,7 @@
builder.Services.AddInterneTaakProxy(builder.Configuration["INTERNE_TAAK_BASE_URL"], builder.Configuration["INTERNE_TAAK_TOKEN"], builder.Configuration["INTERNE_TAAK_OBJECT_TYPE_URL"], builder.Configuration["INTERNE_TAAK_CLIENT_ID"], builder.Configuration["INTERNE_TAAK_CLIENT_SECRET"], builder.Configuration["INTERNE_TAAK_TYPE_VERSION"]);
builder.Services.AddAfdelingenProxy(builder.Configuration["AFDELINGEN_BASE_URL"], builder.Configuration["AFDELINGEN_TOKEN"], builder.Configuration["AFDELINGEN_OBJECT_TYPE_URL"], builder.Configuration["AFDELINGEN_CLIENT_ID"], builder.Configuration["AFDELINGEN_CLIENT_SECRET"]);
builder.Services.AddGroepenProxy(builder.Configuration["GROEPEN_BASE_URL"], builder.Configuration["GROEPEN_TOKEN"], builder.Configuration["GROEPEN_OBJECT_TYPE_URL"], builder.Configuration["GROEPEN_CLIENT_ID"], builder.Configuration["GROEPEN_CLIENT_SECRET"]);
builder.Services.AddVacsProxy(builder.Configuration["VAC_OBJECTEN_BASE_URL"], builder.Configuration["VAC_OBJECTEN_TOKEN"], builder.Configuration["VAC_OBJECT_TYPE_URL"], builder.Configuration["VAC_OBJECT_TYPE_VERSION"]);

builder.Services.AddKlantinteracties(builder.Configuration["KLANTINTERACTIES_BASE_URL"], builder.Configuration["KLANTINTERACTIES_TOKEN"]);

Expand Down
1 change: 1 addition & 0 deletions src/features/search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type Kennisartikel = {
};

export type Vac = {
uuid?: string;
vraag: string;
antwoord: string;
afdelingen?: VacAfdeling[];
Expand Down
15 changes: 15 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const ContactverzoekFormulierenBeheer = () =>

const KanaalBeheer = () => import("@/views/Beheer/Kanalen/KanaalBeheer.vue");
const KanalenBeheer = () => import("@/views/Beheer/Kanalen/KanalenBeheer.vue");
const VacBeheer = () => import("@/views/Beheer/vacs/VacBeheer.vue");
const VacsBeheer = () => import("@/views/Beheer/vacs/VacsBeheer.vue");

const guardContactMoment: NavigationGuard = (to, from, next) => {
const contactmoment = useContactmomentStore();
Expand Down Expand Up @@ -251,6 +253,19 @@ const router = createRouter({
props: true,
meta: {},
},
{
path: "vacs",
name: "VacsBeheer",
component: VacsBeheer,
meta: {},
},
{
path: "vac/:uuid?",
name: "VacBeheer",
component: VacBeheer,
props: true,
meta: {},
},
],
},
redirectRoute,
Expand Down
2 changes: 2 additions & 0 deletions src/views/Beheer/BeheerLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<router-link to="/Beheer/formulieren-contactverzoek-groep">
Formulieren contactverzoek groepen
</router-link>

<router-link to="/Beheer/vacs"> Vacs </router-link>
</nav>

<main>
Expand Down
20 changes: 20 additions & 0 deletions src/views/Beheer/vacs/VacBeheer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<utrecht-heading :level="1">{{ uuid }}</utrecht-heading>

<menu>
<li>
<router-link
to="/Beheer/vacs/"
class="utrecht-button utrecht-button--secondary-action"
>
Annuleren
</router-link>
</li>
</menu>
</template>

<script setup lang="ts">
import { Heading as UtrechtHeading } from "@utrecht/component-library-vue";

defineProps<{ uuid?: string }>();
</script>
57 changes: 57 additions & 0 deletions src/views/Beheer/vacs/VacsBeheer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<template>
<utrecht-heading :level="1">Vacs</utrecht-heading>

<simple-spinner v-if="loading" />

<div v-else-if="error">Er is een fout opgetreden.</div>

<ul v-else>
<li v-for="vac in vacs" :key="vac.uuid" class="listItem">
<router-link :to="'/Beheer/vac/' + vac.uuid">{{
vac.vraag || "__"
}}</router-link>
</li>
</ul>
</template>

<script setup lang="ts">
import { watch } from "vue";
import { Heading as UtrechtHeading } from "@utrecht/component-library-vue";
import SimpleSpinner from "@/components/SimpleSpinner.vue";
import { fetchLoggedIn, parseJson, parsePagination } from "@/services";
import type { Vac } from "@/features/search/types";
import { useLoader } from "@/services/use-loader";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const mapVac = (x: any): Vac => ({
uuid: x.uuid,
vraag: x.record.data.vraag,
mstokericatt marked this conversation as resolved.
Show resolved Hide resolved
antwoord: x.record.data.antwoord,
});

const fetchAllVacs = async (url: string): Promise<Vac[]> => {
const { page, next } = await fetchLoggedIn(url)
.then(parseJson)
.then((json) => parsePagination(json, mapVac));

if (next) {
const [pathname] = url.split("?");
const { searchParams } = new URL(next);

return [
...page,
...(await fetchAllVacs(`${pathname}?page=${searchParams.get("page")}`)),
];
}

return page;
};

const {
data: vacs,
loading,
error,
} = useLoader<Vac[]>(() => fetchAllVacs("/api/vacs/api/v2/objects"));

watch(vacs, (value) => value?.sort((a, b) => a.vraag.localeCompare(b.vraag)));
</script>
Loading