Skip to content

Commit

Permalink
disable argon2 migration (#6938)
Browse files Browse the repository at this point in the history
We disable argon2 migration to prevent that client with offline support
prior to 229.240513.0 have unexpected errors

Co-authored-by: bedhub <bedhub@users.noreply.github.com>
  • Loading branch information
bedhub and bedhub committed May 14, 2024
1 parent ee241c0 commit 67cb9f4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/api/common/TutanotaConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ type ConstType = {
WEBAUTHN_RP_ID: string
U2f_APPID_SUFFIX: string
U2F_LEGACY_APPID: string
EXECUTE_KDF_MIGRATION: boolean
}

export const Const: ConstType = {
Expand All @@ -323,6 +324,7 @@ export const Const: ConstType = {
// we'll still get the contents
// because it will be redirected to tuta.com after new domain deploy.
U2F_LEGACY_APPID: "https://tutanota.com/u2f-appid.json",
EXECUTE_KDF_MIGRATION: false,
} as const

export const TUTANOTA_MAIL_ADDRESS_DOMAINS: ReadonlyArray<string> = Object.freeze([
Expand Down
6 changes: 5 additions & 1 deletion src/api/worker/facades/LoginFacade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
SessionService,
TakeOverDeletedAddressService,
} from "../../entities/sys/Services"
import { AccountType, asKdfType, CloseEventBusOption, DEFAULT_KDF_TYPE, KdfType } from "../../common/TutanotaConstants"
import { AccountType, asKdfType, CloseEventBusOption, Const, DEFAULT_KDF_TYPE, KdfType } from "../../common/TutanotaConstants"
import {
Challenge,
createChangeKdfPostIn,
Expand Down Expand Up @@ -295,6 +295,10 @@ export class LoginFacade {
* @param user the user we are updating
*/
public async migrateKdfType(targetKdfType: KdfType, passphrase: string, user: User): Promise<void> {
if (!Const.EXECUTE_KDF_MIGRATION) {
// Migration is not yet enabled on this version.
return
}
const currentPassphraseKeyData = {
passphrase,
kdfType: asKdfType(user.kdfVersion),
Expand Down
6 changes: 5 additions & 1 deletion test/tests/api/worker/facades/LoginFacadeTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { UserFacade } from "../../../../../src/api/worker/facades/UserFacade"
import { ChangeKdfService, SaltService, SessionService } from "../../../../../src/api/entities/sys/Services"
import { Credentials } from "../../../../../src/misc/credentials/Credentials"
import { defer, DeferredObject, uint8ArrayToBase64 } from "@tutao/tutanota-utils"
import { AccountType, DEFAULT_KDF_TYPE, KdfType } from "../../../../../src/api/common/TutanotaConstants"
import { AccountType, Const, DEFAULT_KDF_TYPE, KdfType } from "../../../../../src/api/common/TutanotaConstants"
import { AccessExpiredError, ConnectionError, NotAuthenticatedError } from "../../../../../src/api/common/error/RestError"
import { SessionType } from "../../../../../src/api/common/SessionType"
import { HttpMethod } from "../../../../../src/api/common/EntityFunctions"
Expand Down Expand Up @@ -753,6 +753,7 @@ o.spec("LoginFacadeTest", function () {
user.salt = SALT

when(userFacade.getCurrentUserGroupKey()).thenReturn({ object: [1, 2, 3, 4], version: 0 })
Const.EXECUTE_KDF_MIGRATION = true
await facade.migrateKdfType(KdfType.Argon2id, "hunter2", user)

verify(
Expand All @@ -772,5 +773,8 @@ o.spec("LoginFacadeTest", function () {
),
)
})
o.afterEach(() => {
Const.EXECUTE_KDF_MIGRATION = false
})
})
})

0 comments on commit 67cb9f4

Please sign in to comment.