mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 07:16:38 +00:00
remove basic auth scheme
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"crypto/subtle"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type BasicAuth struct {
|
||||
username, password string
|
||||
}
|
||||
|
||||
func NewBasicAuth(username string, password string) BasicAuth {
|
||||
return BasicAuth{
|
||||
username: username,
|
||||
password: password,
|
||||
}
|
||||
}
|
||||
|
||||
func (BasicAuth) Type() Method {
|
||||
return MethodBasicAuth
|
||||
}
|
||||
|
||||
func (b BasicAuth) Authenticate(r *http.Request) (string, bool, any) {
|
||||
username, password, ok := r.BasicAuth()
|
||||
if !ok {
|
||||
return "", false, nil
|
||||
}
|
||||
|
||||
usernameMatch := subtle.ConstantTimeCompare([]byte(username), []byte(b.username)) == 1
|
||||
passwordMatch := subtle.ConstantTimeCompare([]byte(password), []byte(b.password)) == 1
|
||||
|
||||
// If authenticated, then return the username.
|
||||
if usernameMatch && passwordMatch {
|
||||
return username, false, nil
|
||||
}
|
||||
|
||||
return "", false, nil
|
||||
}
|
||||
|
||||
func (b BasicAuth) Middleware(next http.Handler) http.Handler {
|
||||
return next
|
||||
}
|
||||
@@ -20,13 +20,14 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/cloudflare/backoff"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/netbirdio/netbird/proxy/internal/accesslog"
|
||||
"github.com/netbirdio/netbird/proxy/internal/acme"
|
||||
"github.com/netbirdio/netbird/proxy/internal/auth"
|
||||
"github.com/netbirdio/netbird/proxy/internal/proxy"
|
||||
"github.com/netbirdio/netbird/proxy/internal/roundtrip"
|
||||
"github.com/netbirdio/netbird/shared/management/proto"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type errorLog interface {
|
||||
@@ -215,12 +216,6 @@ func (s *Server) updateMapping(ctx context.Context, mapping *proto.ProxyMapping)
|
||||
// Note: this does require the management server to always send a
|
||||
// full mapping rather than deltas during a modification.
|
||||
var schemes []auth.Scheme
|
||||
if mapping.GetAuth().GetBasic().GetEnabled() {
|
||||
schemes = append(schemes, auth.NewBasicAuth(
|
||||
mapping.GetAuth().GetBasic().GetUsername(),
|
||||
mapping.GetAuth().GetBasic().GetPassword(),
|
||||
))
|
||||
}
|
||||
if mapping.GetAuth().GetPin().GetEnabled() {
|
||||
schemes = append(schemes, auth.NewPin(
|
||||
mapping.GetAuth().GetPin().GetPin(),
|
||||
|
||||
Reference in New Issue
Block a user