[MM-32406] Introduce trace logging level for LDAP messages (#25118)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ce3b54d23e
Коммит
e8569c91af
@@ -251,7 +251,7 @@ func selfHostedInvoices(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
invoices, err := c.App.Cloud().GetSelfHostedInvoices()
|
||||
invoices, err := c.App.Cloud().GetSelfHostedInvoices(c.AppContext)
|
||||
|
||||
if err != nil {
|
||||
if err.Error() == "404" {
|
||||
|
||||
@@ -83,7 +83,7 @@ func testLdap(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := c.App.TestLdap(); err != nil {
|
||||
if err := c.App.TestLdap(c.AppContext); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
@@ -112,7 +112,7 @@ func getLdapGroups(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
opts.IsConfigured = c.Params.IsConfigured
|
||||
}
|
||||
|
||||
groups, total, appErr := c.App.GetAllLdapGroupsPage(c.Params.Page, c.Params.PerPage, opts)
|
||||
groups, total, appErr := c.App.GetAllLdapGroupsPage(c.AppContext, c.Params.Page, c.Params.PerPage, opts)
|
||||
if appErr != nil {
|
||||
c.Err = appErr
|
||||
return
|
||||
@@ -163,7 +163,7 @@ func linkLdapGroup(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
ldapGroup, appErr := c.App.GetLdapGroup(c.Params.RemoteId)
|
||||
ldapGroup, appErr := c.App.GetLdapGroup(c.AppContext, c.Params.RemoteId)
|
||||
if appErr != nil {
|
||||
c.Err = appErr
|
||||
return
|
||||
|
||||
@@ -165,7 +165,7 @@ type AppIface interface {
|
||||
FilterNonGroupTeamMembers(userIDs []string, team *model.Team) ([]string, error)
|
||||
// GetAllLdapGroupsPage retrieves all LDAP groups under the configured base DN using the default or configured group
|
||||
// filter.
|
||||
GetAllLdapGroupsPage(page int, perPage int, opts model.LdapGroupSearchOpts) ([]*model.Group, int, *model.AppError)
|
||||
GetAllLdapGroupsPage(rctx request.CTX, page int, perPage int, opts model.LdapGroupSearchOpts) ([]*model.Group, int, *model.AppError)
|
||||
// GetBot returns the given bot.
|
||||
GetBot(botUserId string, includeDeleted bool) (*model.Bot, *model.AppError)
|
||||
// GetBots returns the requested page of bots.
|
||||
@@ -199,7 +199,7 @@ type AppIface interface {
|
||||
// GetLastAccessiblePostTime returns CreateAt time(from cache) of the last accessible post as per the cloud limit
|
||||
GetLastAccessiblePostTime() (int64, *model.AppError)
|
||||
// GetLdapGroup retrieves a single LDAP group by the given LDAP group id.
|
||||
GetLdapGroup(ldapGroupID string) (*model.Group, *model.AppError)
|
||||
GetLdapGroup(rctx request.CTX, ldapGroupID string) (*model.Group, *model.AppError)
|
||||
// GetMarketplacePlugins returns a list of plugins from the marketplace-server,
|
||||
// and plugins that are installed locally.
|
||||
GetMarketplacePlugins(filter *model.MarketplacePluginFilter) ([]*model.MarketplacePlugin, *model.AppError)
|
||||
@@ -1100,7 +1100,7 @@ type AppIface interface {
|
||||
TestEmail(userID string, cfg *model.Config) *model.AppError
|
||||
TestFileStoreConnection() *model.AppError
|
||||
TestFileStoreConnectionWithConfig(cfg *model.FileSettings) *model.AppError
|
||||
TestLdap() *model.AppError
|
||||
TestLdap(rctx request.CTX) *model.AppError
|
||||
TestSiteURL(siteURL string) *model.AppError
|
||||
Timezones() *timezones.Timezones
|
||||
ToggleMuteChannel(c request.CTX, channelID, userID string) (*model.ChannelMember, *model.AppError)
|
||||
|
||||
@@ -35,10 +35,10 @@ func (a *App) SyncLdap(c request.CTX, includeRemovedMembers bool) {
|
||||
})
|
||||
}
|
||||
|
||||
func (a *App) TestLdap() *model.AppError {
|
||||
func (a *App) TestLdap(rctx request.CTX) *model.AppError {
|
||||
license := a.Srv().License()
|
||||
if ldapI := a.Ldap(); ldapI != nil && license != nil && *license.Features.LDAP && (*a.Config().LdapSettings.Enable || *a.Config().LdapSettings.EnableSync) {
|
||||
if err := ldapI.RunTest(); err != nil {
|
||||
if err := ldapI.RunTest(rctx); err != nil {
|
||||
err.StatusCode = 500
|
||||
return err
|
||||
}
|
||||
@@ -51,12 +51,12 @@ func (a *App) TestLdap() *model.AppError {
|
||||
}
|
||||
|
||||
// GetLdapGroup retrieves a single LDAP group by the given LDAP group id.
|
||||
func (a *App) GetLdapGroup(ldapGroupID string) (*model.Group, *model.AppError) {
|
||||
func (a *App) GetLdapGroup(rctx request.CTX, ldapGroupID string) (*model.Group, *model.AppError) {
|
||||
var group *model.Group
|
||||
|
||||
if a.Ldap() != nil {
|
||||
var err *model.AppError
|
||||
group, err = a.Ldap().GetGroup(ldapGroupID)
|
||||
group, err = a.Ldap().GetGroup(rctx, ldapGroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -70,13 +70,13 @@ func (a *App) GetLdapGroup(ldapGroupID string) (*model.Group, *model.AppError) {
|
||||
|
||||
// GetAllLdapGroupsPage retrieves all LDAP groups under the configured base DN using the default or configured group
|
||||
// filter.
|
||||
func (a *App) GetAllLdapGroupsPage(page int, perPage int, opts model.LdapGroupSearchOpts) ([]*model.Group, int, *model.AppError) {
|
||||
func (a *App) GetAllLdapGroupsPage(rctx request.CTX, page int, perPage int, opts model.LdapGroupSearchOpts) ([]*model.Group, int, *model.AppError) {
|
||||
var groups []*model.Group
|
||||
var total int
|
||||
|
||||
if a.Ldap() != nil {
|
||||
var err *model.AppError
|
||||
groups, total, err = a.Ldap().GetAllGroupsPage(page, perPage, opts)
|
||||
groups, total, err = a.Ldap().GetAllGroupsPage(rctx, page, perPage, opts)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
@@ -4771,7 +4771,7 @@ func (a *OpenTracingAppLayer) GetAllChannelsCount(c request.CTX, opts model.Chan
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetAllLdapGroupsPage(page int, perPage int, opts model.LdapGroupSearchOpts) ([]*model.Group, int, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetAllLdapGroupsPage(rctx request.CTX, page int, perPage int, opts model.LdapGroupSearchOpts) ([]*model.Group, int, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetAllLdapGroupsPage")
|
||||
|
||||
@@ -4783,7 +4783,7 @@ func (a *OpenTracingAppLayer) GetAllLdapGroupsPage(page int, perPage int, opts m
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1, resultVar2 := a.app.GetAllLdapGroupsPage(page, perPage, opts)
|
||||
resultVar0, resultVar1, resultVar2 := a.app.GetAllLdapGroupsPage(rctx, page, perPage, opts)
|
||||
|
||||
if resultVar2 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar2))
|
||||
@@ -7232,7 +7232,7 @@ func (a *OpenTracingAppLayer) GetLatestVersion(latestVersionUrl string) (*model.
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetLdapGroup(ldapGroupID string) (*model.Group, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetLdapGroup(rctx request.CTX, ldapGroupID string) (*model.Group, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetLdapGroup")
|
||||
|
||||
@@ -7244,7 +7244,7 @@ func (a *OpenTracingAppLayer) GetLdapGroup(ldapGroupID string) (*model.Group, *m
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetLdapGroup(ldapGroupID)
|
||||
resultVar0, resultVar1 := a.app.GetLdapGroup(rctx, ldapGroupID)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
@@ -16919,7 +16919,7 @@ func (a *OpenTracingAppLayer) TestFileStoreConnectionWithConfig(cfg *model.FileS
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) TestLdap() *model.AppError {
|
||||
func (a *OpenTracingAppLayer) TestLdap(rctx request.CTX) *model.AppError {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.TestLdap")
|
||||
|
||||
@@ -16931,7 +16931,7 @@ func (a *OpenTracingAppLayer) TestLdap() *model.AppError {
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0 := a.app.TestLdap()
|
||||
resultVar0 := a.app.TestLdap(rctx)
|
||||
|
||||
if resultVar0 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar0))
|
||||
|
||||
@@ -409,7 +409,7 @@ func (api *PluginAPI) GetLDAPUserAttributes(userID string, attributes []string)
|
||||
// Only bother running the query if the user's auth service is LDAP or it's SAML and sync is enabled.
|
||||
if user.AuthService == model.UserAuthServiceLdap ||
|
||||
(user.AuthService == model.UserAuthServiceSaml && *api.app.Config().SamlSettings.EnableSyncWithLdap) {
|
||||
return api.app.Ldap().GetUserAttributes(*user.AuthData, attributes)
|
||||
return api.app.Ldap().GetUserAttributes(api.ctx, *user.AuthData, attributes)
|
||||
}
|
||||
|
||||
return map[string]string{}, nil
|
||||
|
||||
@@ -96,7 +96,7 @@ func (a *App) generateSupportPacketYaml(c request.CTX) (*model.FileData, error)
|
||||
|
||||
var vendorName, vendorVersion string
|
||||
if ldapInterface := a.ch.Ldap; a.ch.Ldap != nil {
|
||||
vendorName, vendorVersion = ldapInterface.GetVendorNameAndVendorVersion()
|
||||
vendorName, vendorVersion = ldapInterface.GetVendorNameAndVendorVersion(c)
|
||||
}
|
||||
|
||||
/* Elastic Search */
|
||||
|
||||
Ссылка в новой задаче
Block a user