diff --git a/internal/outpost/ldap/bind/request.go b/internal/outpost/ldap/bind/request.go index e91c2e70f..59827105d 100644 --- a/internal/outpost/ldap/bind/request.go +++ b/internal/outpost/ldap/bind/request.go @@ -26,7 +26,11 @@ func NewRequest(bindDN string, bindPW string, conn net.Conn) (*Request, *sentry. span.Description = bindDN rid := uuid.New().String() span.SetTag("request_uid", rid) - sentry.GetHubFromContext(span.Context()).Scope().SetUser(sentry.User{ + hub := sentry.GetHubFromContext(span.Context()) + if hub == nil { + hub = sentry.CurrentHub() + } + hub.Scope().SetUser(sentry.User{ Username: bindDN, ID: bindDN, IPAddress: utils.GetIP(conn.RemoteAddr()), diff --git a/internal/outpost/ldap/search/request.go b/internal/outpost/ldap/search/request.go index 31c9fde42..5f7e9af90 100644 --- a/internal/outpost/ldap/search/request.go +++ b/internal/outpost/ldap/search/request.go @@ -30,7 +30,11 @@ func NewRequest(bindDN string, searchReq ldap.SearchRequest, conn net.Conn) (*Re span := sentry.StartSpan(context.TODO(), "authentik.providers.ldap.search", sentry.TransactionName("authentik.providers.ldap.search")) span.Description = fmt.Sprintf("%s (%s)", searchReq.BaseDN, ldap.ScopeMap[searchReq.Scope]) span.SetTag("request_uid", rid) - sentry.GetHubFromContext(span.Context()).Scope().SetUser(sentry.User{ + hub := sentry.GetHubFromContext(span.Context()) + if hub == nil { + hub = sentry.CurrentHub() + } + hub.Scope().SetUser(sentry.User{ Username: bindDN, ID: bindDN, IPAddress: utils.GetIP(conn.RemoteAddr()), diff --git a/internal/outpost/proxyv2/application/application.go b/internal/outpost/proxyv2/application/application.go index c048bbd55..f6d48fcc8 100644 --- a/internal/outpost/proxyv2/application/application.go +++ b/internal/outpost/proxyv2/application/application.go @@ -111,7 +111,11 @@ func NewApplication(p api.ProxyOutpostConfig, c *http.Client, cs *ak.CryptoStore user := "" if c != nil { user = c.PreferredUsername - sentry.GetHubFromContext(r.Context()).Scope().SetUser(sentry.User{ + hub := sentry.GetHubFromContext(r.Context()) + if hub == nil { + hub = sentry.CurrentHub() + } + hub.Scope().SetUser(sentry.User{ Username: user, ID: c.Sub, IPAddress: r.RemoteAddr,