mirror of
https://github.com/gtsteffaniak/filebrowser.git
synced 2026-11-15 21:45:55 -05:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8c9b9419e | ||
|
|
628d6c0b7d | ||
|
|
c51b0ee973 | ||
|
|
64a0276f7d | ||
|
|
fc5f59f0b7 | ||
|
|
fe7abcffaf | ||
|
|
fefbd78d4a | ||
|
|
be50a3f871 | ||
|
|
813e13bab4 | ||
|
|
653410e408 | ||
|
|
075b61d7be |
No files matched your search
+1
-7
@@ -2,16 +2,10 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. For commit guidelines, please refer to [Standard Version](https://github.com/conventional-changelog/standard-version).
|
||||
|
||||
## v1.2.7-beta
|
||||
|
||||
**BugFixes**:
|
||||
- head > title > infinitely duplicating titles (#2016)
|
||||
- Proxy auth not working with Nginx, stuck at logo (#2013)
|
||||
|
||||
## v1.2.6-beta
|
||||
|
||||
**Security**:
|
||||
- resolves https://github.com/gtsteffaniak/filebrowser/security/advisories/GHSA-8vrh-3pm2-v4v6
|
||||
- resolves CVE https://github.com/gtsteffaniak/filebrowser/security/advisories/GHSA-8vrh-3pm2-v4v6
|
||||
|
||||
## v1.2.5-beta
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/gtsteffaniak/filebrowser/backend/common/settings"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/common/utils"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/database/share"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/database/users"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/preview"
|
||||
"github.com/gtsteffaniak/go-logger/logger"
|
||||
|
||||
@@ -490,3 +491,43 @@ func getShareImagePartsHelper(share *share.Link, isBanner bool) (string, string,
|
||||
|
||||
return sourceName, assetPath, nil
|
||||
}
|
||||
|
||||
// shareInfoHandler retrieves share information by hash.
|
||||
// @Summary Get share information by hash
|
||||
// @Description Returns information about a share link based on its hash. This endpoint is publicly accessible and can be used with or without authentication.
|
||||
// @Tags Shares
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param hash query string true "Hash of the share link"
|
||||
// @Success 200 {object} share.CommonShare "Share information"
|
||||
// @Failure 404 {object} map[string]string "Share hash not found"
|
||||
// @Router /public/api/shareinfo [get]
|
||||
func shareInfoHandler(w http.ResponseWriter, r *http.Request, d *requestContext) (int, error) {
|
||||
hash := r.URL.Query().Get("hash")
|
||||
// Get the file link by hash (need full Link to get Token)
|
||||
shareLink, err := store.Share.GetByHash(hash)
|
||||
if err != nil {
|
||||
return http.StatusNotFound, fmt.Errorf("share hash not found")
|
||||
}
|
||||
commonShare := shareLink.CommonShare
|
||||
commonShare.ShareURL = getShareURL(r, hash, false, "")
|
||||
_, _, err = getShareImagePartsHelper(shareLink, true)
|
||||
if err == nil {
|
||||
commonShare.BannerUrl = fmt.Sprintf("%spublic/api/share/image?banner=true&hash=%s", config.Server.BaseURL, hash)
|
||||
}
|
||||
_, _, err = getShareImagePartsHelper(shareLink, false)
|
||||
if err == nil {
|
||||
commonShare.FaviconUrl = fmt.Sprintf("%spublic/api/share/image?favicon=true&hash=%s", config.Server.BaseURL, hash)
|
||||
}
|
||||
commonShare.Source = ""
|
||||
commonShare.Path = ""
|
||||
commonShare.SidebarLinks = []users.SidebarLink{}
|
||||
for _, link := range shareLink.SidebarLinks {
|
||||
if link.Category == "download" && shareLink.ShareType == "upload" {
|
||||
continue
|
||||
} else {
|
||||
commonShare.SidebarLinks = append(commonShare.SidebarLinks, link)
|
||||
}
|
||||
}
|
||||
return renderJSON(w, r, commonShare)
|
||||
}
|
||||
@@ -592,46 +592,6 @@ func getShareURL(r *http.Request, hash string, isDirectDownload bool, token stri
|
||||
return shareURL
|
||||
}
|
||||
|
||||
// shareInfoHandler retrieves share information by hash.
|
||||
// @Summary Get share information by hash
|
||||
// @Description Returns information about a share link based on its hash. This endpoint is publicly accessible and can be used with or without authentication.
|
||||
// @Tags Shares
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param hash query string true "Hash of the share link"
|
||||
// @Success 200 {object} share.CommonShare "Share information"
|
||||
// @Failure 404 {object} map[string]string "Share hash not found"
|
||||
// @Router /public/api/shareinfo [get]
|
||||
func shareInfoHandler(w http.ResponseWriter, r *http.Request, d *requestContext) (int, error) {
|
||||
hash := r.URL.Query().Get("hash")
|
||||
// Get the file link by hash (need full Link to get Token)
|
||||
shareLink, err := store.Share.GetByHash(hash)
|
||||
if err != nil {
|
||||
return http.StatusNotFound, fmt.Errorf("share hash not found")
|
||||
}
|
||||
commonShare := shareLink.CommonShare
|
||||
commonShare.ShareURL = getShareURL(r, hash, false, "")
|
||||
_, _, err = getShareImagePartsHelper(shareLink, true)
|
||||
if err == nil {
|
||||
commonShare.BannerUrl = fmt.Sprintf("%spublic/api/share/image?banner=true&hash=%s", config.Server.BaseURL, hash)
|
||||
}
|
||||
_, _, err = getShareImagePartsHelper(shareLink, false)
|
||||
if err == nil {
|
||||
commonShare.FaviconUrl = fmt.Sprintf("%spublic/api/share/image?favicon=true&hash=%s", config.Server.BaseURL, hash)
|
||||
}
|
||||
commonShare.Source = ""
|
||||
commonShare.Path = ""
|
||||
commonShare.SidebarLinks = []users.SidebarLink{}
|
||||
for _, link := range shareLink.SidebarLinks {
|
||||
if link.Category == "download" && shareLink.ShareType == "upload" {
|
||||
continue
|
||||
} else {
|
||||
commonShare.SidebarLinks = append(commonShare.SidebarLinks, link)
|
||||
}
|
||||
}
|
||||
return renderJSON(w, r, commonShare)
|
||||
}
|
||||
|
||||
func getSharePasswordHash(body share.CreateBody) (data []byte, statuscode int, err error) {
|
||||
if body.Password == "" {
|
||||
return nil, 0, nil
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { globalVars } from "@/utils/constants";
|
||||
|
||||
const ssl = window.location.protocol === "https:";
|
||||
const protocol = ssl ? "wss:" : "ws:";
|
||||
|
||||
export default function command(url, command, onmessage, onclose) {
|
||||
url = `${protocol}//${window.location.host}${globalVars.baseURL}api/command${url}`;
|
||||
let conn = new window.WebSocket(url);
|
||||
conn.onopen = () => conn.send(command);
|
||||
conn.onmessage = onmessage;
|
||||
conn.onclose = onclose;
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import { fetchURL, fetchJSON } from '@/api/utils'
|
||||
import { getApiPath, getPublicApiPath } from '@/utils/url.js'
|
||||
import { notify } from '@/notify' // Import notify for error handling
|
||||
|
||||
export async function getAllUsers() {
|
||||
try {
|
||||
const apiPath = getApiPath('api/users')
|
||||
|
||||
@@ -11,10 +11,10 @@ import { mutations } from "@/store";
|
||||
import { validateLogin } from "@/utils/auth";
|
||||
import i18n from "@/i18n";
|
||||
|
||||
|
||||
const titles = {
|
||||
Login: i18n.global.t("general.login"),
|
||||
Share: i18n.global.t("general.share"),
|
||||
PublicShare: i18n.global.t("general.share"),
|
||||
Files: i18n.global.t("general.files"),
|
||||
Tools: i18n.global.t("general.tool"),
|
||||
Settings: i18n.global.t("general.settings"),
|
||||
@@ -180,12 +180,11 @@ router.beforeResolve(async (to, from, next) => {
|
||||
to.matched.some((record) => record.meta.requiresAuth) ||
|
||||
to.matched.some((record) => record.meta.optionalAuth)
|
||||
) {
|
||||
const isPublicRoute = to.path.startsWith("/public");
|
||||
if (state?.user?.username) {
|
||||
// do nothing, user is already set
|
||||
} else {
|
||||
try {
|
||||
await validateLogin(isPublicRoute);
|
||||
await validateLogin();
|
||||
} catch (error) {
|
||||
mutations.setCurrentUser(getters.anonymous());
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ export interface UserObject {
|
||||
rules?: any[];
|
||||
lockPassword?: boolean;
|
||||
hideDotfiles?: boolean;
|
||||
commands?: string[];
|
||||
sorting?: {
|
||||
by: string;
|
||||
asc: boolean;
|
||||
|
||||
@@ -2,12 +2,9 @@ import { mutations, getters,state } from "@/store";
|
||||
import { getApiPath, getPublicApiPath } from "@/utils/url.js";
|
||||
import { globalVars } from "@/utils/constants";
|
||||
|
||||
export async function validateLogin(isPublicRoute = false) {
|
||||
export async function validateLogin() {
|
||||
// Use direct fetch to avoid automatic logout on 401
|
||||
// Public routes (e.g. /public/share/...) use the public API base path
|
||||
const apiPath = isPublicRoute
|
||||
? getPublicApiPath('users', { id: 'self' })
|
||||
: getApiPath('/api/users', { id: 'self' });
|
||||
let apiPath = getPublicApiPath('users', { id: 'self' });
|
||||
const res = await fetch(apiPath, {
|
||||
credentials: 'same-origin', // Ensure cookies are sent with the request
|
||||
headers: {
|
||||
|
||||
@@ -356,7 +356,8 @@ export default {
|
||||
|
||||
// Display initial data immediately
|
||||
mutations.replaceRequest(file);
|
||||
document.title = globalVars.name + " - " + this.$t("general.share") + " - " + file.name;
|
||||
document.title = `${document.title} - ${file.name}`;
|
||||
|
||||
// Second pass: If directory has metadata available, fetch again with metadata IN THE BACKGROUND
|
||||
if (file.type === "directory" && file.hasMetadata) {
|
||||
this.loadingProgress = 90;
|
||||
@@ -475,7 +476,7 @@ export default {
|
||||
if (state.sources.count > 1) {
|
||||
mutations.setCurrentSource(data.source);
|
||||
}
|
||||
document.title = globalVars.name + " - " + this.$t("general.files") + " - " + res.name;
|
||||
document.title = `${document.title} - ${res.name}`;
|
||||
|
||||
// Display initial data immediately and clear loading spinner
|
||||
mutations.replaceRequest(data);
|
||||
|
||||
Reference in new issue
Block a user