add stateless proxy sessions

This commit is contained in:
Alisdair MacLeod
2026-02-04 16:52:35 +00:00
parent 476785b122
commit 694ae13418
16 changed files with 744 additions and 774 deletions

View File

@@ -3,13 +3,11 @@ package auth
import (
"net/http"
"github.com/netbirdio/netbird/proxy/auth"
"github.com/netbirdio/netbird/shared/management/proto"
)
const (
passwordUserId = "password-user"
passwordFormId = "password"
)
const passwordFormId = "password"
type Password struct {
id, accountId string
@@ -24,8 +22,8 @@ func NewPassword(client authenticator, id, accountId string) Password {
}
}
func (Password) Type() Method {
return MethodPassword
func (Password) Type() auth.Method {
return auth.MethodPassword
}
// Authenticate attempts to authenticate the request using a form
@@ -37,7 +35,7 @@ func (p Password) Authenticate(r *http.Request) (string, string) {
password := r.FormValue(passwordFormId)
if password == "" {
// This cannot be authenticated so not worth wasting time sending the request.
// This cannot be authenticated, so not worth wasting time sending the request.
return "", passwordFormId
}
@@ -56,7 +54,7 @@ func (p Password) Authenticate(r *http.Request) (string, string) {
}
if res.GetSuccess() {
return passwordUserId, ""
return res.GetSessionToken(), ""
}
return "", passwordFormId