diff --git a/frontend/.gitignore b/frontend/.gitignore index 11f5d71..b5bcb0c 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -20,3 +20,6 @@ pnpm-debug.log* *.njsproj *.sln *.sw? + +# Generated source files +src/generated/ \ No newline at end of file diff --git a/frontend/src/components/Home.vue b/frontend/src/components/Home.vue index 64c98ce..4906cef 100644 --- a/frontend/src/components/Home.vue +++ b/frontend/src/components/Home.vue @@ -39,7 +39,7 @@ rounded="lg" title="Manage your certificates" variant="text" - to="/cert-request" + to="/certificates" /> diff --git a/frontend/src/pages/certificates/[fingerprint].vue b/frontend/src/pages/certificates/[fingerprint].vue new file mode 100644 index 0000000..17c9dd8 --- /dev/null +++ b/frontend/src/pages/certificates/[fingerprint].vue @@ -0,0 +1,34 @@ + + + diff --git a/frontend/src/pages/certificates/index.vue b/frontend/src/pages/certificates/index.vue new file mode 100644 index 0000000..924b91b --- /dev/null +++ b/frontend/src/pages/certificates/index.vue @@ -0,0 +1,49 @@ + + + + + diff --git a/frontend/src/pages/certificates/new.vue b/frontend/src/pages/certificates/new.vue new file mode 100644 index 0000000..1837583 --- /dev/null +++ b/frontend/src/pages/certificates/new.vue @@ -0,0 +1,11 @@ + + + + + diff --git a/frontend/src/plugins/client.ts b/frontend/src/plugins/client.ts new file mode 100644 index 0000000..90105c8 --- /dev/null +++ b/frontend/src/plugins/client.ts @@ -0,0 +1,18 @@ +import createFetchClient from "openapi-fetch"; +import type { components, paths } from "@/generated/api-spec.ts"; +import type { App } from "vue"; + +export const fetchClient = createFetchClient({ + baseUrl: "http://localhost:8080" +}); + +export type Schemas = components["schemas"]; + +// noinspection JSUnusedGlobalSymbols +const $api = { + install: (app: App) => { + app.config.globalProperties.$api = fetchClient; + } +} + +export default $api; diff --git a/frontend/src/plugins/index.ts b/frontend/src/plugins/index.ts index cd3a681..17430da 100644 --- a/frontend/src/plugins/index.ts +++ b/frontend/src/plugins/index.ts @@ -1,10 +1,12 @@ -import vuetify from './vuetify' -import router from '../router' +import vuetify from "./vuetify"; +import router from "../router"; +import client from "./client"; -import type { App } from 'vue' +import type { App } from "vue"; -export function registerPlugins (app: App) { +export function registerPlugins(app: App) { app .use(vuetify) .use(router) + .use(client); } diff --git a/frontend/typed-router.d.ts b/frontend/typed-router.d.ts index 8d7445f..3530519 100644 --- a/frontend/typed-router.d.ts +++ b/frontend/typed-router.d.ts @@ -20,5 +20,8 @@ declare module 'vue-router/auto-routes' { export interface RouteNamedMap { '/': RouteRecordInfo<'/', '/', Record, Record>, '/cert-request': RouteRecordInfo<'/cert-request', '/cert-request', Record, Record>, + '/certificates/': RouteRecordInfo<'/certificates/', '/certificates', Record, Record>, + '/certificates/[fingerprint]': RouteRecordInfo<'/certificates/[fingerprint]', '/certificates/:fingerprint', { fingerprint: ParamValue }, { fingerprint: ParamValue }>, + '/certificates/new': RouteRecordInfo<'/certificates/new', '/certificates/new', Record, Record>, } } diff --git a/src/main/java/de/mlessmann/certassist/config/SecurityConfiguration.java b/src/main/java/de/mlessmann/certassist/config/SecurityConfiguration.java index c30d79f..14c324a 100644 --- a/src/main/java/de/mlessmann/certassist/config/SecurityConfiguration.java +++ b/src/main/java/de/mlessmann/certassist/config/SecurityConfiguration.java @@ -16,7 +16,7 @@ public class SecurityConfiguration { // Allow unauthenticated access to OpenAPI and swagger documentation. // This should be removed or at least configurable at some point, but for now, this is fine (tm) http.authorizeHttpRequests(auth -> auth - .requestMatchers("/v3/api-docs/**", "/swagger-ui/**", "/swagger-ui.html") + .requestMatchers("/v3/api-docs/**", "/v3/api-docs.yaml", "/swagger-ui/**", "/swagger-ui.html") .permitAll()); return http.build(); } diff --git a/src/main/java/de/mlessmann/certassist/web/CertificatesEndpoint.java b/src/main/java/de/mlessmann/certassist/web/CertificatesEndpoint.java index 8737584..27bf6b3 100644 --- a/src/main/java/de/mlessmann/certassist/web/CertificatesEndpoint.java +++ b/src/main/java/de/mlessmann/certassist/web/CertificatesEndpoint.java @@ -38,6 +38,18 @@ public class CertificatesEndpoint { return ResponseEntity.ok(DocumentedPage.of(certificates)); } + @GetMapping("/certificates/{fingerprint}") + @Operation( + description = "Fetches a single certificate by the provided fingerprint", + responses = { + @ApiResponse(responseCode = "200") + } + ) + public ResponseEntity getCertificate(@PathVariable String fingerprint) { + var certificate = certificateRepository.findByFingerprintIs(fingerprint); + return ResponseEntity.ok(certificate); + } + @PostMapping("/certificates") @Operation(description = "Requests a new certificate", responses = { @ApiResponse(responseCode = "400", description = "One of the provided parameters is invalid."),