瀏覽代碼

Improve password generation for link shares

Use web crypto when generating password for link shares
whenever the password policy app is disabled.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
tags/v26.0.0beta1
Vincent Petry 1 年之前
父節點
當前提交
e9f7ea11bb
沒有連結到貢獻者的電子郵件帳戶。

+ 9
- 6
apps/files_sharing/src/utils/GeneratePassword.js 查看文件

@@ -25,6 +25,7 @@ import Config from '../services/ConfigService'
import { showError, showSuccess } from '@nextcloud/dialogs'

const config = new Config()
// note: some chars removed on purpose to make them human friendly when read out
const passwordSet = 'abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789'

/**
@@ -49,10 +50,12 @@ export default async function() {
}
}

// generate password of 10 length based on passwordSet
return Array(10).fill(0)
.reduce((prev, curr) => {
prev += passwordSet.charAt(Math.floor(Math.random() * passwordSet.length))
return prev
}, '')
const array = new Uint8Array(10)
const ratio = passwordSet.length / 255
self.crypto.getRandomValues(array)
let password = ''
for (let i = 0; i < array.length; i++) {
password += passwordSet.charAt(array[i] * ratio)
}
return password
}

+ 2
- 2
dist/files_sharing-files_sharing_tab.js
文件差異過大導致無法顯示
查看文件


+ 1
- 1
dist/files_sharing-files_sharing_tab.js.map
文件差異過大導致無法顯示
查看文件


Loading…
取消
儲存