Skip to content

Commit

Permalink
Dont show user/pw page when using header authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
Forceu committed Dec 29, 2024
1 parent 7a4cf4c commit 115168d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/webserver/Webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func Start() {
mux.HandleFunc("/e2eSetup", requireLogin(showE2ESetup, false))
mux.HandleFunc("/error", showError)
mux.HandleFunc("/error-auth", showErrorAuth)
mux.HandleFunc("/error-header", showErrorHeader)
mux.HandleFunc("/error-oauth", showErrorIntOAuth)
mux.HandleFunc("/forgotpw", forgotPassword)
mux.HandleFunc("/hotlink/", showHotlink)
Expand Down Expand Up @@ -278,6 +279,12 @@ func showErrorAuth(w http.ResponseWriter, r *http.Request) {
helper.CheckIgnoreTimeout(err)
}

// Handling of /error-header
func showErrorHeader(w http.ResponseWriter, r *http.Request) {
err := templateFolder.ExecuteTemplate(w, "error_auth_header", genericView{PublicName: configuration.Get().PublicName})
helper.CheckIgnoreTimeout(err)
}

// Handling of /error-oauth
func showErrorIntOAuth(w http.ResponseWriter, r *http.Request) {
view := oauthErrorView{PublicName: configuration.Get().PublicName}
Expand Down Expand Up @@ -336,6 +343,10 @@ func showLogin(w http.ResponseWriter, r *http.Request) {
redirect(w, "admin")
return
}
if configuration.Get().Authentication.Method == authentication.Header {
redirect(w, "error-header")
return
}
if configuration.Get().Authentication.Method == authentication.OAuth2 {
// If user clicked logout, force consent
if r.URL.Query().Has("consent") {
Expand Down
16 changes: 16 additions & 0 deletions internal/webserver/web/templates/html_error_header.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{define "error_auth_header"}}
{{template "header" .}}

<div class="row">
<div class="col">
<div class="card" style="width: 18rem;">
<div class="card-body">
<h2 class="card-title">Unauthorised</h2>
<br>
<p class="card-text">Error: No login information was sent from the authentication provider.</p><br>
</div>
</div>
</div>
</div>
{{template "footer"}}
{{end}}

0 comments on commit 115168d

Please sign in to comment.