Просмотр исходного кода

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

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

GitOrigin-RevId: 4ccb6d220d74a821f2fef8c72267f174cc2c502f
Jakob Ackermann 3 лет назад
Родитель
Сommit
d06a578492

+ 4 - 4
libraries/access-token-encryptor/scripts/helpers/re-encrypt-tokens.js

@@ -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)
       }

+ 3 - 3
services/web/scripts/count_encrypted_access_tokens.js

@@ -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