Skip to content

Commit b3b2da1

Browse files
susnuxbackportbot[bot]
authored andcommitted
fix(sharing): enforce password policy
fix(sharing): enforce password policy Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de> [skip ci]
1 parent 41d5f5e commit b3b2da1

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

apps/files_sharing/src/components/SharingEntryLink.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
:label="t('files_sharing', 'Enter a password')"
8989
:disabled="saving"
9090
:required="config.enableLinkPasswordByDefault || config.enforcePasswordForPublicLink"
91-
:minlength="isPasswordPolicyEnabled && config.passwordPolicy.minLength"
91+
:minlength="minPasswordLength"
9292
autocomplete="new-password"
9393
@submit="onNewLinkShare(true)">
9494
<template #icon>
@@ -349,6 +349,16 @@ export default {
349349
},
350350
351351
computed: {
352+
minPasswordLength() {
353+
if (this.isPasswordPolicyEnabled) {
354+
if (this.config.passwordPolicy.policies?.sharing?.minLength) {
355+
return this.config.passwordPolicy.policies.sharing.minLength
356+
}
357+
return this.config.passwordPolicy.minLength
358+
}
359+
return 0
360+
},
361+
352362
/**
353363
* Link share label
354364
*

apps/files_sharing/src/services/ConfigService.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,24 @@
55
import { getCapabilities } from '@nextcloud/capabilities'
66
import { loadState } from '@nextcloud/initial-state'
77

8-
type PasswordPolicyCapabilities = {
8+
type PasswordPolicySettings = {
99
enforceNonCommonPassword: boolean
1010
enforceNumericCharacters: boolean
1111
enforceSpecialCharacters: boolean
1212
enforceUpperLowerCase: boolean
1313
minLength: number
1414
}
1515

16+
type PasswordPolicyCapabilities = PasswordPolicySettings & {
17+
api?: {
18+
generate: string
19+
validate: string
20+
}
21+
policies?: {
22+
sharing: PasswordPolicySettings
23+
}
24+
}
25+
1626
type FileSharingCapabilities = {
1727
api_enabled: boolean
1828
public: {

apps/files_sharing/src/utils/GeneratePassword.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export default async function(verbose = false): Promise<string> {
2222
// password policy is enabled, let's request a pass
2323
if (config.passwordPolicy.api && config.passwordPolicy.api.generate) {
2424
try {
25-
const request = await axios.get(config.passwordPolicy.api.generate)
25+
const request = await axios.get(config.passwordPolicy.api.generate, {
26+
params: { context: 'sharing' },
27+
})
2628
if (request.data.ocs.data.password) {
2729
if (verbose) {
2830
showSuccess(t('files_sharing', 'Password created successfully'))

0 commit comments

Comments
 (0)