[management] Match account ids from the request and service config (#8386)

* match account ids from the request and service config

Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>

* match account ids from the request and service config

Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>

* add tests

Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>

---------

Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
This commit is contained in:
dmitri-netbird
2026-10-28 17:38:42 +01:00
committed by GitHub
parent 42418448d8
commit 4ff3267542
6 changed files with 114 additions and 5 deletions
+6 -1
View File
@@ -135,12 +135,17 @@ func (mw *Middleware) Protect(next http.Handler) http.Handler {
config, exists := mw.getDomainConfig(host)
mw.logger.Debugf("checking authentication for host: %s, exists: %t", host, exists)
if !exists {
next.ServeHTTP(w, r)
return
}
// enforce account id for requests routed through the embedded client
capturedData := proxy.CapturedDataFromContext(r.Context())
if capturedData != nil && capturedData.GetAccountID() != "" && capturedData.GetAccountID() != config.AccountID {
denyForbidden(w, config)
return
}
// Set account and service IDs in captured data for access logging.
setCapturedIDs(r, config)