Merge pull request #11816 from overleaf/jpa-re-encrypt-v2

[access-token-encryptor] flag v2 tokens for re-encryption

GitOrigin-RevId: 4ccb6d220d74a821f2fef8c72267f174cc2c502f
This commit is contained in:
Jakob Ackermann 2023-02-15 13:13:36 +00:00 committed by Copybot
parent b531105446
commit d06a578492
2 changed files with 7 additions and 7 deletions

View file

@ -68,14 +68,14 @@ async function reEncryptTokensInCollection({
for (const [name, path] of Object.entries(paths)) {
const blob = _.get(doc, path)
if (!blob) continue
// Schema: LABEL:SALT:CIPHERTEXT:IV
const [label, , , iv] = blob.split(':', 4)
const version = iv ? 'v2' : 'v1'
// Schema: LABEL-VERSION:SALT:CIPHERTEXT:IV
const [label] = blob.split(':')
const [, version] = label.split('-')
const key = [name, version, collectionName, path, label].join(':')
stats[key] = (stats[key] || 0) + 1
if (version === 'v1') {
if (version === 'v2') {
update = update || {}
update[path] = await reEncryptTokens(accessTokenEncryptor, blob)
}

View file

@ -40,9 +40,9 @@ async function count(collectionName, paths) {
for (const [name, path] of Object.entries(paths)) {
const blob = _.get(doc, path)
if (!blob) continue
// Schema: LABEL:SALT:CIPHERTEXT:IV
const [label, , , iv] = blob.split(':', 4)
const version = iv ? 'v2' : 'v1'
// Schema: LABEL-VERSION:SALT:CIPHERTEXT:IV
const [label] = blob.split(':')
const [, version] = label.split('-')
const key = [name, version, collectionName, path, label].join(':')
stats[key] = (stats[key] || 0) + 1