diff --git a/cmd/authelia-scripts/cmd_suites.go b/cmd/authelia-scripts/cmd_suites.go index e73fefd04..e5bc17214 100644 --- a/cmd/authelia-scripts/cmd_suites.go +++ b/cmd/authelia-scripts/cmd_suites.go @@ -172,9 +172,9 @@ func setupSuite(suiteName string) error { if errSetup := runSuiteSetupTeardown("setup", suiteName); errSetup != nil || interrupted { if errSetup == utils.ErrTimeoutReached { - runOnSetupTimeout(suiteName) + runOnSetupTimeout(suiteName) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } - teardownSuite(suiteName) + teardownSuite(suiteName) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. return errSetup } diff --git a/internal/authentication/ldap_user_provider_test.go b/internal/authentication/ldap_user_provider_test.go index fb5841d99..3c5032ec3 100644 --- a/internal/authentication/ldap_user_provider_test.go +++ b/internal/authentication/ldap_user_provider_test.go @@ -149,7 +149,7 @@ func TestShouldEscapeUserInput(t *testing.T) { Search(NewSearchRequestMatcher("(|(uid=john\\=abc)(mail=john\\=abc))")). Return(&ldap.SearchResult{}, nil) - ldapClient.getUserProfile(mockConn, "john=abc") + ldapClient.getUserProfile(mockConn, "john=abc") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } func TestShouldCombineUsernameFilterAndUsersFilter(t *testing.T) { @@ -174,7 +174,7 @@ func TestShouldCombineUsernameFilterAndUsersFilter(t *testing.T) { Search(NewSearchRequestMatcher("(&(uid=john)(&(objectCategory=person)(objectClass=user)))")). Return(&ldap.SearchResult{}, nil) - ldapClient.getUserProfile(mockConn, "john") + ldapClient.getUserProfile(mockConn, "john") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } func createSearchResultWithAttributes(attributes ...*ldap.EntryAttribute) *ldap.SearchResult { diff --git a/internal/commands/migration_local.go b/internal/commands/migration_local.go index acf6ada14..a6e31ea42 100644 --- a/internal/commands/migration_local.go +++ b/internal/commands/migration_local.go @@ -26,10 +26,10 @@ var MigrateLocalCmd = &cobra.Command{ func init() { MigrateLocalCmd.PersistentFlags().StringVarP(&localDatabasePath, "db-path", "p", "", "The path to the v3 local database") - MigrateLocalCmd.MarkPersistentFlagRequired("db-path") + MigrateLocalCmd.MarkPersistentFlagRequired("db-path") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. MigrateLocalCmd.PersistentFlags().StringVarP(&configurationPath, "config", "c", "", "The configuration file of Authelia v4") - MigrateLocalCmd.MarkPersistentFlagRequired("config") + MigrateLocalCmd.MarkPersistentFlagRequired("config") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } // migrateLocal data from v3 to v4. @@ -58,7 +58,7 @@ func migrateLocalTOTPSecret(dbProvider storage.Provider) { data := scanner.Text() entry := TOTPSecretsV3{} - json.Unmarshal([]byte(data), &entry) + json.Unmarshal([]byte(data), &entry) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. err := dbProvider.SaveTOTPSecret(entry.UserID, entry.Secret.Base32) if err != nil { @@ -80,7 +80,7 @@ func migrateLocalU2FSecret(dbProvider storage.Provider) { data := scanner.Text() entry := U2FDeviceHandleV3{} - json.Unmarshal([]byte(data), &entry) + json.Unmarshal([]byte(data), &entry) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. kH, err := decodeWebsafeBase64(entry.Registration.KeyHandle) @@ -115,7 +115,7 @@ func migrateLocalPreferences(dbProvider storage.Provider) { data := scanner.Text() entry := PreferencesV3{} - json.Unmarshal([]byte(data), &entry) + json.Unmarshal([]byte(data), &entry) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. err := dbProvider.SavePreferred2FAMethod(entry.UserID, entry.Method) if err != nil { @@ -137,7 +137,7 @@ func migrateLocalAuthenticationTraces(dbProvider storage.Provider) { data := scanner.Text() entry := AuthenticationTraceV3{} - json.Unmarshal([]byte(data), &entry) + json.Unmarshal([]byte(data), &entry) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. attempt := models.AuthenticationAttempt{ Username: entry.UserID, diff --git a/internal/commands/migration_mongo.go b/internal/commands/migration_mongo.go index f0384bdfb..dd6dd865b 100644 --- a/internal/commands/migration_mongo.go +++ b/internal/commands/migration_mongo.go @@ -26,13 +26,13 @@ var MigrateMongoCmd = &cobra.Command{ func init() { MigrateMongoCmd.PersistentFlags().StringVar(&mongoURL, "url", "", "The address to the mongo server") - MigrateMongoCmd.MarkPersistentFlagRequired("url") + MigrateMongoCmd.MarkPersistentFlagRequired("url") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. MigrateMongoCmd.PersistentFlags().StringVar(&mongoDatabase, "database", "", "The mongo database") - MigrateMongoCmd.MarkPersistentFlagRequired("database") + MigrateMongoCmd.MarkPersistentFlagRequired("database") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. MigrateMongoCmd.PersistentFlags().StringVarP(&configurationPath, "config", "c", "", "The configuration file of Authelia v4") - MigrateMongoCmd.MarkPersistentFlagRequired("config") + MigrateMongoCmd.MarkPersistentFlagRequired("config") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } func migrateMongo(cmd *cobra.Command, args []string) { diff --git a/internal/configuration/reader.go b/internal/configuration/reader.go index 94b5493cd..4a86522f1 100644 --- a/internal/configuration/reader.go +++ b/internal/configuration/reader.go @@ -17,14 +17,14 @@ func Read(configPath string) (*schema.Configuration, []error) { // we need to bind all env variables as long as https://github.com/spf13/viper/issues/761 // is not resolved. - viper.BindEnv("jwt_secret") - viper.BindEnv("duo_api.secret_key") - viper.BindEnv("session.secret") - viper.BindEnv("authentication_backend.ldap.password") - viper.BindEnv("notifier.smtp.password") - viper.BindEnv("session.redis.password") - viper.BindEnv("storage.mysql.password") - viper.BindEnv("storage.postgres.password") + viper.BindEnv("jwt_secret") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. + viper.BindEnv("duo_api.secret_key") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. + viper.BindEnv("session.secret") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. + viper.BindEnv("authentication_backend.ldap.password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. + viper.BindEnv("notifier.smtp.password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. + viper.BindEnv("session.redis.password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. + viper.BindEnv("storage.mysql.password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. + viper.BindEnv("storage.postgres.password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. viper.SetConfigFile(configPath) @@ -35,7 +35,7 @@ func Read(configPath string) (*schema.Configuration, []error) { } var configuration schema.Configuration - viper.Unmarshal(&configuration) + viper.Unmarshal(&configuration) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. val := schema.NewStructValidator() validator.Validate(&configuration, val) diff --git a/internal/configuration/schema/validator.go b/internal/configuration/schema/validator.go index 441630488..ddbc82801 100644 --- a/internal/configuration/schema/validator.go +++ b/internal/configuration/schema/validator.go @@ -39,7 +39,7 @@ func (v *Validator) validateOne(item QueueItem, q *queue.Queue) error { //nolint } elem := item.value.Elem() - q.Put(QueueItem{ + q.Put(QueueItem{ //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. value: elem, path: item.path, }) @@ -58,7 +58,7 @@ func (v *Validator) validateOne(item QueueItem, q *queue.Queue) error { //nolint field := item.value.Type().Field(i) value := item.value.Field(i) - q.Put(QueueItem{ + q.Put(QueueItem{ //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. value: value, path: item.path + "." + field.Name, }) @@ -70,7 +70,7 @@ func (v *Validator) validateOne(item QueueItem, q *queue.Queue) error { //nolint // Validate validate a struct func (v *Validator) Validate(s interface{}) error { q := queue.New(40) - q.Put(QueueItem{value: reflect.ValueOf(s), path: "root"}) + q.Put(QueueItem{value: reflect.ValueOf(s), path: "root"}) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. for !q.Empty() { val, err := q.Get(1) @@ -81,7 +81,7 @@ func (v *Validator) Validate(s interface{}) error { if !ok { return fmt.Errorf("Cannot convert item into QueueItem") } - v.validateOne(item, q) + v.validateOne(item, q) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } return nil } diff --git a/internal/handlers/handler_configuration.go b/internal/handlers/handler_configuration.go index 5b451ea38..c03653516 100644 --- a/internal/handlers/handler_configuration.go +++ b/internal/handlers/handler_configuration.go @@ -16,5 +16,5 @@ func ConfigurationGet(ctx *middlewares.AutheliaCtx) { RememberMe: ctx.Providers.SessionProvider.RememberMe != 0, ResetPassword: !ctx.Configuration.AuthenticationBackend.DisableResetPassword, } - ctx.SetJSONBody(body) + ctx.SetJSONBody(body) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } diff --git a/internal/handlers/handler_extended_configuration.go b/internal/handlers/handler_extended_configuration.go index 052798670..7f03598a0 100644 --- a/internal/handlers/handler_extended_configuration.go +++ b/internal/handlers/handler_extended_configuration.go @@ -26,5 +26,5 @@ func ExtendedConfigurationGet(ctx *middlewares.AutheliaCtx) { ctx.Logger.Tracef("Second factor enabled: %v", body.SecondFactorEnabled) ctx.Logger.Tracef("Available methods are %s", body.AvailableMethods) - ctx.SetJSONBody(body) + ctx.SetJSONBody(body) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } diff --git a/internal/handlers/handler_firstfactor.go b/internal/handlers/handler_firstfactor.go index c7a1a57fe..54ade2661 100644 --- a/internal/handlers/handler_firstfactor.go +++ b/internal/handlers/handler_firstfactor.go @@ -35,7 +35,7 @@ func FirstFactorPost(ctx *middlewares.AutheliaCtx) { if err != nil { ctx.Logger.Debugf("Mark authentication attempt made by user %s", bodyJSON.Username) - ctx.Providers.Regulator.Mark(bodyJSON.Username, false) + ctx.Providers.Regulator.Mark(bodyJSON.Username, false) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. ctx.Error(fmt.Errorf("Error while checking password for user %s: %s", bodyJSON.Username, err.Error()), authenticationFailedMessage) return @@ -43,7 +43,7 @@ func FirstFactorPost(ctx *middlewares.AutheliaCtx) { if !userPasswordOk { ctx.Logger.Debugf("Mark authentication attempt made by user %s", bodyJSON.Username) - ctx.Providers.Regulator.Mark(bodyJSON.Username, false) + ctx.Providers.Regulator.Mark(bodyJSON.Username, false) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. ctx.ReplyError(fmt.Errorf("Credentials are wrong for user %s", bodyJSON.Username), authenticationFailedMessage) return diff --git a/internal/handlers/handler_logout_test.go b/internal/handlers/handler_logout_test.go index 7894b238e..cbd042194 100644 --- a/internal/handlers/handler_logout_test.go +++ b/internal/handlers/handler_logout_test.go @@ -21,7 +21,7 @@ func (s *LogoutSuite) SetupTest() { s.mock = mocks.NewMockAutheliaCtx(s.T()) userSession := s.mock.Ctx.GetSession() userSession.Username = "john" - s.mock.Ctx.SaveSession(userSession) + s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } func (s *LogoutSuite) TearDownTest() { diff --git a/internal/handlers/handler_register_totp.go b/internal/handlers/handler_register_totp.go index 8fa3288a0..8c5bfd7f6 100644 --- a/internal/handlers/handler_register_totp.go +++ b/internal/handlers/handler_register_totp.go @@ -60,7 +60,7 @@ func secondFactorTOTPIdentityFinish(ctx *middlewares.AutheliaCtx, username strin Base32Secret: key.Secret(), } - ctx.SetJSONBody(response) + ctx.SetJSONBody(response) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } // SecondFactorTOTPIdentityFinish the handler for finishing the identity validation diff --git a/internal/handlers/handler_register_u2f_step1.go b/internal/handlers/handler_register_u2f_step1.go index 9ce5d8eb6..06791e66f 100644 --- a/internal/handlers/handler_register_u2f_step1.go +++ b/internal/handlers/handler_register_u2f_step1.go @@ -55,7 +55,7 @@ func secondFactorU2FIdentityFinish(ctx *middlewares.AutheliaCtx, username string return } - ctx.SetJSONBody(u2f.NewWebRegisterRequest(challenge, []u2f.Registration{})) + ctx.SetJSONBody(u2f.NewWebRegisterRequest(challenge, []u2f.Registration{})) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } // SecondFactorU2FIdentityFinish the handler for finishing the identity validation diff --git a/internal/handlers/handler_register_u2f_step1_test.go b/internal/handlers/handler_register_u2f_step1_test.go index b8cf61fce..a1a15c2e9 100644 --- a/internal/handlers/handler_register_u2f_step1_test.go +++ b/internal/handlers/handler_register_u2f_step1_test.go @@ -25,7 +25,7 @@ func (s *HandlerRegisterU2FStep1Suite) SetupTest() { userSession := s.mock.Ctx.GetSession() userSession.Username = "john" - s.mock.Ctx.SaveSession(userSession) + s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } func (s *HandlerRegisterU2FStep1Suite) TearDownTest() { diff --git a/internal/handlers/handler_register_u2f_step2.go b/internal/handlers/handler_register_u2f_step2.go index 0c7e63ca1..3964c1a03 100644 --- a/internal/handlers/handler_register_u2f_step2.go +++ b/internal/handlers/handler_register_u2f_step2.go @@ -28,7 +28,7 @@ func SecondFactorU2FRegister(ctx *middlewares.AutheliaCtx) { // Ensure the challenge is cleared if anything goes wrong. defer func() { userSession.U2FChallenge = nil - ctx.SaveSession(userSession) + ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. }() registration, err := u2f.Register(responseBody, *userSession.U2FChallenge, u2fConfig) diff --git a/internal/handlers/handler_reset_password_step1.go b/internal/handlers/handler_reset_password_step1.go index 697dff864..e1fa9d448 100644 --- a/internal/handlers/handler_reset_password_step1.go +++ b/internal/handlers/handler_reset_password_step1.go @@ -46,7 +46,7 @@ func resetPasswordIdentityFinish(ctx *middlewares.AutheliaCtx, username string) userSession := ctx.GetSession() // TODO(c.michaud): use JWT tokens to expire the request in only few seconds for better security. userSession.PasswordResetUsername = &username - ctx.SaveSession(userSession) + ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. ctx.ReplyOK() } diff --git a/internal/handlers/handler_sign_duo_test.go b/internal/handlers/handler_sign_duo_test.go index 7b10d5483..a1cd7b4a1 100644 --- a/internal/handlers/handler_sign_duo_test.go +++ b/internal/handlers/handler_sign_duo_test.go @@ -25,7 +25,7 @@ func (s *SecondFactorDuoPostSuite) SetupTest() { s.mock = mocks.NewMockAutheliaCtx(s.T()) userSession := s.mock.Ctx.GetSession() userSession.Username = "john" - s.mock.Ctx.SaveSession(userSession) + s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } func (s *SecondFactorDuoPostSuite) TearDownTest() { diff --git a/internal/handlers/handler_sign_totp_test.go b/internal/handlers/handler_sign_totp_test.go index e5375c823..c496ba4b2 100644 --- a/internal/handlers/handler_sign_totp_test.go +++ b/internal/handlers/handler_sign_totp_test.go @@ -25,7 +25,7 @@ func (s *HandlerSignTOTPSuite) SetupTest() { userSession.Username = "john" userSession.U2FChallenge = &u2f.Challenge{} userSession.U2FRegistration = &session.U2FRegistration{} - s.mock.Ctx.SaveSession(userSession) + s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } func (s *HandlerSignTOTPSuite) TearDownTest() { diff --git a/internal/handlers/handler_sign_u2f_step2_test.go b/internal/handlers/handler_sign_u2f_step2_test.go index 2961d94b7..4d42fa19f 100644 --- a/internal/handlers/handler_sign_u2f_step2_test.go +++ b/internal/handlers/handler_sign_u2f_step2_test.go @@ -25,7 +25,7 @@ func (s *HandlerSignU2FStep2Suite) SetupTest() { userSession.Username = "john" userSession.U2FChallenge = &u2f.Challenge{} userSession.U2FRegistration = &session.U2FRegistration{} - s.mock.Ctx.SaveSession(userSession) + s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } func (s *HandlerSignU2FStep2Suite) TearDownTest() { diff --git a/internal/handlers/handler_state.go b/internal/handlers/handler_state.go index 87d86f76e..54103fafa 100644 --- a/internal/handlers/handler_state.go +++ b/internal/handlers/handler_state.go @@ -12,5 +12,5 @@ func StateGet(ctx *middlewares.AutheliaCtx) { AuthenticationLevel: userSession.AuthenticationLevel, DefaultRedirectionURL: ctx.Configuration.DefaultRedirectionURL, } - ctx.SetJSONBody(stateResponse) + ctx.SetJSONBody(stateResponse) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } diff --git a/internal/handlers/handler_state_test.go b/internal/handlers/handler_state_test.go index 72198357c..5552eeaae 100644 --- a/internal/handlers/handler_state_test.go +++ b/internal/handlers/handler_state_test.go @@ -29,7 +29,7 @@ func (s *StateGetSuite) TearDownTest() { func (s *StateGetSuite) TestShouldReturnUsernameFromSession() { userSession := s.mock.Ctx.GetSession() userSession.Username = "username" - s.mock.Ctx.SaveSession(userSession) + s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. StateGet(s.mock.Ctx) @@ -48,7 +48,7 @@ func (s *StateGetSuite) TestShouldReturnUsernameFromSession() { } actualBody := Response{} - json.Unmarshal(s.mock.Ctx.Response.Body(), &actualBody) + json.Unmarshal(s.mock.Ctx.Response.Body(), &actualBody) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. assert.Equal(s.T(), 200, s.mock.Ctx.Response.StatusCode()) assert.Equal(s.T(), []byte("application/json"), s.mock.Ctx.Response.Header.ContentType()) assert.Equal(s.T(), expectedBody, actualBody) @@ -57,7 +57,7 @@ func (s *StateGetSuite) TestShouldReturnUsernameFromSession() { func (s *StateGetSuite) TestShouldReturnAuthenticationLevelFromSession() { userSession := s.mock.Ctx.GetSession() userSession.AuthenticationLevel = authentication.OneFactor - s.mock.Ctx.SaveSession(userSession) + s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. StateGet(s.mock.Ctx) @@ -76,7 +76,7 @@ func (s *StateGetSuite) TestShouldReturnAuthenticationLevelFromSession() { } actualBody := Response{} - json.Unmarshal(s.mock.Ctx.Response.Body(), &actualBody) + json.Unmarshal(s.mock.Ctx.Response.Body(), &actualBody) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. assert.Equal(s.T(), 200, s.mock.Ctx.Response.StatusCode()) assert.Equal(s.T(), []byte("application/json"), s.mock.Ctx.Response.Header.ContentType()) assert.Equal(s.T(), expectedBody, actualBody) diff --git a/internal/handlers/handler_user_info.go b/internal/handlers/handler_user_info.go index 05a277901..7f6dc4d3b 100644 --- a/internal/handlers/handler_user_info.go +++ b/internal/handlers/handler_user_info.go @@ -76,7 +76,7 @@ func UserInfoGet(ctx *middlewares.AutheliaCtx) { ctx.Error(fmt.Errorf("Unable to load user information"), operationFailedMessage) return } - ctx.SetJSONBody(preferences) + ctx.SetJSONBody(preferences) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } // MethodBody the selected 2FA method. diff --git a/internal/handlers/handler_user_info_test.go b/internal/handlers/handler_user_info_test.go index 1177c45e3..ced0f7fbd 100644 --- a/internal/handlers/handler_user_info_test.go +++ b/internal/handlers/handler_user_info_test.go @@ -24,7 +24,7 @@ func (s *FetchSuite) SetupTest() { userSession := s.mock.Ctx.GetSession() userSession.Username = "john" userSession.AuthenticationLevel = 1 - s.mock.Ctx.SaveSession(userSession) + s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } func (s *FetchSuite) TearDownTest() { @@ -92,7 +92,7 @@ func TestMethodSetToU2F(t *testing.T) { userSession := mock.Ctx.GetSession() userSession.Username = "john" userSession.AuthenticationLevel = 1 - mock.Ctx.SaveSession(userSession) + mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. setPreferencesExpectations(expectedPreferences, mock.StorageProviderMock) UserInfoGet(mock.Ctx) @@ -170,7 +170,7 @@ func (s *SaveSuite) SetupTest() { userSession := s.mock.Ctx.GetSession() userSession.Username = "john" userSession.AuthenticationLevel = 1 - s.mock.Ctx.SaveSession(userSession) + s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } func (s *SaveSuite) TearDownTest() { diff --git a/internal/handlers/handler_verify_test.go b/internal/handlers/handler_verify_test.go index 3c86258cf..1e391eb3f 100644 --- a/internal/handlers/handler_verify_test.go +++ b/internal/handlers/handler_verify_test.go @@ -447,7 +447,7 @@ func TestShouldVerifyAuthorizationsUsingSessionCookie(t *testing.T) { userSession := mock.Ctx.GetSession() userSession.Username = testCase.Username userSession.AuthenticationLevel = testCase.AuthenticationLevel - mock.Ctx.SaveSession(userSession) + mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. mock.Ctx.Request.Header.Set("X-Original-URL", testCase.URL) @@ -481,7 +481,7 @@ func TestShouldDestroySessionWhenInactiveForTooLong(t *testing.T) { userSession.Username = "john" userSession.AuthenticationLevel = authentication.TwoFactor userSession.LastActivity = clock.Now().Add(-1 * time.Hour).Unix() - mock.Ctx.SaveSession(userSession) + mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com") @@ -509,7 +509,7 @@ func TestShouldDestroySessionWhenInactiveForTooLongUsingDurationNotation(t *test userSession.Username = "john" userSession.AuthenticationLevel = authentication.TwoFactor userSession.LastActivity = clock.Now().Add(-1 * time.Hour).Unix() - mock.Ctx.SaveSession(userSession) + mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com") @@ -535,7 +535,7 @@ func TestShouldKeepSessionWhenUserCheckedRememberMeAndIsInactiveForTooLong(t *te userSession.AuthenticationLevel = authentication.TwoFactor userSession.LastActivity = clock.Now().Add(-1 * time.Hour).Unix() userSession.KeepMeLoggedIn = true - mock.Ctx.SaveSession(userSession) + mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com") @@ -560,7 +560,7 @@ func TestShouldKeepSessionWhenInactivityTimeoutHasNotBeenExceeded(t *testing.T) userSession.Username = "john" userSession.AuthenticationLevel = authentication.TwoFactor userSession.LastActivity = clock.Now().Add(-1 * time.Second).Unix() - mock.Ctx.SaveSession(userSession) + mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com") @@ -579,7 +579,7 @@ func TestShouldURLEncodeRedirectionURLParameter(t *testing.T) { userSession := mock.Ctx.GetSession() userSession.Username = "john" userSession.AuthenticationLevel = authentication.NotAuthenticated - mock.Ctx.SaveSession(userSession) + mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com") mock.Ctx.Request.SetHost("mydomain.com") diff --git a/internal/handlers/response.go b/internal/handlers/response.go index d831ef742..ec5d9b71b 100644 --- a/internal/handlers/response.go +++ b/internal/handlers/response.go @@ -13,7 +13,7 @@ import ( func Handle1FAResponse(ctx *middlewares.AutheliaCtx, targetURI string, username string, groups []string) { if targetURI == "" { if !ctx.Providers.Authorizer.IsSecondFactorEnabled() && ctx.Configuration.DefaultRedirectionURL != "" { - ctx.SetJSONBody(redirectResponse{Redirect: ctx.Configuration.DefaultRedirectionURL}) + ctx.SetJSONBody(redirectResponse{Redirect: ctx.Configuration.DefaultRedirectionURL}) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } else { ctx.ReplyOK() } @@ -44,7 +44,7 @@ func Handle1FAResponse(ctx *middlewares.AutheliaCtx, targetURI string, username if !safeRedirection { if !ctx.Providers.Authorizer.IsSecondFactorEnabled() && ctx.Configuration.DefaultRedirectionURL != "" { - ctx.SetJSONBody(redirectResponse{Redirect: ctx.Configuration.DefaultRedirectionURL}) + ctx.SetJSONBody(redirectResponse{Redirect: ctx.Configuration.DefaultRedirectionURL}) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } else { ctx.ReplyOK() } @@ -53,14 +53,14 @@ func Handle1FAResponse(ctx *middlewares.AutheliaCtx, targetURI string, username ctx.Logger.Debugf("Redirection URL %s is safe", targetURI) response := redirectResponse{Redirect: targetURI} - ctx.SetJSONBody(response) + ctx.SetJSONBody(response) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } // Handle2FAResponse handle the redirection upon 2FA authentication func Handle2FAResponse(ctx *middlewares.AutheliaCtx, targetURI string) { if targetURI == "" { if ctx.Configuration.DefaultRedirectionURL != "" { - ctx.SetJSONBody(redirectResponse{Redirect: ctx.Configuration.DefaultRedirectionURL}) + ctx.SetJSONBody(redirectResponse{Redirect: ctx.Configuration.DefaultRedirectionURL}) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } else { ctx.ReplyOK() } @@ -75,7 +75,7 @@ func Handle2FAResponse(ctx *middlewares.AutheliaCtx, targetURI string) { } if targetURL != nil && utils.IsRedirectionSafe(*targetURL, ctx.Configuration.Session.Domain) { - ctx.SetJSONBody(redirectResponse{Redirect: targetURI}) + ctx.SetJSONBody(redirectResponse{Redirect: targetURI}) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } else { ctx.ReplyOK() } diff --git a/internal/server/index.go b/internal/server/index.go index 4381cf4f9..36502695e 100644 --- a/internal/server/index.go +++ b/internal/server/index.go @@ -43,4 +43,4 @@ func ServeIndex(publicDir string) fasthttp.RequestHandler { return } } -} \ No newline at end of file +} diff --git a/internal/suites/action_2fa_methods.go b/internal/suites/action_2fa_methods.go index 8b66742f6..96866dc7d 100644 --- a/internal/suites/action_2fa_methods.go +++ b/internal/suites/action_2fa_methods.go @@ -7,7 +7,7 @@ import ( ) func (wds *WebDriverSession) doChangeMethod(ctx context.Context, t *testing.T, method string) { - wds.WaitElementLocatedByID(ctx, t, "methods-button").Click() + wds.WaitElementLocatedByID(ctx, t, "methods-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. wds.WaitElementLocatedByID(ctx, t, "methods-dialog") - wds.WaitElementLocatedByID(ctx, t, fmt.Sprintf("%s-option", method)).Click() + wds.WaitElementLocatedByID(ctx, t, fmt.Sprintf("%s-option", method)).Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } diff --git a/internal/suites/action_reset_password.go b/internal/suites/action_reset_password.go index 96db1d23f..ae6d9184a 100644 --- a/internal/suites/action_reset_password.go +++ b/internal/suites/action_reset_password.go @@ -6,20 +6,20 @@ import ( ) func (wds *WebDriverSession) doInitiatePasswordReset(ctx context.Context, t *testing.T, username string) { - wds.WaitElementLocatedByID(ctx, t, "reset-password-button").Click() + wds.WaitElementLocatedByID(ctx, t, "reset-password-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. // Fill in username - wds.WaitElementLocatedByID(ctx, t, "username-textfield").SendKeys(username) + wds.WaitElementLocatedByID(ctx, t, "username-textfield").SendKeys(username) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. // And click on the reset button - wds.WaitElementLocatedByID(ctx, t, "reset-button").Click() + wds.WaitElementLocatedByID(ctx, t, "reset-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } func (wds *WebDriverSession) doCompletePasswordReset(ctx context.Context, t *testing.T, newPassword1, newPassword2 string) { link := doGetLinkFromLastMail(t) wds.doVisit(t, link) - wds.WaitElementLocatedByID(ctx, t, "password1-textfield").SendKeys(newPassword1) - wds.WaitElementLocatedByID(ctx, t, "password2-textfield").SendKeys(newPassword2) - wds.WaitElementLocatedByID(ctx, t, "reset-button").Click() + wds.WaitElementLocatedByID(ctx, t, "password1-textfield").SendKeys(newPassword1) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. + wds.WaitElementLocatedByID(ctx, t, "password2-textfield").SendKeys(newPassword2) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. + wds.WaitElementLocatedByID(ctx, t, "reset-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } func (wds *WebDriverSession) doSuccessfullyCompletePasswordReset(ctx context.Context, t *testing.T, newPassword1, newPassword2 string) { diff --git a/internal/suites/action_totp.go b/internal/suites/action_totp.go index 015931a71..3d88c3527 100644 --- a/internal/suites/action_totp.go +++ b/internal/suites/action_totp.go @@ -10,7 +10,7 @@ import ( ) func (wds *WebDriverSession) doRegisterTOTP(ctx context.Context, t *testing.T) string { - wds.WaitElementLocatedByID(ctx, t, "register-link").Click() + wds.WaitElementLocatedByID(ctx, t, "register-link").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. wds.verifyMailNotificationDisplayed(ctx, t) link := doGetLinkFromLastMail(t) wds.doVisit(t, link) @@ -25,7 +25,7 @@ func (wds *WebDriverSession) doEnterOTP(ctx context.Context, t *testing.T, code inputs := wds.WaitElementsLocatedByCSSSelector(ctx, t, "#otp-input input") for i := 0; i < 6; i++ { - inputs[i].SendKeys(string(code[i])) + inputs[i].SendKeys(string(code[i])) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. } } diff --git a/internal/suites/scenario_regulation_test.go b/internal/suites/scenario_regulation_test.go index f752cf9a8..120f8e5c9 100644 --- a/internal/suites/scenario_regulation_test.go +++ b/internal/suites/scenario_regulation_test.go @@ -55,14 +55,14 @@ func (s *RegulationScenario) TestShouldBanUserAfterTooManyAttempt() { s.verifyNotificationDisplayed(ctx, s.T(), "Incorrect username or password.") for i := 0; i < 3; i++ { - s.WaitElementLocatedByID(ctx, s.T(), "password-textfield").SendKeys("bad-password") - s.WaitElementLocatedByID(ctx, s.T(), "sign-in-button").Click() + s.WaitElementLocatedByID(ctx, s.T(), "password-textfield").SendKeys("bad-password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. + s.WaitElementLocatedByID(ctx, s.T(), "sign-in-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. time.Sleep(1 * time.Second) } // Enter the correct password and test the regulation lock out - s.WaitElementLocatedByID(ctx, s.T(), "password-textfield").SendKeys("password") - s.WaitElementLocatedByID(ctx, s.T(), "sign-in-button").Click() + s.WaitElementLocatedByID(ctx, s.T(), "password-textfield").SendKeys("password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. + s.WaitElementLocatedByID(ctx, s.T(), "sign-in-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. s.verifyNotificationDisplayed(ctx, s.T(), "Incorrect username or password.") time.Sleep(1 * time.Second) @@ -70,8 +70,8 @@ func (s *RegulationScenario) TestShouldBanUserAfterTooManyAttempt() { time.Sleep(9 * time.Second) // Enter the correct password and test a successful login - s.WaitElementLocatedByID(ctx, s.T(), "password-textfield").SendKeys("password") - s.WaitElementLocatedByID(ctx, s.T(), "sign-in-button").Click() + s.WaitElementLocatedByID(ctx, s.T(), "password-textfield").SendKeys("password") //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. + s.WaitElementLocatedByID(ctx, s.T(), "sign-in-button").Click() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. s.verifyIsSecondFactorPage(ctx, s.T()) } diff --git a/internal/suites/suite_kubernetes.go b/internal/suites/suite_kubernetes.go index a1302d5dc..99f00f5af 100644 --- a/internal/suites/suite_kubernetes.go +++ b/internal/suites/suite_kubernetes.go @@ -88,8 +88,8 @@ func init() { } teardown := func(suitePath string) error { - kubectl.StopDashboard() - kubectl.StopProxy() + kubectl.StopDashboard() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. + kubectl.StopProxy() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. return kind.DeleteCluster() } diff --git a/internal/suites/suite_network_acl_test.go b/internal/suites/suite_network_acl_test.go index b8ab7d28a..f1a8f369e 100644 --- a/internal/suites/suite_network_acl_test.go +++ b/internal/suites/suite_network_acl_test.go @@ -23,7 +23,7 @@ func (s *NetworkACLSuite) TestShouldAccessSecretUpon2FA() { wds, err := StartWebDriver() s.Require().NoError(err) - defer wds.Stop() + defer wds.Stop() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. targetURL := fmt.Sprintf("%s/secret.html", SecureBaseURL) wds.doVisit(s.T(), targetURL) @@ -40,7 +40,7 @@ func (s *NetworkACLSuite) TestShouldAccessSecretUpon1FA() { wds, err := StartWebDriverWithProxy("http://proxy-client1.example.com:3128", 4444) s.Require().NoError(err) - defer wds.Stop() + defer wds.Stop() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. targetURL := fmt.Sprintf("%s/secret.html", SecureBaseURL) wds.doVisit(s.T(), targetURL) @@ -58,7 +58,7 @@ func (s *NetworkACLSuite) TestShouldAccessSecretUpon0FA() { wds, err := StartWebDriverWithProxy("http://proxy-client2.example.com:3128", 4444) s.Require().NoError(err) - defer wds.Stop() + defer wds.Stop() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. wds.doVisit(s.T(), fmt.Sprintf("%s/secret.html", SecureBaseURL)) wds.verifySecretAuthorized(ctx, s.T()) diff --git a/internal/suites/webdriver.go b/internal/suites/webdriver.go index 31fd3cc54..74428cce4 100644 --- a/internal/suites/webdriver.go +++ b/internal/suites/webdriver.go @@ -52,7 +52,7 @@ func StartWebDriverWithProxy(proxy string, port int) (*WebDriverSession, error) wd, err := selenium.NewRemote(caps, fmt.Sprintf("http://localhost:%d/wd/hub", port)) if err != nil { - service.Stop() + service.Stop() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. panic(err) } @@ -86,7 +86,7 @@ func WithWebdriver(fn func(webdriver selenium.WebDriver) error) error { return err } - defer wds.Stop() + defer wds.Stop() //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting. return fn(wds.WebDriver) }