From 6e611a7977e7926260cfc306a1f415882b43daf4 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Tue, 26 Mar 2024 19:56:56 +0100 Subject: [PATCH] backend-app-api: add createAuthIntegrationRouter Signed-off-by: Vincenzo Scamporlino --- .../auth/createAuthIntegrationRouter.ts | 30 +++++++++++++++++++ .../services/implementations/auth/index.ts | 1 + 2 files changed, 31 insertions(+) create mode 100644 packages/backend-app-api/src/services/implementations/auth/createAuthIntegrationRouter.ts diff --git a/packages/backend-app-api/src/services/implementations/auth/createAuthIntegrationRouter.ts b/packages/backend-app-api/src/services/implementations/auth/createAuthIntegrationRouter.ts new file mode 100644 index 0000000000..586846cdeb --- /dev/null +++ b/packages/backend-app-api/src/services/implementations/auth/createAuthIntegrationRouter.ts @@ -0,0 +1,30 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { PublicKeyStoreService } from '@backstage/backend-plugin-api'; +import express from 'express'; +import Router from 'express-promise-router'; + +export function createAuthIntegrationRouter(options: { + publicKeyStore: PublicKeyStoreService; +}): express.Router { + const router = Router(); + + router.get('/.backstage/auth/v1/jwks.json', async (_req, res) => { + res.json({ keys: await options.publicKeyStore.listKeys() }); + }); + + return router; +} diff --git a/packages/backend-app-api/src/services/implementations/auth/index.ts b/packages/backend-app-api/src/services/implementations/auth/index.ts index 1b55d46a83..4bcf535e5b 100644 --- a/packages/backend-app-api/src/services/implementations/auth/index.ts +++ b/packages/backend-app-api/src/services/implementations/auth/index.ts @@ -15,3 +15,4 @@ */ export { authServiceFactory } from './authServiceFactory'; +export { createAuthIntegrationRouter } from './createAuthIntegrationRouter';