Skip to content

armgit / ente

Public Imported from GitHub
0

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

[accounts] Make it easier for self hosters to use passkeys

Manav Rathi02a4e2b1ca45
diff --git a/web/apps/accounts/src/services/passkey.ts b/web/apps/accounts/src/services/passkey.ts
index 4f4ab55099..5d056901fa 100644
--- a/web/apps/accounts/src/services/passkey.ts
+++ b/web/apps/accounts/src/services/passkey.ts
@@ -343,8 +343,18 @@ const authenticatorAttestationResponse = (credential: Credential) => {
* Return `true` if the given {@link redirectURL} (obtained from the redirect
* query parameter passed around during the passkey verification flow) is one of
* the whitelisted URLs that we allow redirecting to on success.
+ *
+ * This check is likely not necessary but we've only kept it just to be on the
+ * safer side. However, this gets in the way of people who are self hosting
+ * Ente. So only do this check if we're running on our production servers (or
+ * localhost).
*/
export const isWhitelistedRedirect = (redirectURL: URL) =>
+ shouldRestrictToWhitelistedRedirect()
+ ? _isWhitelistedRedirect(redirectURL)
+ : true;
+
+const _isWhitelistedRedirect = (redirectURL: URL) =>
(isDevBuild && redirectURL.hostname.endsWith("localhost")) ||
redirectURL.host.endsWith(".ente.io") ||
redirectURL.host.endsWith(".ente.sh") ||
@@ -352,6 +362,16 @@ export const isWhitelistedRedirect = (redirectURL: URL) =>
redirectURL.protocol == "enteauth:" ||
redirectURL.protocol == "ente-cli:";
+export const shouldRestrictToWhitelistedRedirect = () => {
+ // host includes port, hostname is sans port
+ const hostname = new URL(window.location.origin).hostname;
+ return (
+ hostname.endsWith("localhost") ||
+ hostname.endsWith(".ente.io") ||
+ hostname.endsWith(".ente.sh")
+ );
+};
+
export interface BeginPasskeyAuthenticationResponse {
/**
* An identifier for this authentication ceremony / session.