Skip to content

fix(files_sharing): Use share password policy for password generation#58221

Open
nfebe wants to merge 2 commits intomasterfrom
fix/share-password-policy-generation
Open

fix(files_sharing): Use share password policy for password generation#58221
nfebe wants to merge 2 commits intomasterfrom
fix/share-password-policy-generation

Conversation

@nfebe
Copy link
Copy Markdown
Contributor

@nfebe nfebe commented Feb 10, 2026

Pass context=sharing when calling the password_policy API to generate passwords that comply with share-specific password policies.

The fallback generator now also respects the sharing policy settings from capabilities (minLength, special characters, etc.) when the API is unavailable.

Fixes: nextcloud/password_policy#870

@nfebe nfebe requested a review from a team as a code owner February 10, 2026 13:14
@nfebe nfebe requested review from sorbaugh, susnux and szaimen and removed request for a team February 10, 2026 13:14
@nfebe nfebe force-pushed the fix/share-password-policy-generation branch 3 times, most recently from 77608d0 to 0072c5e Compare February 10, 2026 13:40
nfebe added 2 commits March 18, 2026 18:17
Pass context=sharing when calling the password_policy API to generate
passwords that comply with share-specific password policies.

The fallback generator now also respects the sharing policy settings
from capabilities (minLength, special characters, etc.) when the API
is unavailable.

Fixes: nextcloud/password_policy#870
Signed-off-by: nfebe <fenn25.fn@gmail.com>
Signed-off-by: nfebe <fenn25.fn@gmail.com>
@nfebe nfebe force-pushed the fix/share-password-policy-generation branch from 0072c5e to cb46856 Compare March 18, 2026 17:17
// Character sets for password generation
const CHARS_LOWER = 'abcdefgijkmnopqrstwxyz'
const CHARS_UPPER = 'ABCDEFGHJKLMNPQRSTWXYZ'
const CHARS_DIGITS = '23456789'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing 1?

Suggested change
const CHARS_DIGITS = '23456789'
const CHARS_DIGITS = '123456789'

// note: some chars removed on purpose to make them human friendly when read out
const passwordSet = 'abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789'
// Character sets for password generation
const CHARS_LOWER = 'abcdefgijkmnopqrstwxyz'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const CHARS_LOWER = 'abcdefgijkmnopqrstwxyz'
const CHARS_LOWER = 'abcdefghijklmnopqrstuvwxyz'

const passwordSet = 'abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789'
// Character sets for password generation
const CHARS_LOWER = 'abcdefgijkmnopqrstwxyz'
const CHARS_UPPER = 'ABCDEFGHJKLMNPQRSTWXYZ'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const CHARS_UPPER = 'ABCDEFGHJKLMNPQRSTWXYZ'
const CHARS_UPPER = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

const array = new Uint8Array(10)
const ratio = passwordSet.length / 255
getRandomValues(array)
// Fallback: generate password based on sharing policy from capabilities
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a fallback needed? I think this will only cause problems down the line when the implementations in the frontend and backend get out of sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Randomly generated password not complying with external sharing password policy

3 participants