Skip to content

Commit

Permalink
fix!: bypass on SHOULD_AUTH
Browse files Browse the repository at this point in the history
  • Loading branch information
jabuxas committed Nov 1, 2024
1 parent b73c06f commit efe5cf7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 0 additions & 8 deletions abyss.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,4 @@ func setupHandlers(mux *http.ServeMux, app *Application) {
mux.HandleFunc("/token", BasicAuth(app.createTokenHandler, app))

mux.HandleFunc("/files/", app.fileHandler)

if app.authUpload == "yes" {
mux.HandleFunc("/upload", BasicAuth(app.uploadHandler, app))
slog.Warn("text uploading will be restricted")
} else {
mux.HandleFunc("/upload", app.uploadHandler)
slog.Warn("text uploading will NOT be restricted")
}
}
6 changes: 5 additions & 1 deletion handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ func (app *Application) lastUploadedHandler(w http.ResponseWriter, r *http.Reque

func (app *Application) uploadHandler(w http.ResponseWriter, r *http.Request) {
if contentType := r.Header.Get("Content-Type"); contentType == "application/x-www-form-urlencoded" {
app.formHandler(w, r)
if app.authUpload == "yes" {
BasicAuth(app.formHandler, app)(w, r)
} else {
app.formHandler(w, r)
}
} else if strings.Split(contentType, ";")[0] == "multipart/form-data" {
app.curlHandler(w, r)
} else {
Expand Down

0 comments on commit efe5cf7

Please sign in to comment.