add configurable logoutPage URL and re-enable logout with proxy/hook auth, re: #870
parent
35d1c09243
commit
8dd871df17
|
@ -38,6 +38,8 @@ func addConfigFlags(flags *pflag.FlagSet) {
|
||||||
flags.String("auth.header", "", "HTTP header for auth.method=proxy")
|
flags.String("auth.header", "", "HTTP header for auth.method=proxy")
|
||||||
flags.String("auth.command", "", "command for auth.method=hook")
|
flags.String("auth.command", "", "command for auth.method=hook")
|
||||||
|
|
||||||
|
flags.String("logoutpage", "", "custom logout page")
|
||||||
|
|
||||||
flags.String("recaptcha.host", "https://www.google.com", "use another host for ReCAPTCHA. recaptcha.net might be useful in China")
|
flags.String("recaptcha.host", "https://www.google.com", "use another host for ReCAPTCHA. recaptcha.net might be useful in China")
|
||||||
flags.String("recaptcha.key", "", "ReCaptcha site key")
|
flags.String("recaptcha.key", "", "ReCaptcha site key")
|
||||||
flags.String("recaptcha.secret", "", "ReCaptcha secret")
|
flags.String("recaptcha.secret", "", "ReCaptcha secret")
|
||||||
|
@ -145,6 +147,7 @@ func printSettings(ser *settings.Server, set *settings.Settings, auther auth.Aut
|
||||||
fmt.Fprintf(w, "Sign up:\t%t\n", set.Signup)
|
fmt.Fprintf(w, "Sign up:\t%t\n", set.Signup)
|
||||||
fmt.Fprintf(w, "Create User Dir:\t%t\n", set.CreateUserDir)
|
fmt.Fprintf(w, "Create User Dir:\t%t\n", set.CreateUserDir)
|
||||||
fmt.Fprintf(w, "Auth method:\t%s\n", set.AuthMethod)
|
fmt.Fprintf(w, "Auth method:\t%s\n", set.AuthMethod)
|
||||||
|
fmt.Fprintf(w, "LogoutPage:\t%s\n", set.LogoutPage)
|
||||||
fmt.Fprintf(w, "Shell:\t%s\t\n", strings.Join(set.Shell, " "))
|
fmt.Fprintf(w, "Shell:\t%s\t\n", strings.Join(set.Shell, " "))
|
||||||
fmt.Fprintln(w, "\nBranding:")
|
fmt.Fprintln(w, "\nBranding:")
|
||||||
fmt.Fprintf(w, "\tName:\t%s\n", set.Branding.Name)
|
fmt.Fprintf(w, "\tName:\t%s\n", set.Branding.Name)
|
||||||
|
|
|
@ -47,6 +47,8 @@ you want to change. Other options will remain unchanged.`,
|
||||||
set.Signup = mustGetBool(flags, flag.Name)
|
set.Signup = mustGetBool(flags, flag.Name)
|
||||||
case "auth.method":
|
case "auth.method":
|
||||||
hasAuth = true
|
hasAuth = true
|
||||||
|
case "logoutpage":
|
||||||
|
set.LogoutPage = mustGetString(flags, flag.Name)
|
||||||
case "shell":
|
case "shell":
|
||||||
set.Shell = convertCmdStrToCmdArray(mustGetString(flags, flag.Name))
|
set.Shell = convertCmdStrToCmdArray(mustGetString(flags, flag.Name))
|
||||||
case "create-user-dir":
|
case "create-user-dir":
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
DisableUsedPercentage: false,
|
DisableUsedPercentage: false,
|
||||||
EnableExec: true,
|
EnableExec: true,
|
||||||
EnableThumbs: true,
|
EnableThumbs: true,
|
||||||
|
LogoutPage: "",
|
||||||
LoginPage: true,
|
LoginPage: true,
|
||||||
Name: "",
|
Name: "",
|
||||||
NoAuth: false,
|
NoAuth: false,
|
||||||
|
|
|
@ -124,6 +124,7 @@ import {
|
||||||
disableExternal,
|
disableExternal,
|
||||||
disableUsedPercentage,
|
disableUsedPercentage,
|
||||||
noAuth,
|
noAuth,
|
||||||
|
logoutPage,
|
||||||
loginPage,
|
loginPage,
|
||||||
} from "@/utils/constants";
|
} from "@/utils/constants";
|
||||||
import { files as api } from "@/api";
|
import { files as api } from "@/api";
|
||||||
|
@ -153,7 +154,7 @@ export default {
|
||||||
version: () => version,
|
version: () => version,
|
||||||
disableExternal: () => disableExternal,
|
disableExternal: () => disableExternal,
|
||||||
disableUsedPercentage: () => disableUsedPercentage,
|
disableUsedPercentage: () => disableUsedPercentage,
|
||||||
canLogout: () => !noAuth && loginPage,
|
canLogout: () => !noAuth && (loginPage || logoutPage !== "/login"),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(useLayoutStore, ["closeHovers", "showHover"]),
|
...mapActions(useLayoutStore, ["closeHovers", "showHover"]),
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { useAuthStore } from "@/stores/auth";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import type { JwtPayload } from "jwt-decode";
|
import type { JwtPayload } from "jwt-decode";
|
||||||
import { jwtDecode } from "jwt-decode";
|
import { jwtDecode } from "jwt-decode";
|
||||||
import { baseURL, noAuth } from "./constants";
|
import { baseURL, noAuth, logoutPage } from "./constants";
|
||||||
import { StatusError } from "@/api/utils";
|
import { StatusError } from "@/api/utils";
|
||||||
|
|
||||||
export function parseToken(token: string) {
|
export function parseToken(token: string) {
|
||||||
|
@ -101,6 +101,8 @@ export function logout() {
|
||||||
localStorage.setItem("jwt", "");
|
localStorage.setItem("jwt", "");
|
||||||
if (noAuth) {
|
if (noAuth) {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
} else if (logoutPage !== "/login") {
|
||||||
|
document.location.href = `${logoutPage}`;
|
||||||
} else {
|
} else {
|
||||||
router.push({ path: "/login" });
|
router.push({ path: "/login" });
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ const version: string = window.FileBrowser.Version;
|
||||||
const logoURL = `${staticURL}/img/logo.svg`;
|
const logoURL = `${staticURL}/img/logo.svg`;
|
||||||
const noAuth: boolean = window.FileBrowser.NoAuth;
|
const noAuth: boolean = window.FileBrowser.NoAuth;
|
||||||
const authMethod = window.FileBrowser.AuthMethod;
|
const authMethod = window.FileBrowser.AuthMethod;
|
||||||
|
const logoutPage: string = window.FileBrowser.LogoutPage || "/login";
|
||||||
const loginPage: boolean = window.FileBrowser.LoginPage;
|
const loginPage: boolean = window.FileBrowser.LoginPage;
|
||||||
const theme: UserTheme = window.FileBrowser.Theme;
|
const theme: UserTheme = window.FileBrowser.Theme;
|
||||||
const enableThumbs: boolean = window.FileBrowser.EnableThumbs;
|
const enableThumbs: boolean = window.FileBrowser.EnableThumbs;
|
||||||
|
@ -31,6 +32,7 @@ export {
|
||||||
version,
|
version,
|
||||||
noAuth,
|
noAuth,
|
||||||
authMethod,
|
authMethod,
|
||||||
|
logoutPage,
|
||||||
loginPage,
|
loginPage,
|
||||||
theme,
|
theme,
|
||||||
enableThumbs,
|
enableThumbs,
|
||||||
|
|
|
@ -38,6 +38,7 @@ func handleWithStaticData(w http.ResponseWriter, _ *http.Request, d *data, fSys
|
||||||
"Signup": d.settings.Signup,
|
"Signup": d.settings.Signup,
|
||||||
"NoAuth": d.settings.AuthMethod == auth.MethodNoAuth,
|
"NoAuth": d.settings.AuthMethod == auth.MethodNoAuth,
|
||||||
"AuthMethod": d.settings.AuthMethod,
|
"AuthMethod": d.settings.AuthMethod,
|
||||||
|
"LogoutPage": d.settings.LogoutPage,
|
||||||
"LoginPage": auther.LoginPage(),
|
"LoginPage": auther.LoginPage(),
|
||||||
"CSS": false,
|
"CSS": false,
|
||||||
"ReCaptcha": false,
|
"ReCaptcha": false,
|
||||||
|
|
|
@ -9,7 +9,10 @@ import (
|
||||||
"github.com/filebrowser/filebrowser/v2/rules"
|
"github.com/filebrowser/filebrowser/v2/rules"
|
||||||
)
|
)
|
||||||
|
|
||||||
const DefaultUsersHomeBasePath = "/users"
|
const (
|
||||||
|
DefaultLogoutPage = "/login"
|
||||||
|
DefaultUsersHomeBasePath = "/users"
|
||||||
|
)
|
||||||
|
|
||||||
// AuthMethod describes an authentication method.
|
// AuthMethod describes an authentication method.
|
||||||
type AuthMethod string
|
type AuthMethod string
|
||||||
|
@ -22,6 +25,7 @@ type Settings struct {
|
||||||
UserHomeBasePath string `json:"userHomeBasePath"`
|
UserHomeBasePath string `json:"userHomeBasePath"`
|
||||||
Defaults UserDefaults `json:"defaults"`
|
Defaults UserDefaults `json:"defaults"`
|
||||||
AuthMethod AuthMethod `json:"authMethod"`
|
AuthMethod AuthMethod `json:"authMethod"`
|
||||||
|
LogoutPage string `json:"logoutPage"`
|
||||||
Branding Branding `json:"branding"`
|
Branding Branding `json:"branding"`
|
||||||
Tus Tus `json:"tus"`
|
Tus Tus `json:"tus"`
|
||||||
Commands map[string][]string `json:"commands"`
|
Commands map[string][]string `json:"commands"`
|
||||||
|
|
|
@ -33,6 +33,9 @@ func (s *Storage) Get() (*Settings, error) {
|
||||||
if set.UserHomeBasePath == "" {
|
if set.UserHomeBasePath == "" {
|
||||||
set.UserHomeBasePath = DefaultUsersHomeBasePath
|
set.UserHomeBasePath = DefaultUsersHomeBasePath
|
||||||
}
|
}
|
||||||
|
if set.LogoutPage == "" {
|
||||||
|
set.LogoutPage = DefaultLogoutPage
|
||||||
|
}
|
||||||
if set.Tus == (Tus{}) {
|
if set.Tus == (Tus{}) {
|
||||||
set.Tus = Tus{
|
set.Tus = Tus{
|
||||||
ChunkSize: DefaultTusChunkSize,
|
ChunkSize: DefaultTusChunkSize,
|
||||||
|
|
Loading…
Reference in New Issue