1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-24 14:31:44 +01:00

fix: removes any configuration from index.html when users are not authenticated (#2889)

This commit is contained in:
Amir Raminfar
2024-04-11 09:03:37 -07:00
committed by GitHub
parent ac04e4c149
commit b781570811
4 changed files with 15 additions and 8 deletions

View File

@@ -50,8 +50,7 @@ let form: HTMLFormElement | undefined = $ref();
const params = new URLSearchParams(window.location.search);
async function onLogin() {
const url = config.authProvider === "simple" ? "/api/token" : "/api/validateCredentials";
const response = await fetch(withBase(url), {
const response = await fetch(withBase("/api/token"), {
body: new FormData(form),
method: "POST",
});

View File

@@ -29,6 +29,8 @@ const pageConfig = JSON.parse(text);
const config: Config = {
maxLogs: 600,
version: "v0.0.0",
hosts: [],
...pageConfig,
};

View File

@@ -52,15 +52,19 @@ func (h *handler) executeTemplate(w http.ResponseWriter, req *http.Request) {
})
config := map[string]interface{}{
"base": base,
"version": h.config.Version,
"hostname": h.config.Hostname,
"hosts": hosts,
"authProvider": h.config.Authorization.Provider,
"enableActions": h.config.EnableActions,
"base": base,
}
user := auth.UserFromContext(req.Context())
if h.config.Authorization.Provider == NONE || user != nil {
config["authProvider"] = h.config.Authorization.Provider
config["version"] = h.config.Version
config["hostname"] = h.config.Hostname
config["hosts"] = hosts
config["enableActions"] = h.config.EnableActions
}
if user != nil {
if profile, err := profile.Load(*user); err == nil {
config["profile"] = profile

2
public/robots.txt Normal file
View File

@@ -0,0 +1,2 @@
User-agent: *
Disallow: /