mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
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> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
This commit is contained in:
parent
ff90735db7
commit
2aad203c99
3 changed files with 12 additions and 9 deletions
|
|
@ -24,6 +24,7 @@ import axios from '@nextcloud/axios'
|
|||
import Config from '../services/ConfigService'
|
||||
|
||||
const config = new Config()
|
||||
// note: some chars removed on purpose to make them human friendly when read out
|
||||
const passwordSet = 'abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789'
|
||||
|
||||
/**
|
||||
|
|
@ -46,10 +47,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
|
||||
}
|
||||
|
|
|
|||
4
dist/files_sharing-files_sharing_tab.js
vendored
4
dist/files_sharing-files_sharing_tab.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files_sharing-files_sharing_tab.js.map
vendored
2
dist/files_sharing-files_sharing_tab.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue