mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
[accounts] Make it easier for self hosters to use passkeys
Solves a problem someone was facing on our Discord: https://discord.com/channels/948937918347608085/1215252276911018014/1253766354402545754
This commit is contained in:
parent
30dd41e3ca
commit
02a4e2b1ca
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user