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:
@@ -76,23 +76,13 @@ export function removePrefix(url: string): string {
|
||||
return url;
|
||||
}
|
||||
|
||||
export function createURL(endpoint: string, params = {}, auth = true): string {
|
||||
const authStore = useAuthStore();
|
||||
|
||||
export function createURL(endpoint: string, searchParams = {}): string {
|
||||
let prefix = baseURL;
|
||||
if (!prefix.endsWith("/")) {
|
||||
prefix = prefix + "/";
|
||||
}
|
||||
const url = new URL(prefix + encodePath(endpoint), origin);
|
||||
|
||||
const searchParams: SearchParams = {
|
||||
...(auth && { auth: authStore.jwt }),
|
||||
...params,
|
||||
};
|
||||
|
||||
for (const key in searchParams) {
|
||||
url.searchParams.set(key, searchParams[key]);
|
||||
}
|
||||
url.search = new URLSearchParams(searchParams).toString();
|
||||
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user