Fix spelling errors

This commit is contained in:
Amir Zarrinkafsh 2020-01-06 10:03:16 +11:00 committed by Clément Michaud
parent 1b39d28cbe
commit 612881ca67
15 changed files with 50 additions and 50 deletions

View File

@ -102,7 +102,7 @@ func migrateLocalU2FSecret(dbProvider storage.Provider) {
} }
func migrateLocalPreferences(dbProvider storage.Provider) { func migrateLocalPreferences(dbProvider storage.Provider) {
file, err := os.Open(path.Join(localDatabasePath, "prefered_2fa_method")) file, err := os.Open(path.Join(localDatabasePath, "preferred_2fa_method"))
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
@ -115,7 +115,7 @@ func migrateLocalPreferences(dbProvider storage.Provider) {
entry := PreferencesV3{} entry := PreferencesV3{}
json.Unmarshal([]byte(data), &entry) json.Unmarshal([]byte(data), &entry)
err := dbProvider.SavePrefered2FAMethod(entry.UserID, entry.Method) err := dbProvider.SavePreferred2FAMethod(entry.UserID, entry.Method)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)

View File

@ -124,7 +124,7 @@ func migrateMongoTOTPDevices(db *mongo.Database, dbProvider storage.Provider) {
} }
func migrateMongoPreferences(db *mongo.Database, dbProvider storage.Provider) { func migrateMongoPreferences(db *mongo.Database, dbProvider storage.Provider) {
u2fCollection := db.Collection("prefered_2fa_method") u2fCollection := db.Collection("preferred_2fa_method")
cur, err := u2fCollection.Find(context.Background(), bson.D{}) cur, err := u2fCollection.Find(context.Background(), bson.D{})
if err != nil { if err != nil {
@ -139,7 +139,7 @@ func migrateMongoPreferences(db *mongo.Database, dbProvider storage.Provider) {
log.Fatal(err) log.Fatal(err)
} }
err = dbProvider.SavePrefered2FAMethod(result.UserID, result.Method) err = dbProvider.SavePreferred2FAMethod(result.UserID, result.Method)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)

View File

@ -23,7 +23,7 @@ type SMTPNotifierConfiguration struct {
Secure bool `yaml:"secure"` Secure bool `yaml:"secure"`
} }
// NotifierConfiguration representes the configuration of the notifier to use when sending notifications to users. // NotifierConfiguration represents the configuration of the notifier to use when sending notifications to users.
type NotifierConfiguration struct { type NotifierConfiguration struct {
FileSystem *FileSystemNotifierConfiguration `yaml:"filesystem"` FileSystem *FileSystemNotifierConfiguration `yaml:"filesystem"`
Email *EmailNotifierConfiguration `yaml:"email"` Email *EmailNotifierConfiguration `yaml:"email"`

View File

@ -9,7 +9,7 @@ type ExtendedConfigurationBody struct {
AvailableMethods MethodList `json:"available_methods"` AvailableMethods MethodList `json:"available_methods"`
} }
// ExtendedConfigurationGet get the extended configuration accessbile to authenticated users. // ExtendedConfigurationGet get the extended configuration accessible to authenticated users.
func ExtendedConfigurationGet(ctx *middlewares.AutheliaCtx) { func ExtendedConfigurationGet(ctx *middlewares.AutheliaCtx) {
body := ExtendedConfigurationBody{} body := ExtendedConfigurationBody{}
body.AvailableMethods = MethodList{authentication.TOTP, authentication.U2F} body.AvailableMethods = MethodList{authentication.TOTP, authentication.U2F}

View File

@ -19,7 +19,7 @@ func loadInfo(username string, storageProvier storage.Provider, preferences *Use
errors := make([]error, 0) errors := make([]error, 0)
go func() { go func() {
defer wg.Done() defer wg.Done()
method, err := storageProvier.LoadPrefered2FAMethod(username) method, err := storageProvier.LoadPreferred2FAMethod(username)
if err != nil { if err != nil {
errors = append(errors, err) errors = append(errors, err)
logger.Error(err) logger.Error(err)
@ -97,11 +97,11 @@ func MethodPreferencePost(ctx *middlewares.AutheliaCtx) {
} }
userSession := ctx.GetSession() userSession := ctx.GetSession()
ctx.Logger.Debugf("Save new prefered 2FA method of user %s to %s", userSession.Username, bodyJSON.Method) ctx.Logger.Debugf("Save new preferred 2FA method of user %s to %s", userSession.Username, bodyJSON.Method)
err = ctx.Providers.StorageProvider.SavePrefered2FAMethod(userSession.Username, bodyJSON.Method) err = ctx.Providers.StorageProvider.SavePreferred2FAMethod(userSession.Username, bodyJSON.Method)
if err != nil { if err != nil {
ctx.Error(fmt.Errorf("Unable to save new prefered 2FA method: %s", err), operationFailedMessage) ctx.Error(fmt.Errorf("Unable to save new preferred 2FA method: %s", err), operationFailedMessage)
return return
} }

View File

@ -20,7 +20,7 @@ type FetchSuite struct {
func (s *FetchSuite) SetupTest() { func (s *FetchSuite) SetupTest() {
s.mock = mocks.NewMockAutheliaCtx(s.T()) s.mock = mocks.NewMockAutheliaCtx(s.T())
// Set the intial user session. // Set the initial user session.
userSession := s.mock.Ctx.GetSession() userSession := s.mock.Ctx.GetSession()
userSession.Username = "john" userSession.Username = "john"
userSession.AuthenticationLevel = 1 userSession.AuthenticationLevel = 1
@ -34,7 +34,7 @@ func (s *FetchSuite) TearDownTest() {
func setPreferencesExpectations(preferences UserPreferences, provider *storage.MockProvider) { func setPreferencesExpectations(preferences UserPreferences, provider *storage.MockProvider) {
provider. provider.
EXPECT(). EXPECT().
LoadPrefered2FAMethod(gomock.Eq("john")). LoadPreferred2FAMethod(gomock.Eq("john")).
Return(preferences.Method, nil) Return(preferences.Method, nil)
if preferences.HasU2F { if preferences.HasU2F {
@ -89,7 +89,7 @@ func TestMethodSetToU2F(t *testing.T) {
for _, expectedPreferences := range table { for _, expectedPreferences := range table {
mock := mocks.NewMockAutheliaCtx(t) mock := mocks.NewMockAutheliaCtx(t)
// Set the intial user session. // Set the initial user session.
userSession := mock.Ctx.GetSession() userSession := mock.Ctx.GetSession()
userSession.Username = "john" userSession.Username = "john"
userSession.AuthenticationLevel = 1 userSession.AuthenticationLevel = 1
@ -119,7 +119,7 @@ func TestMethodSetToU2F(t *testing.T) {
func (s *FetchSuite) TestShouldGetDefaultPreferenceIfNotInDB() { func (s *FetchSuite) TestShouldGetDefaultPreferenceIfNotInDB() {
s.mock.StorageProviderMock. s.mock.StorageProviderMock.
EXPECT(). EXPECT().
LoadPrefered2FAMethod(gomock.Eq("john")). LoadPreferred2FAMethod(gomock.Eq("john")).
Return("", nil) Return("", nil)
s.mock.StorageProviderMock. s.mock.StorageProviderMock.
@ -138,7 +138,7 @@ func (s *FetchSuite) TestShouldGetDefaultPreferenceIfNotInDB() {
func (s *FetchSuite) TestShouldReturnError500WhenStorageFailsToLoad() { func (s *FetchSuite) TestShouldReturnError500WhenStorageFailsToLoad() {
s.mock.StorageProviderMock.EXPECT(). s.mock.StorageProviderMock.EXPECT().
LoadPrefered2FAMethod(gomock.Eq("john")). LoadPreferred2FAMethod(gomock.Eq("john")).
Return("", fmt.Errorf("Failure")) Return("", fmt.Errorf("Failure"))
s.mock.StorageProviderMock. s.mock.StorageProviderMock.
@ -167,7 +167,7 @@ type SaveSuite struct {
func (s *SaveSuite) SetupTest() { func (s *SaveSuite) SetupTest() {
s.mock = mocks.NewMockAutheliaCtx(s.T()) s.mock = mocks.NewMockAutheliaCtx(s.T())
// Set the intial user session. // Set the initial user session.
userSession := s.mock.Ctx.GetSession() userSession := s.mock.Ctx.GetSession()
userSession.Username = "john" userSession.Username = "john"
userSession.AuthenticationLevel = 1 userSession.AuthenticationLevel = 1
@ -217,20 +217,20 @@ func (s *SaveSuite) TestShouldReturnError500WhenBadMethodProvided() {
func (s *SaveSuite) TestShouldReturnError500WhenDatabaseFailsToSave() { func (s *SaveSuite) TestShouldReturnError500WhenDatabaseFailsToSave() {
s.mock.Ctx.Request.SetBody([]byte("{\"method\":\"u2f\"}")) s.mock.Ctx.Request.SetBody([]byte("{\"method\":\"u2f\"}"))
s.mock.StorageProviderMock.EXPECT(). s.mock.StorageProviderMock.EXPECT().
SavePrefered2FAMethod(gomock.Eq("john"), gomock.Eq("u2f")). SavePreferred2FAMethod(gomock.Eq("john"), gomock.Eq("u2f")).
Return(fmt.Errorf("Failure")) Return(fmt.Errorf("Failure"))
MethodPreferencePost(s.mock.Ctx) MethodPreferencePost(s.mock.Ctx)
s.mock.Assert200KO(s.T(), "Operation failed.") s.mock.Assert200KO(s.T(), "Operation failed.")
assert.Equal(s.T(), "Unable to save new prefered 2FA method: Failure", s.mock.Hook.LastEntry().Message) assert.Equal(s.T(), "Unable to save new preferred 2FA method: Failure", s.mock.Hook.LastEntry().Message)
assert.Equal(s.T(), logrus.ErrorLevel, s.mock.Hook.LastEntry().Level) assert.Equal(s.T(), logrus.ErrorLevel, s.mock.Hook.LastEntry().Level)
} }
func (s *SaveSuite) TestShouldReturn200WhenMethodIsSuccessfullySaved() { func (s *SaveSuite) TestShouldReturn200WhenMethodIsSuccessfullySaved() {
s.mock.Ctx.Request.SetBody([]byte("{\"method\":\"u2f\"}")) s.mock.Ctx.Request.SetBody([]byte("{\"method\":\"u2f\"}"))
s.mock.StorageProviderMock.EXPECT(). s.mock.StorageProviderMock.EXPECT().
SavePrefered2FAMethod(gomock.Eq("john"), gomock.Eq("u2f")). SavePreferred2FAMethod(gomock.Eq("john"), gomock.Eq("u2f")).
Return(nil) Return(nil)
MethodPreferencePost(s.mock.Ctx) MethodPreferencePost(s.mock.Ctx)

View File

@ -12,7 +12,7 @@ type authorizationMatching int
// UserInfo is the model of user second factor preferences // UserInfo is the model of user second factor preferences
type UserPreferences struct { type UserPreferences struct {
// The prefered 2FA method. // The preferred 2FA method.
Method string `json:"method" valid:"required"` Method string `json:"method" valid:"required"`
// True if a security key has been registered // True if a security key has been registered

View File

@ -51,7 +51,7 @@ func (n *SMTPNotifier) Send(recipient string, subject string, body string) error
return err return err
} }
// Do StartTLS if available (some servers only provide the auth extnesion after, and encrpytion is preferred) // Do StartTLS if available (some servers only provide the auth extnesion after, and encryption is preferred)
starttls, _ := c.Extension("STARTTLS") starttls, _ := c.Extension("STARTTLS")
if starttls { if starttls {
tlsconfig := &tls.Config{ tlsconfig := &tls.Config{

View File

@ -227,7 +227,7 @@ func (s *RegulatorSuite) TestShouldCheckRegulationHasBeenResetOnSuccessfulAttemp
Time: s.clock.Now().Add(-93 * time.Second), Time: s.clock.Now().Add(-93 * time.Second),
}, },
// The user was almost banned but he did a successful attempt. Therefore, even if the next // The user was almost banned but he did a successful attempt. Therefore, even if the next
// failure happens withing FindTime, he should not be banned. // failure happens within FindTime, he should not be banned.
models.AuthenticationAttempt{ models.AuthenticationAttempt{
Username: "john", Username: "john",
Successful: false, Successful: false,

View File

@ -9,8 +9,8 @@ import (
// Provider is an interface providing storage capabilities for // Provider is an interface providing storage capabilities for
// persisting any kind of data related to Authelia. // persisting any kind of data related to Authelia.
type Provider interface { type Provider interface {
LoadPrefered2FAMethod(username string) (string, error) LoadPreferred2FAMethod(username string) (string, error)
SavePrefered2FAMethod(username string, method string) error SavePreferred2FAMethod(username string, method string) error
FindIdentityVerificationToken(token string) (bool, error) FindIdentityVerificationToken(token string) (bool, error)
SaveIdentityVerificationToken(token string) error SaveIdentityVerificationToken(token string) error

View File

@ -34,33 +34,33 @@ func (m *MockProvider) EXPECT() *MockProviderMockRecorder {
return m.recorder return m.recorder
} }
// LoadPrefered2FAMethod mocks base method // LoadPreferred2FAMethod mocks base method
func (m *MockProvider) LoadPrefered2FAMethod(username string) (string, error) { func (m *MockProvider) LoadPreferred2FAMethod(username string) (string, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LoadPrefered2FAMethod", username) ret := m.ctrl.Call(m, "LoadPreferred2FAMethod", username)
ret0, _ := ret[0].(string) ret0, _ := ret[0].(string)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// LoadPrefered2FAMethod indicates an expected call of LoadPrefered2FAMethod // LoadPreferred2FAMethod indicates an expected call of LoadPreferred2FAMethod
func (mr *MockProviderMockRecorder) LoadPrefered2FAMethod(username interface{}) *gomock.Call { func (mr *MockProviderMockRecorder) LoadPreferred2FAMethod(username interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadPrefered2FAMethod", reflect.TypeOf((*MockProvider)(nil).LoadPrefered2FAMethod), username) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadPreferred2FAMethod", reflect.TypeOf((*MockProvider)(nil).LoadPreferred2FAMethod), username)
} }
// SavePrefered2FAMethod mocks base method // SavePreferred2FAMethod mocks base method
func (m *MockProvider) SavePrefered2FAMethod(username, method string) error { func (m *MockProvider) SavePreferred2FAMethod(username, method string) error {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SavePrefered2FAMethod", username, method) ret := m.ctrl.Call(m, "SavePreferred2FAMethod", username, method)
ret0, _ := ret[0].(error) ret0, _ := ret[0].(error)
return ret0 return ret0
} }
// SavePrefered2FAMethod indicates an expected call of SavePrefered2FAMethod // SavePreferred2FAMethod indicates an expected call of SavePreferred2FAMethod
func (mr *MockProviderMockRecorder) SavePrefered2FAMethod(username, method interface{}) *gomock.Call { func (mr *MockProviderMockRecorder) SavePreferred2FAMethod(username, method interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SavePrefered2FAMethod", reflect.TypeOf((*MockProvider)(nil).SavePrefered2FAMethod), username, method) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SavePreferred2FAMethod", reflect.TypeOf((*MockProvider)(nil).SavePreferred2FAMethod), username, method)
} }
// FindIdentityVerificationToken mocks base method // FindIdentityVerificationToken mocks base method

View File

@ -72,8 +72,8 @@ func (p *SQLProvider) initialize(db *sql.DB) error {
return nil return nil
} }
// LoadPrefered2FAMethod load the prefered method for 2FA from sqlite db. // LoadPreferred2FAMethod load the preferred method for 2FA from sqlite db.
func (p *SQLProvider) LoadPrefered2FAMethod(username string) (string, error) { func (p *SQLProvider) LoadPreferred2FAMethod(username string) (string, error) {
rows, err := p.db.Query(p.sqlGetPreferencesByUsername, username) rows, err := p.db.Query(p.sqlGetPreferencesByUsername, username)
defer rows.Close() defer rows.Close()
if err != nil { if err != nil {
@ -90,8 +90,8 @@ func (p *SQLProvider) LoadPrefered2FAMethod(username string) (string, error) {
return "", nil return "", nil
} }
// SavePrefered2FAMethod save the prefered method for 2FA in sqlite db. // SavePreferred2FAMethod save the preferred method for 2FA in sqlite db.
func (p *SQLProvider) SavePrefered2FAMethod(username string, method string) error { func (p *SQLProvider) SavePreferred2FAMethod(username string, method string) error {
_, err := p.db.Exec(p.sqlUpsertSecondFactorPreference, username, method) _, err := p.db.Exec(p.sqlUpsertSecondFactorPreference, username, method)
return err return err
} }

View File

@ -264,9 +264,9 @@ const emailContent = `
</tbody> </tbody>
</table> </table>
<!-- End of Header --> <!-- End of Header -->
<!-- Start of seperator --> <!-- Start of separator -->
<table width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" id="backgroundTable" <table width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" id="backgroundTable"
st-sortable="seperator"> st-sortable="separator">
<tbody> <tbody>
<tr> <tr>
<td> <td>
@ -281,7 +281,7 @@ const emailContent = `
</tr> </tr>
</tbody> </tbody>
</table> </table>
<!-- End of seperator --> <!-- End of separator -->
<!-- Start Full Text --> <!-- Start Full Text -->
<table width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" id="backgroundTable" <table width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" id="backgroundTable"
st-sortable="full-text"> st-sortable="full-text">
@ -353,9 +353,9 @@ const emailContent = `
</tbody> </tbody>
</table> </table>
<!-- end of full text --> <!-- end of full text -->
<!-- Start of seperator --> <!-- Start of separator -->
<table width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" id="backgroundTable" <table width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" id="backgroundTable"
st-sortable="seperator"> st-sortable="separator">
<tbody> <tbody>
<tr> <tr>
<td> <td>
@ -377,7 +377,7 @@ const emailContent = `
</tr> </tr>
</tbody> </tbody>
</table> </table>
<!-- End of seperator --> <!-- End of separator -->
<!-- Start of Postfooter --> <!-- Start of Postfooter -->
<table width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" id="backgroundTable" <table width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" id="backgroundTable"
st-sortable="postfooter"> st-sortable="postfooter">

View File

@ -42,7 +42,7 @@ export async function getUserPreferences(): Promise<UserInfo> {
return { ...res, method: toEnum(res.method) }; return { ...res, method: toEnum(res.method) };
} }
export function setPrefered2FAMethod(method: SecondFactorMethod) { export function setPreferred2FAMethod(method: SecondFactorMethod) {
return PostWithOptionalResponse(UserInfo2FAMethodPath, return PostWithOptionalResponse(UserInfo2FAMethodPath,
{ method: toString(method) } as MethodPreferencePayload); { method: toString(method) } as MethodPreferencePayload);
} }

View File

@ -16,7 +16,7 @@ import {
LogoutRoute as SignOutRoute, SecondFactorTOTPRoute, LogoutRoute as SignOutRoute, SecondFactorTOTPRoute,
SecondFactorPushRoute, SecondFactorU2FRoute, SecondFactorRoute SecondFactorPushRoute, SecondFactorU2FRoute, SecondFactorRoute
} from "../../../Routes"; } from "../../../Routes";
import { setPrefered2FAMethod } from "../../../services/UserPreferences"; import { setPreferred2FAMethod } from "../../../services/UserPreferences";
import { UserInfo } from "../../../models/UserInfo"; import { UserInfo } from "../../../models/UserInfo";
import { ExtendedConfiguration } from "../../../models/Configuration"; import { ExtendedConfiguration } from "../../../models/Configuration";
import u2fApi from "u2f-api"; import u2fApi from "u2f-api";
@ -69,12 +69,12 @@ export default function (props: Props) {
const handleMethodSelected = async (method: SecondFactorMethod) => { const handleMethodSelected = async (method: SecondFactorMethod) => {
try { try {
await setPrefered2FAMethod(method); await setPreferred2FAMethod(method);
setMethodSelectionOpen(false); setMethodSelectionOpen(false);
props.onMethodChanged(method); props.onMethodChanged(method);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
createErrorNotification("There was an issue updating prefered second factor method"); createErrorNotification("There was an issue updating preferred second factor method");
} }
} }