Skip to content

Commit

Permalink
fix: removes any configuration from index.html when users are not aut…
Browse files Browse the repository at this point in the history
…henticated (#2889)
  • Loading branch information
amir20 committed Apr 11, 2024
1 parent ac04e4c commit b781570
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
3 changes: 1 addition & 2 deletions assets/pages/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});
Expand Down
2 changes: 2 additions & 0 deletions assets/stores/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const pageConfig = JSON.parse(text);

const config: Config = {
maxLogs: 600,
version: "v0.0.0",
hosts: [],
...pageConfig,
};

Expand Down
16 changes: 10 additions & 6 deletions internal/web/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow: /

0 comments on commit b781570

Please sign in to comment.