mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-06-22 09:13:00 +00:00
fix: remove auth query parameter from download and preview links
macOS saves the download URL in the metadata of the downloaded file. This means that the downloaded file contains a metadata item with the JWT token of the user. If the user were to share this file with someone else, they would have access to their account using the JWT in the metadata during the validity of the JWT. The JWT has been removed from the URLs. Since the user is logged in, there is an authentication cookie set. A JWT in the URL is not necessary.
This commit is contained in:
parent
8a14018861
commit
cbb712484d
@ -75,11 +75,6 @@ export function download(format: any, ...files: string[]) {
|
|||||||
url += `algo=${format}&`;
|
url += `algo=${format}&`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const authStore = useAuthStore();
|
|
||||||
if (authStore.jwt) {
|
|
||||||
url += `auth=${authStore.jwt}&`;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.open(url);
|
window.open(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,5 +71,5 @@ export function getDownloadURL(res: Resource, inline = false) {
|
|||||||
...(res.token && { token: res.token }),
|
...(res.token && { token: res.token }),
|
||||||
};
|
};
|
||||||
|
|
||||||
return createURL("api/public/dl/" + res.hash + res.path, params, false);
|
return createURL("api/public/dl/" + res.hash + res.path, params);
|
||||||
}
|
}
|
||||||
|
@ -41,5 +41,5 @@ export async function create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getShareURL(share: Share) {
|
export function getShareURL(share: Share) {
|
||||||
return createURL("share/" + share.hash, {}, false);
|
return createURL("share/" + share.hash, {});
|
||||||
}
|
}
|
||||||
|
@ -76,23 +76,13 @@ export function removePrefix(url: string): string {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createURL(endpoint: string, params = {}, auth = true): string {
|
export function createURL(endpoint: string, searchParams = {}): string {
|
||||||
const authStore = useAuthStore();
|
|
||||||
|
|
||||||
let prefix = baseURL;
|
let prefix = baseURL;
|
||||||
if (!prefix.endsWith("/")) {
|
if (!prefix.endsWith("/")) {
|
||||||
prefix = prefix + "/";
|
prefix = prefix + "/";
|
||||||
}
|
}
|
||||||
const url = new URL(prefix + encodePath(endpoint), origin);
|
const url = new URL(prefix + encodePath(endpoint), origin);
|
||||||
|
url.search = new URLSearchParams(searchParams).toString();
|
||||||
const searchParams: SearchParams = {
|
|
||||||
...(auth && { auth: authStore.jwt }),
|
|
||||||
...params,
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const key in searchParams) {
|
|
||||||
url.searchParams.set(key, searchParams[key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return url.toString();
|
return url.toString();
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ const raw = computed(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isEpub.value) {
|
if (isEpub.value) {
|
||||||
return createURL("api/raw" + fileStore.req?.path, {}, false);
|
return createURL("api/raw" + fileStore.req?.path, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
return downloadUrl.value;
|
return downloadUrl.value;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user