refactor: extract a create cookie middleware

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2024-03-18 10:27:26 +01:00
committed by Patrik Oldsberg
parent 7b77befdfb
commit f17da85b08
9 changed files with 56 additions and 12 deletions
+1
View File
@@ -51,6 +51,7 @@
"@backstage/config-loader": "workspace:^",
"@backstage/errors": "workspace:^",
"@backstage/plugin-app-node": "workspace:^",
"@backstage/plugin-auth-node": "workspace:^",
"@backstage/types": "workspace:^",
"@types/express": "^4.17.6",
"express": "^4.17.1",
+2 -2
View File
@@ -40,6 +40,7 @@ import {
import { ConfigSchema } from '@backstage/config-loader';
import { AuthService, HttpAuthService } from '@backstage/backend-plugin-api';
import { AuthenticationError } from '@backstage/errors';
import { createCookieAuthRefreshMiddleware } from '@backstage/plugin-auth-node';
// express uses mime v1 while we only have types for mime v2
type Mime = { lookup(arg0: string): string };
@@ -184,8 +185,7 @@ export async function createRouter(
if (enablePublicEntryPoint && auth && httpAuth) {
const publicRouter = Router();
// TODO
// publicRouter.use(createCookieAuthRouter({ httpAuth }))
publicRouter.use(createCookieAuthRefreshMiddleware({ httpAuth }));
publicRouter.use(async (req, _res, next) => {
const credentials = await httpAuth.credentials(req, {