Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

feat: passkeys flow redir check

httpjamesmd62de0c193d2
diff --git a/apps/accounts/src/pages/passkeys/flow/index.tsx b/apps/accounts/src/pages/passkeys/flow/index.tsx
index f7bc37ee81..e8d7646e8c 100644
--- a/apps/accounts/src/pages/passkeys/flow/index.tsx
+++ b/apps/accounts/src/pages/passkeys/flow/index.tsx
@@ -23,8 +23,25 @@ const PasskeysFlow = () => {
const [loading, setLoading] = useState(true);
const init = async () => {
- // get passkeySessionID from the query params
const searchParams = new URLSearchParams(window.location.search);
+
+ // get redirect from the query params
+ const redirect = searchParams.get('redirect');
+
+ if (!redirect) {
+ setErrored(true);
+ return;
+ }
+
+ const redirectURL = new URL(redirect);
+ if (process.env.NEXT_PUBLIC_DISABLE_REDIRECT_CHECK !== 'true') {
+ if (!redirectURL.host.endsWith('ente.io')) {
+ setErrored(true);
+ return;
+ }
+ }
+
+ // get passkeySessionID from the query params
const passkeySessionID = searchParams.get('passkeySessionID');
setLoading(true);
@@ -83,9 +100,6 @@ const PasskeysFlow = () => {
const encodedResponse = _sodium.to_base64(JSON.stringify(finishData));
- // get redirect from the query params
- const redirect = searchParams.get('redirect');
-
window.location.href = `${redirect}?response=${encodedResponse}`;
};