diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/admin_auth.go | 4 | ||||
-rw-r--r-- | cmd/admin_auth_ldap.go | 22 | ||||
-rw-r--r-- | cmd/admin_auth_ldap_test.go | 24 | ||||
-rw-r--r-- | cmd/admin_auth_oauth.go | 6 | ||||
-rw-r--r-- | cmd/admin_auth_stmp.go | 6 |
5 files changed, 31 insertions, 31 deletions
diff --git a/cmd/admin_auth.go b/cmd/admin_auth.go index ef826a4893..0c931e74eb 100644 --- a/cmd/admin_auth.go +++ b/cmd/admin_auth.go @@ -62,7 +62,7 @@ func runListAuth(c *cli.Context) error { return err } - authSources, err := auth_model.Sources() + authSources, err := auth_model.Sources(ctx) if err != nil { return err } @@ -100,7 +100,7 @@ func runDeleteAuth(c *cli.Context) error { return err } - source, err := auth_model.GetSourceByID(c.Int64("id")) + source, err := auth_model.GetSourceByID(ctx, c.Int64("id")) if err != nil { return err } diff --git a/cmd/admin_auth_ldap.go b/cmd/admin_auth_ldap.go index 111bc7955c..e3c81809f8 100644 --- a/cmd/admin_auth_ldap.go +++ b/cmd/admin_auth_ldap.go @@ -17,9 +17,9 @@ import ( type ( authService struct { initDB func(ctx context.Context) error - createAuthSource func(*auth.Source) error - updateAuthSource func(*auth.Source) error - getAuthSourceByID func(id int64) (*auth.Source, error) + createAuthSource func(context.Context, *auth.Source) error + updateAuthSource func(context.Context, *auth.Source) error + getAuthSourceByID func(ctx context.Context, id int64) (*auth.Source, error) } ) @@ -289,12 +289,12 @@ func findLdapSecurityProtocolByName(name string) (ldap.SecurityProtocol, bool) { // getAuthSource gets the login source by its id defined in the command line flags. // It returns an error if the id is not set, does not match any source or if the source is not of expected type. -func (a *authService) getAuthSource(c *cli.Context, authType auth.Type) (*auth.Source, error) { +func (a *authService) getAuthSource(ctx context.Context, c *cli.Context, authType auth.Type) (*auth.Source, error) { if err := argsSet(c, "id"); err != nil { return nil, err } - authSource, err := a.getAuthSourceByID(c.Int64("id")) + authSource, err := a.getAuthSourceByID(ctx, c.Int64("id")) if err != nil { return nil, err } @@ -332,7 +332,7 @@ func (a *authService) addLdapBindDn(c *cli.Context) error { return err } - return a.createAuthSource(authSource) + return a.createAuthSource(ctx, authSource) } // updateLdapBindDn updates a new LDAP via Bind DN authentication source. @@ -344,7 +344,7 @@ func (a *authService) updateLdapBindDn(c *cli.Context) error { return err } - authSource, err := a.getAuthSource(c, auth.LDAP) + authSource, err := a.getAuthSource(ctx, c, auth.LDAP) if err != nil { return err } @@ -354,7 +354,7 @@ func (a *authService) updateLdapBindDn(c *cli.Context) error { return err } - return a.updateAuthSource(authSource) + return a.updateAuthSource(ctx, authSource) } // addLdapSimpleAuth adds a new LDAP (simple auth) authentication source. @@ -383,7 +383,7 @@ func (a *authService) addLdapSimpleAuth(c *cli.Context) error { return err } - return a.createAuthSource(authSource) + return a.createAuthSource(ctx, authSource) } // updateLdapBindDn updates a new LDAP (simple auth) authentication source. @@ -395,7 +395,7 @@ func (a *authService) updateLdapSimpleAuth(c *cli.Context) error { return err } - authSource, err := a.getAuthSource(c, auth.DLDAP) + authSource, err := a.getAuthSource(ctx, c, auth.DLDAP) if err != nil { return err } @@ -405,5 +405,5 @@ func (a *authService) updateLdapSimpleAuth(c *cli.Context) error { return err } - return a.updateAuthSource(authSource) + return a.updateAuthSource(ctx, authSource) } diff --git a/cmd/admin_auth_ldap_test.go b/cmd/admin_auth_ldap_test.go index 228c9dd3ed..7791f3a9cc 100644 --- a/cmd/admin_auth_ldap_test.go +++ b/cmd/admin_auth_ldap_test.go @@ -210,15 +210,15 @@ func TestAddLdapBindDn(t *testing.T) { initDB: func(context.Context) error { return nil }, - createAuthSource: func(authSource *auth.Source) error { + createAuthSource: func(ctx context.Context, authSource *auth.Source) error { createdAuthSource = authSource return nil }, - updateAuthSource: func(authSource *auth.Source) error { + updateAuthSource: func(ctx context.Context, authSource *auth.Source) error { assert.FailNow(t, "case %d: should not call updateAuthSource", n) return nil }, - getAuthSourceByID: func(id int64) (*auth.Source, error) { + getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) { assert.FailNow(t, "case %d: should not call getAuthSourceByID", n) return nil, nil }, @@ -441,15 +441,15 @@ func TestAddLdapSimpleAuth(t *testing.T) { initDB: func(context.Context) error { return nil }, - createAuthSource: func(authSource *auth.Source) error { + createAuthSource: func(ctx context.Context, authSource *auth.Source) error { createdAuthSource = authSource return nil }, - updateAuthSource: func(authSource *auth.Source) error { + updateAuthSource: func(ctx context.Context, authSource *auth.Source) error { assert.FailNow(t, "case %d: should not call updateAuthSource", n) return nil }, - getAuthSourceByID: func(id int64) (*auth.Source, error) { + getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) { assert.FailNow(t, "case %d: should not call getAuthSourceByID", n) return nil, nil }, @@ -896,15 +896,15 @@ func TestUpdateLdapBindDn(t *testing.T) { initDB: func(context.Context) error { return nil }, - createAuthSource: func(authSource *auth.Source) error { + createAuthSource: func(ctx context.Context, authSource *auth.Source) error { assert.FailNow(t, "case %d: should not call createAuthSource", n) return nil }, - updateAuthSource: func(authSource *auth.Source) error { + updateAuthSource: func(ctx context.Context, authSource *auth.Source) error { updatedAuthSource = authSource return nil }, - getAuthSourceByID: func(id int64) (*auth.Source, error) { + getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) { if c.id != 0 { assert.Equal(t, c.id, id, "case %d: wrong id", n) } @@ -1286,15 +1286,15 @@ func TestUpdateLdapSimpleAuth(t *testing.T) { initDB: func(context.Context) error { return nil }, - createAuthSource: func(authSource *auth.Source) error { + createAuthSource: func(ctx context.Context, authSource *auth.Source) error { assert.FailNow(t, "case %d: should not call createAuthSource", n) return nil }, - updateAuthSource: func(authSource *auth.Source) error { + updateAuthSource: func(ctx context.Context, authSource *auth.Source) error { updatedAuthSource = authSource return nil }, - getAuthSourceByID: func(id int64) (*auth.Source, error) { + getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) { if c.id != 0 { assert.Equal(t, c.id, id, "case %d: wrong id", n) } diff --git a/cmd/admin_auth_oauth.go b/cmd/admin_auth_oauth.go index cc54ac9454..c151c0af27 100644 --- a/cmd/admin_auth_oauth.go +++ b/cmd/admin_auth_oauth.go @@ -183,7 +183,7 @@ func runAddOauth(c *cli.Context) error { } } - return auth_model.CreateSource(&auth_model.Source{ + return auth_model.CreateSource(ctx, &auth_model.Source{ Type: auth_model.OAuth2, Name: c.String("name"), IsActive: true, @@ -203,7 +203,7 @@ func runUpdateOauth(c *cli.Context) error { return err } - source, err := auth_model.GetSourceByID(c.Int64("id")) + source, err := auth_model.GetSourceByID(ctx, c.Int64("id")) if err != nil { return err } @@ -294,5 +294,5 @@ func runUpdateOauth(c *cli.Context) error { oAuth2Config.CustomURLMapping = customURLMapping source.Cfg = oAuth2Config - return auth_model.UpdateSource(source) + return auth_model.UpdateSource(ctx, source) } diff --git a/cmd/admin_auth_stmp.go b/cmd/admin_auth_stmp.go index 8c65de8a1b..58a6e2ac22 100644 --- a/cmd/admin_auth_stmp.go +++ b/cmd/admin_auth_stmp.go @@ -156,7 +156,7 @@ func runAddSMTP(c *cli.Context) error { smtpConfig.Auth = "PLAIN" } - return auth_model.CreateSource(&auth_model.Source{ + return auth_model.CreateSource(ctx, &auth_model.Source{ Type: auth_model.SMTP, Name: c.String("name"), IsActive: active, @@ -176,7 +176,7 @@ func runUpdateSMTP(c *cli.Context) error { return err } - source, err := auth_model.GetSourceByID(c.Int64("id")) + source, err := auth_model.GetSourceByID(ctx, c.Int64("id")) if err != nil { return err } @@ -197,5 +197,5 @@ func runUpdateSMTP(c *cli.Context) error { source.Cfg = smtpConfig - return auth_model.UpdateSource(source) + return auth_model.UpdateSource(ctx, source) } |