From 672a4b4876db0eb3ba8756503b1252e42f49cf01 Mon Sep 17 00:00:00 2001 From: Stephen Glass Date: Mon, 29 Jul 2024 00:06:51 -0400 Subject: [PATCH] update middleware order Signed-off-by: Stephen Glass --- .../implementations/AuthErrorApi/SignInAuthErrorApi.ts | 2 +- plugins/auth-backend/src/service/router.ts | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/core-app-api/src/apis/implementations/AuthErrorApi/SignInAuthErrorApi.ts b/packages/core-app-api/src/apis/implementations/AuthErrorApi/SignInAuthErrorApi.ts index 2f2ba9cb09..77b3c53f14 100644 --- a/packages/core-app-api/src/apis/implementations/AuthErrorApi/SignInAuthErrorApi.ts +++ b/packages/core-app-api/src/apis/implementations/AuthErrorApi/SignInAuthErrorApi.ts @@ -1,5 +1,5 @@ /* - * Copyright 2021 The Backstage Authors + * 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. diff --git a/plugins/auth-backend/src/service/router.ts b/plugins/auth-backend/src/service/router.ts index b1952755ca..57f01cfba1 100644 --- a/plugins/auth-backend/src/service/router.ts +++ b/plugins/auth-backend/src/service/router.ts @@ -170,16 +170,13 @@ export async function createRouter( userInfoDatabaseHandler, }); + router.use(createCookieAuthErrorMiddleware(appUrl, authUrl)); + // Gives a more helpful error message than a plain 404 - router.use('/:provider/', (req, _, next) => { + router.use('/:provider/', req => { const { provider } = req.params; - if (provider.startsWith('.backstage')) { - return next('route'); - } throw new NotFoundError(`Unknown auth provider '${provider}'`); }); - router.use(createCookieAuthErrorMiddleware(appUrl, authUrl)); - return router; }