master
bel 2024-03-10 09:51:29 -06:00
parent fb30cc8436
commit 9941706b73
1 changed files with 9 additions and 6 deletions

View File

@ -8,11 +8,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"gogs.inhome.blapointe.com/local/logb"
"gogs.inhome.blapointe.com/local/oauth2/oauth2client"
"gogs.inhome.blapointe.com/local/rproxy3/config"
"gogs.inhome.blapointe.com/local/rproxy3/storage"
"gogs.inhome.blapointe.com/local/rproxy3/storage/packable"
"log" "log"
"net" "net"
"net/http" "net/http"
@ -22,6 +17,12 @@ import (
"strings" "strings"
"time" "time"
"gogs.inhome.blapointe.com/local/logb"
"gogs.inhome.blapointe.com/local/oauth2/oauth2client"
"gogs.inhome.blapointe.com/local/rproxy3/config"
"gogs.inhome.blapointe.com/local/rproxy3/storage"
"gogs.inhome.blapointe.com/local/rproxy3/storage/packable"
"github.com/google/uuid" "github.com/google/uuid"
"golang.org/x/time/rate" "golang.org/x/time/rate"
) )
@ -211,7 +212,8 @@ func (s *Server) doBOAuthZ(foo http.HandlerFunc) http.HandlerFunc {
if ok { if ok {
usr, pwd, ok := r.BasicAuth() usr, pwd, ok := r.BasicAuth()
if !ok || rusr != usr || rpwd != pwd { if !ok || rusr != usr || rpwd != pwd {
w.WriteHeader(http.StatusUnauthorized) w.Header().Set("WWW-Authenticate", "Basic")
w.WriteHeader(403)
log.Printf("denying proxy basic auth") log.Printf("denying proxy basic auth")
return return
} }
@ -224,6 +226,7 @@ func (s *Server) doBOAuthZ(foo http.HandlerFunc) http.HandlerFunc {
if url, exists := config.GetBOAuthZ(); ok && exists { if url, exists := config.GetBOAuthZ(); ok && exists {
err := oauth2client.Authenticate(url, key, w, r) err := oauth2client.Authenticate(url, key, w, r)
if err != nil { if err != nil {
log.Printf("failed proxy oauth2: %v", err)
return return
} }
} }