Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8156ecbb6 | ||
|
|
e14ddaad57 | ||
|
|
65e627febc |
No files matched your search
@@ -1,14 +0,0 @@
|
||||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: Community Support
|
||||
url: https://forum.netbird.io/
|
||||
about: Community support forum
|
||||
- name: Cloud Support
|
||||
url: https://docs.netbird.io/help/report-bug-issues
|
||||
about: Contact us for support
|
||||
- name: Client/Connection Troubleshooting
|
||||
url: https://docs.netbird.io/help/troubleshooting-client
|
||||
about: See our client troubleshooting guide for help addressing common issues
|
||||
- name: Self-host Troubleshooting
|
||||
url: https://docs.netbird.io/selfhosted/troubleshooting
|
||||
about: See our self-host troubleshooting guide for help addressing common issues
|
||||
@@ -46,10 +46,8 @@ const (
|
||||
cmdSFTP = "<sftp>"
|
||||
cmdNonInteractive = "<idle>"
|
||||
|
||||
// DefaultJWTMaxTokenAge is the default maximum age for JWT tokens accepted by the SSH server.
|
||||
// Set to 10 minutes to accommodate identity providers like Azure Entra ID
|
||||
// that backdate the iat claim by up to 5 minutes.
|
||||
DefaultJWTMaxTokenAge = 10 * 60
|
||||
// DefaultJWTMaxTokenAge is the default maximum age for JWT tokens accepted by the SSH server
|
||||
DefaultJWTMaxTokenAge = 5 * 60
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -71,12 +71,14 @@ func NewProxyAuthInterceptors(tokenStore proxyTokenStore) (grpc.UnaryServerInter
|
||||
return handler(ctx, req)
|
||||
}
|
||||
|
||||
token, err := interceptor.validateProxyToken(ctx)
|
||||
if err != nil {
|
||||
// Log auth failures explicitly; gRPC doesn't log these by default.
|
||||
log.WithContext(ctx).Warnf("proxy auth failed: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
// token, err := interceptor.validateProxyToken(ctx)
|
||||
// if err != nil {
|
||||
// // Log auth failures explicitly; gRPC doesn't log these by default.
|
||||
// log.WithContext(ctx).Warnf("proxy auth failed: %v", err)
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
token := &types.ProxyAccessToken{ID: "dummy"}
|
||||
|
||||
ctx = context.WithValue(ctx, ProxyTokenContextKey, token)
|
||||
return handler(ctx, req)
|
||||
@@ -87,12 +89,13 @@ func NewProxyAuthInterceptors(tokenStore proxyTokenStore) (grpc.UnaryServerInter
|
||||
return handler(srv, ss)
|
||||
}
|
||||
|
||||
token, err := interceptor.validateProxyToken(ss.Context())
|
||||
if err != nil {
|
||||
// Log auth failures explicitly; gRPC doesn't log these by default.
|
||||
log.WithContext(ss.Context()).Warnf("proxy auth failed: %v", err)
|
||||
return err
|
||||
}
|
||||
// token, err := interceptor.validateProxyToken(ss.Context())
|
||||
// if err != nil {
|
||||
// // Log auth failures explicitly; gRPC doesn't log these by default.
|
||||
// log.WithContext(ss.Context()).Warnf("proxy auth failed: %v", err)
|
||||
// return err
|
||||
// }
|
||||
token := &types.ProxyAccessToken{ID: "dummy"} // TODO: Implement token validation for streaming methods.
|
||||
|
||||
ctx := context.WithValue(ss.Context(), ProxyTokenContextKey, token)
|
||||
wrapped := &wrappedServerStream{
|
||||
|
||||
@@ -294,9 +294,9 @@ func (w *Worker) generateProperties(ctx context.Context) properties {
|
||||
localUsers++
|
||||
} else {
|
||||
idpUsers++
|
||||
idpType := extractIdpType(idpID)
|
||||
embeddedIdpTypes[idpType]++
|
||||
}
|
||||
idpType := extractIdpType(idpID)
|
||||
embeddedIdpTypes[idpType]++
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -531,9 +531,6 @@ func createPostRequest(ctx context.Context, endpoint string, payloadStr string)
|
||||
// Connector IDs are formatted as "<type>-<xid>" (e.g., "okta-abc123", "zitadel-xyz").
|
||||
// Returns the type prefix, or "oidc" if no known prefix is found.
|
||||
func extractIdpType(connectorID string) string {
|
||||
if connectorID == "local" {
|
||||
return "local"
|
||||
}
|
||||
idx := strings.LastIndex(connectorID, "-")
|
||||
if idx <= 0 {
|
||||
return "oidc"
|
||||
|
||||
@@ -29,7 +29,6 @@ func (mockDatasource) GetAllConnectedPeers() map[string]struct{} {
|
||||
func (mockDatasource) GetAllAccounts(_ context.Context) []*types.Account {
|
||||
localUserID := dex.EncodeDexUserID("10", "local")
|
||||
idpUserID := dex.EncodeDexUserID("20", "zitadel-d5uv82dra0haedlf6kv0")
|
||||
oidcUserID := dex.EncodeDexUserID("30", "d6jvvp69kmnc73c9pl40")
|
||||
return []*types.Account{
|
||||
{
|
||||
Id: "1",
|
||||
@@ -207,13 +206,6 @@ func (mockDatasource) GetAllAccounts(_ context.Context) []*types.Account {
|
||||
"1": {},
|
||||
},
|
||||
},
|
||||
oidcUserID: {
|
||||
Id: oidcUserID,
|
||||
IsServiceUser: false,
|
||||
PATs: map[string]*types.PersonalAccessToken{
|
||||
"1": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
Networks: []*networkTypes.Network{
|
||||
{
|
||||
@@ -286,14 +278,14 @@ func TestGenerateProperties(t *testing.T) {
|
||||
if properties["rules"] != 4 {
|
||||
t.Errorf("expected 4 rules, got %d", properties["rules"])
|
||||
}
|
||||
if properties["users"] != 3 {
|
||||
t.Errorf("expected 3 users, got %d", properties["users"])
|
||||
if properties["users"] != 2 {
|
||||
t.Errorf("expected 1 users, got %d", properties["users"])
|
||||
}
|
||||
if properties["setup_keys_usage"] != 2 {
|
||||
t.Errorf("expected 1 setup_keys_usage, got %d", properties["setup_keys_usage"])
|
||||
}
|
||||
if properties["pats"] != 5 {
|
||||
t.Errorf("expected 5 personal_access_tokens, got %d", properties["pats"])
|
||||
if properties["pats"] != 4 {
|
||||
t.Errorf("expected 4 personal_access_tokens, got %d", properties["pats"])
|
||||
}
|
||||
if properties["peers_ssh_enabled"] != 2 {
|
||||
t.Errorf("expected 2 peers_ssh_enabled, got %d", properties["peers_ssh_enabled"])
|
||||
@@ -377,20 +369,14 @@ func TestGenerateProperties(t *testing.T) {
|
||||
if properties["local_users_count"] != 1 {
|
||||
t.Errorf("expected 1 local_users_count, got %d", properties["local_users_count"])
|
||||
}
|
||||
if properties["idp_users_count"] != 2 {
|
||||
t.Errorf("expected 2 idp_users_count, got %d", properties["idp_users_count"])
|
||||
}
|
||||
if properties["embedded_idp_users_local"] != 1 {
|
||||
t.Errorf("expected 1 embedded_idp_users_local, got %v", properties["embedded_idp_users_local"])
|
||||
if properties["idp_users_count"] != 1 {
|
||||
t.Errorf("expected 1 idp_users_count, got %d", properties["idp_users_count"])
|
||||
}
|
||||
if properties["embedded_idp_users_zitadel"] != 1 {
|
||||
t.Errorf("expected 1 embedded_idp_users_zitadel, got %v", properties["embedded_idp_users_zitadel"])
|
||||
}
|
||||
if properties["embedded_idp_users_oidc"] != 1 {
|
||||
t.Errorf("expected 1 embedded_idp_users_oidc, got %v", properties["embedded_idp_users_oidc"])
|
||||
}
|
||||
if properties["embedded_idp_count"] != 3 {
|
||||
t.Errorf("expected 3 embedded_idp_count, got %v", properties["embedded_idp_count"])
|
||||
if properties["embedded_idp_count"] != 1 {
|
||||
t.Errorf("expected 1 embedded_idp_count, got %v", properties["embedded_idp_count"])
|
||||
}
|
||||
|
||||
if properties["services"] != 2 {
|
||||
@@ -450,8 +436,7 @@ func TestExtractIdpType(t *testing.T) {
|
||||
{"microsoft-abc123", "microsoft"},
|
||||
{"authentik-abc123", "authentik"},
|
||||
{"keycloak-d5uv82dra0haedlf6kv0", "keycloak"},
|
||||
{"local", "local"},
|
||||
{"d6jvvp69kmnc73c9pl40", "oidc"},
|
||||
{"local", "oidc"},
|
||||
{"", "oidc"},
|
||||
}
|
||||
|
||||
|
||||
+50
-2
@@ -18,6 +18,7 @@ import (
|
||||
"net/http"
|
||||
"net/netip"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -180,8 +181,39 @@ func (s *Server) ListenAndServe(ctx context.Context, addr string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// Configure the reverse proxy using NetBird's HTTP Client Transport for proxying.
|
||||
s.proxy = proxy.NewReverseProxy(s.meter.RoundTripper(s.netbird), s.ForwardedProto, s.TrustedProxies, s.Logger)
|
||||
// TEMPORARY: Create a test transport that uses direct HTTP (bypasses NetBird tunnel)
|
||||
testTransport := &http.Transport{
|
||||
MaxIdleConns: 100,
|
||||
MaxIdleConnsPerHost: 100,
|
||||
IdleConnTimeout: 90 * time.Second,
|
||||
WriteBufferSize: 256 * 1024,
|
||||
ReadBufferSize: 256 * 1024,
|
||||
}
|
||||
|
||||
// TEMPORARY: Start local file server for testing
|
||||
go func() {
|
||||
staticFile := os.Getenv("NB_PROXY_STATIC_FILE_PATH")
|
||||
log.Infof("Reading static file from %s", staticFile)
|
||||
fileServerMux := http.NewServeMux()
|
||||
fileServerMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
s.Logger.Debugf("Serving test file to %s", r.RemoteAddr)
|
||||
http.ServeFile(w, r, staticFile)
|
||||
})
|
||||
testServer := &http.Server{
|
||||
Addr: "0.0.0.0:9999",
|
||||
Handler: fileServerMux,
|
||||
}
|
||||
s.Logger.Info("Started test file server on http://0.0.0.0:9999/")
|
||||
if err := testServer.ListenAndServe(); err != nil {
|
||||
s.Logger.Warnf("Test file server error: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
// Configure the reverse proxy using direct transport for testing (bypasses NetBird)
|
||||
s.proxy = proxy.NewReverseProxy(s.meter.RoundTripper(testTransport), s.ForwardedProto, s.TrustedProxies, s.Logger)
|
||||
|
||||
// TEMPORARY: Add static test mapping pointing to local file server
|
||||
// Using "/" as the path to match all requests to this host
|
||||
|
||||
// Configure the authentication middleware with session validator for OIDC group checks.
|
||||
s.auth = auth.NewMiddleware(s.Logger, s.mgmtClient)
|
||||
@@ -228,6 +260,22 @@ func (s *Server) ListenAndServe(ctx context.Context, addr string) (err error) {
|
||||
httpsErr <- s.https.ServeTLS(ln, "", "")
|
||||
}()
|
||||
|
||||
hostDomain := os.Getenv("NB_PROXY_FILE_HOST")
|
||||
|
||||
testURL, _ := url.Parse("http://127.0.0.1:9999")
|
||||
s.proxy.AddMapping(proxy.Mapping{
|
||||
ID: "test-static-file",
|
||||
AccountID: types.AccountID("test-account"),
|
||||
Host: hostDomain,
|
||||
Paths: map[string]*url.URL{
|
||||
"/": testURL,
|
||||
},
|
||||
})
|
||||
if s.acme != nil {
|
||||
s.acme.AddDomain(domain.Domain(hostDomain), "test-account", "test-static-file")
|
||||
}
|
||||
s.Logger.Info("Added static test mapping: %s/* -> local test file server (bypassing NetBird tunnel)", hostDomain)
|
||||
|
||||
select {
|
||||
case err := <-httpsErr:
|
||||
s.shutdownServices()
|
||||
|
||||
Reference in new issue
Block a user