-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate against Banned-Passwords List #9727
Changes from all commits
b80d6d3
03a7efe
2282170
9f73d1c
3a400b1
e4a17f7
168baca
3b46940
9a75086
cfb7623
d00ec57
2227adc
3cd8cac
7ba1914
4899746
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Enhancement: Show error if password is on a banned password list | ||
|
||
We now show a meaningful error if the user tries to set a public link password, | ||
that's on a server side banned password list. | ||
|
||
https://github.com/owncloud/web/pull/9727 | ||
https://github.com/owncloud/web/issues/9726 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
password | ||
12345678 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -350,7 +350,13 @@ export default defineComponent({ | |
}, | ||
methods: { | ||
...mapActions('Files', ['addLink', 'updateLink', 'removeLink']), | ||
...mapActions(['showMessage', 'showErrorMessage', 'createModal', 'hideModal']), | ||
...mapActions([ | ||
'showMessage', | ||
'showErrorMessage', | ||
'createModal', | ||
'hideModal', | ||
'setModalInputErrorMessage' | ||
]), | ||
...mapMutations('Files', ['REMOVE_FILES']), | ||
|
||
toggleLinkListCollapsed() { | ||
|
@@ -394,7 +400,7 @@ export default defineComponent({ | |
}) | ||
}, | ||
|
||
checkLinkToCreate({ link, onError = () => {} }) { | ||
checkLinkToCreate({ link }) { | ||
const paramsToCreate = this.getParamsForLink(link) | ||
|
||
if (this.isPasswordEnforcedFor(link)) { | ||
|
@@ -405,15 +411,15 @@ export default defineComponent({ | |
passwordPolicyService: this.passwordPolicyService | ||
}, | ||
(newPassword) => { | ||
this.createLink({ params: { ...paramsToCreate, password: newPassword }, onError }) | ||
this.createLink({ params: { ...paramsToCreate, password: newPassword } }) | ||
} | ||
) | ||
} else { | ||
this.createLink({ params: paramsToCreate, onError }) | ||
this.createLink({ params: paramsToCreate }) | ||
} | ||
}, | ||
|
||
checkLinkToUpdate({ link, onSuccess = () => {} }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed all those onSuccess and onError callbacks because they actually weren't used and added to confusion. |
||
checkLinkToUpdate({ link }) { | ||
const params = this.getParamsForLink(link) | ||
|
||
if (!link.password && this.isPasswordEnforcedFor(link)) { | ||
|
@@ -424,11 +430,11 @@ export default defineComponent({ | |
passwordPolicyService: this.passwordPolicyService | ||
}, | ||
(newPassword) => { | ||
this.updatePublicLink({ params: { ...params, password: newPassword }, onSuccess }) | ||
this.updatePublicLink({ params: { ...params, password: newPassword } }) | ||
} | ||
) | ||
} else { | ||
this.updatePublicLink({ params, onSuccess }) | ||
this.updatePublicLink({ params }) | ||
} | ||
}, | ||
|
||
|
@@ -481,7 +487,7 @@ export default defineComponent({ | |
} | ||
}, | ||
|
||
async createLink({ params, onError = (e) => {} }) { | ||
async createLink({ params }) { | ||
let path = this.resource.path | ||
// sharing a share root from the share jail -> use resource name as path | ||
if (this.hasShareJail && path === '/') { | ||
|
@@ -494,41 +500,47 @@ export default defineComponent({ | |
storageId: this.resource.fileId || this.resource.id, | ||
params | ||
}) | ||
this.hideModal() | ||
this.showMessage({ | ||
title: this.$gettext('Link was created successfully') | ||
}) | ||
} catch (e) { | ||
onError(e) | ||
console.error(e) | ||
|
||
// Human-readable error message is provided, for example when password is on banned list | ||
if (e.status === 400) { | ||
return this.setModalInputErrorMessage(this.$gettext(e.message)) | ||
} | ||
|
||
this.showErrorMessage({ | ||
title: this.$gettext('Failed to create link'), | ||
error: e | ||
}) | ||
return | ||
} | ||
|
||
this.showMessage({ | ||
title: this.$gettext('Link was created successfully') | ||
}) | ||
}, | ||
|
||
async updatePublicLink({ params, onSuccess = () => {}, onError = (e) => {} }) { | ||
async updatePublicLink({ params }) { | ||
try { | ||
await this.updateLink({ | ||
id: params.id, | ||
client: this.$client, | ||
params | ||
}).then(onSuccess) | ||
}) | ||
this.hideModal() | ||
this.showMessage({ | ||
title: this.$gettext('Link was updated successfully') | ||
}) | ||
} catch (e) { | ||
onError(e) | ||
console.error(e) | ||
// Human-readable error message is provided, for example when password is on banned list | ||
if (e.statusCode === 400) { | ||
return this.setModalInputErrorMessage(this.$gettext(e.message)) | ||
} | ||
|
||
this.showErrorMessage({ | ||
title: this.$gettext('Failed to update link'), | ||
error: e | ||
}) | ||
return | ||
} | ||
|
||
this.showMessage({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't be here. |
||
title: this.$gettext('Link was updated successfully') | ||
}) | ||
}, | ||
|
||
deleteLinkConfirmation({ link }) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,22 +30,12 @@ export function showQuickLinkPasswordModal({ $gettext, store, passwordPolicyServ | |
inputGeneratePasswordMethod: () => passwordPolicyService.generatePassword(), | ||
inputLabel: $gettext('Password'), | ||
inputType: 'password', | ||
onInput: () => store.dispatch('setModalInputErrorMessage', ''), | ||
onPasswordChallengeCompleted: () => store.dispatch('setModalConfirmButtonDisabled', false), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I missed those in the last pr. |
||
onPasswordChallengeFailed: () => store.dispatch('setModalConfirmButtonDisabled', true), | ||
onCancel: () => store.dispatch('hideModal'), | ||
onConfirm: async (password) => { | ||
if (!password || password.trim() === '') { | ||
store.dispatch('showErrorMessage', { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed anymore as built in default password policy. Also closing the modal instantly was not correct, because we might want to show an error in the modal. |
||
title: $gettext('Password cannot be empty') | ||
}) | ||
} else { | ||
await store.dispatch('hideModal') | ||
onConfirm(password) | ||
} | ||
}, | ||
onInput: (password) => { | ||
if (password.trim() === '') { | ||
return store.dispatch('setModalInputErrorMessage', $gettext('Password cannot be empty')) | ||
} | ||
return store.dispatch('setModalInputErrorMessage', null) | ||
onConfirm(password) | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,9 +37,11 @@ export class PasswordPolicyService { | |
|
||
private useDefaultRules(): boolean { | ||
return ( | ||
Object.keys(this.capability).length === 0 || | ||
(Object.keys(this.capability).length === 1 && | ||
Object.keys(this.capability)[0] === 'max_characters') | ||
!this.capability.min_characters && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are always set, defaults to 0, so had to change the logic |
||
!this.capability.min_lowercase_characters && | ||
!this.capability.min_uppercase_characters && | ||
!this.capability.min_digits && | ||
!this.capability.min_special_characters | ||
) | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added some demo data, can't hurt