Skip to content
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

feat: Allow to configure different policies per password context #717

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Jan 18, 2025

The server already emits the events with password context information (new with Nextcloud 31), so this implements the support to configure different policies for different contexts.

For the reviewers: Please first check the backend stuff - if there is anything we need to adjust we should do this first before adjusting the frontend.

Summary

  • The validators and generator classes just got a new optional parameter for the password context
  • The config now supports the context parameter as well allowing to get different values for different contexts
    • The context specific values are saved with the context as the suffix in the app settings
  • The new policies are provided by the capabilities
    • No need to duplicate as initial state, so only access it via capabilities

Possible improvement

Maybe it would be easier to make the server enum backed with the string value.
That would remove 2 functions here and make some functions easier.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
* Add support for multiple password policies (per context)
* Split Vue files into components
* Use Typescript (also for the script part of Vue files)

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux force-pushed the feat/support-password-context branch from d87ea09 to f3d9920 Compare January 18, 2025 15:01
@susnux susnux changed the title Feat/support password context feat: Allow to configure different policies per password context Jan 18, 2025
public function getMinLength(): int {
return max(0, $this->appConfig->getValueInt(Application::APP_ID, 'minLength', 10));
public function getMinLength(?PasswordContext $context = null): int {
$key = $this->getScopedAppConfig('minLength', $context);
Copy link
Member

Choose a reason for hiding this comment

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

Do I get this right that there is now only the scoped policies and no longer one default policy? If we do that we should add a migration step for existing configs. Otherwise we could have a default policy and fall back to that if no custom one is configured

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is what is done, if e.g. there is no policy for sharing the default one is applied.

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

Successfully merging this pull request may close these issues.

Different share link password policy
2 participants