feat: remove cookie on sign out
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
committed by
Patrik Oldsberg
parent
641a068514
commit
a1950ad5e6
+4
@@ -254,6 +254,10 @@ class DefaultHttpAuthService implements HttpAuthService {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
removeUserCookie(res: Response): void {
|
||||
res.clearCookie(BACKSTAGE_AUTH_COOKIE);
|
||||
}
|
||||
}
|
||||
|
||||
/** @public */
|
||||
|
||||
+8
-2
@@ -59,6 +59,8 @@ export const httpRouterServiceFactory = createServiceFactory(
|
||||
rootHttpRouter,
|
||||
lifecycle,
|
||||
}) {
|
||||
let hasRegistedCookieAuthRefreshMiddleware = false;
|
||||
|
||||
if (options?.getPath) {
|
||||
logger.warn(
|
||||
`DEPRECATION WARNING: The 'getPath' option for HttpRouterService is deprecated. The ability to reconfigure the '/api/' path prefix for plugins will be removed in the future.`,
|
||||
@@ -85,8 +87,12 @@ export const httpRouterServiceFactory = createServiceFactory(
|
||||
},
|
||||
addAuthPolicy(policy: HttpRouterServiceAuthPolicy): void {
|
||||
credentialsBarrier.addAuthPolicy(policy);
|
||||
if (policy.allow === 'user-cookie') {
|
||||
// TODO: Make sure this is only added once
|
||||
if (
|
||||
policy.allow === 'user-cookie' &&
|
||||
!hasRegistedCookieAuthRefreshMiddleware
|
||||
) {
|
||||
// Only add the cookie refresh middleware once
|
||||
hasRegistedCookieAuthRefreshMiddleware = true;
|
||||
router.use(createCookieAuthRefreshMiddleware({ httpAuth }));
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user