Skip to content

Fixes for browserCookiePersistence #8893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/auth/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ export const enum Endpoint {
}

const CookieAuthProxiedEndpoints: string[] = [
Endpoint.FINALIZE_MFA_SIGN_IN,
Endpoint.SIGN_IN_WITH_CUSTOM_TOKEN,
Endpoint.SIGN_IN_WITH_EMAIL_LINK,
Endpoint.SIGN_IN_WITH_IDP,
Endpoint.SIGN_IN_WITH_PASSWORD,
Endpoint.SIGN_IN_WITH_PHONE_NUMBER,
Endpoint.SIGN_UP,
Endpoint.TOKEN
];

Expand Down Expand Up @@ -291,7 +293,7 @@ export async function _getFinalTarget(
if (authInternal._getPersistenceType() === PersistenceType.COOKIE) {
const cookiePersistence =
authInternal._getPersistence() as CookiePersistence;
return cookiePersistence._getFinalTarget(finalTarget).toString();
return cookiePersistence._getFinalTarget(auth, finalTarget).toString();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { Persistence } from '../../model/public_types';
import { Auth, Persistence } from '../../model/public_types';
import type { CookieChangeEvent } from 'cookie-store';

const POLLING_INTERVAL_MS = 1_000;
Expand Down Expand Up @@ -49,12 +49,13 @@ export class CookiePersistence implements PersistenceInternal {
listenerUnsubscribes: Map<StorageEventListener, () => void> = new Map();

// used to get the URL to the backend to proxy to
_getFinalTarget(originalUrl: string): URL | string {
_getFinalTarget(auth: Auth, originalUrl: string): URL | string {
if (typeof window === undefined) {
return originalUrl;
}
const url = new URL(`${window.location.origin}/__cookies__`);
url.searchParams.set('finalTarget', originalUrl);
url.searchParams.set('appName', auth.app.name);
return url;
}

Expand Down
Loading