add support for some basic authentication methods

This commit is contained in:
Alisdair MacLeod
2026-01-29 16:34:52 +00:00
parent 0d480071b6
commit e95cfa1a00
12 changed files with 867 additions and 449 deletions

View File

@@ -1,6 +1,7 @@
package auth
import (
"context"
"crypto/rand"
_ "embed"
"encoding/base64"
@@ -8,6 +9,10 @@ import (
"net/http"
"sync"
"time"
"google.golang.org/grpc"
"github.com/netbirdio/netbird/shared/management/proto"
)
//go:embed auth.gohtml
@@ -16,9 +21,10 @@ var authTemplate string
type Method string
var (
MethodBasicAuth Method = "basic"
MethodPIN Method = "pin"
MethodBearer Method = "bearer"
MethodPassword Method = "password"
MethodPIN Method = "pin"
MethodOIDC Method = "oidc"
MethodLink Method = "link"
)
func (m Method) String() string {
@@ -36,6 +42,10 @@ type session struct {
CreatedAt time.Time
}
type authenticator interface {
Authenticate(ctx context.Context, in *proto.AuthenticateRequest, opts ...grpc.CallOption) (*proto.AuthenticateResponse, error)
}
type Scheme interface {
Type() Method
// Authenticate should check the passed request and determine whether