Skip to content

Commit

Permalink
[MM-32406] Introduce trace logging level for LDAP messages (mattermos…
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzei authored Nov 3, 2023
1 parent ce3b54d commit e8569c9
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 79 deletions.
2 changes: 1 addition & 1 deletion server/channels/api4/hosted_customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
6 changes: 3 additions & 3 deletions server/channels/api4/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions server/channels/app/app_iface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions server/channels/app/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
12 changes: 6 additions & 6 deletions server/channels/app/opentracing/opentracing_layer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/channels/app/plugin_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion server/channels/app/support_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 2 additions & 1 deletion server/einterfaces/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package einterfaces

import (
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/request"
)

type CloudInterface interface {
Expand Down Expand Up @@ -39,7 +40,7 @@ type CloudInterface interface {
ConfirmSelfHostedSignup(req model.SelfHostedConfirmPaymentMethodRequest, requesterEmail string) (*model.SelfHostedSignupConfirmResponse, error)
ConfirmSelfHostedExpansion(req model.SelfHostedConfirmPaymentMethodRequest, requesterEmail string) (*model.SelfHostedSignupConfirmResponse, error)
ConfirmSelfHostedSignupLicenseApplication() error
GetSelfHostedInvoices() ([]*model.Invoice, error)
GetSelfHostedInvoices(rctx request.CTX) ([]*model.Invoice, error)
GetSelfHostedInvoicePDF(invoiceID string) ([]byte, string, error)

CreateOrUpdateSubscriptionHistoryEvent(userID string, userCount int) (*model.SubscriptionHistory, error)
Expand Down
10 changes: 5 additions & 5 deletions server/einterfaces/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ import (
type LdapInterface interface {
DoLogin(c request.CTX, id string, password string) (*model.User, *model.AppError)
GetUser(c request.CTX, id string) (*model.User, *model.AppError)
GetUserAttributes(id string, attributes []string) (map[string]string, *model.AppError)
GetUserAttributes(rctx request.CTX, id string, attributes []string) (map[string]string, *model.AppError)
CheckPassword(c request.CTX, id string, password string) *model.AppError
CheckPasswordAuthData(c request.CTX, authData string, password string) *model.AppError
CheckProviderAttributes(c request.CTX, LS *model.LdapSettings, ouser *model.User, patch *model.UserPatch) string
SwitchToLdap(c request.CTX, userID, ldapID, ldapPassword string) *model.AppError
StartSynchronizeJob(c request.CTX, waitForJobToFinish bool, includeRemovedMembers bool) (*model.Job, *model.AppError)
RunTest() *model.AppError
RunTest(rctx request.CTX) *model.AppError
GetAllLdapUsers(c request.CTX) ([]*model.User, *model.AppError)
MigrateIDAttribute(c request.CTX, toAttribute string) error
GetGroup(groupUID string) (*model.Group, *model.AppError)
GetAllGroupsPage(page int, perPage int, opts model.LdapGroupSearchOpts) ([]*model.Group, int, *model.AppError)
GetGroup(rctx request.CTX, groupUID string) (*model.Group, *model.AppError)
GetAllGroupsPage(rctx request.CTX, page int, perPage int, opts model.LdapGroupSearchOpts) ([]*model.Group, int, *model.AppError)
FirstLoginSync(c request.CTX, user *model.User, userAuthService, userAuthData, email string) *model.AppError
UpdateProfilePictureIfNecessary(request.CTX, model.User, model.Session)
GetADLdapIdFromSAMLId(c request.CTX, authData string) string
GetSAMLIdFromADLdapId(c request.CTX, authData string) string
GetVendorNameAndVendorVersion() (string, string)
GetVendorNameAndVendorVersion(rctx request.CTX) (string, string)
}
19 changes: 10 additions & 9 deletions server/einterfaces/mocks/CloudInterface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e8569c9

Please sign in to comment.