outposts: check if hub from context is set and fallback
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
f8aab40e3e
commit
7d6e88061f
|
@ -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()),
|
||||
|
|
|
@ -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()),
|
||||
|
|
|
@ -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,
|
||||
|
|
Reference in New Issue