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

Fetch default privacy scopes and set properties appropriate #1048

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bjalbor
Copy link

@bjalbor bjalbor commented Feb 7, 2025

Fetch default values for privacy scopes and use these for user provisioning instead of always take 'v2-local' which will reveal sensitive information on default (closes #1047)

@bjalbor bjalbor force-pushed the feat/1047/user-provisioning-privacy-scopes branch 2 times, most recently from 5274df5 to c1dd620 Compare February 7, 2025 13:26
…stead of using 'v2-local' (closes nextcloud#1047)

Signed-off-by: Björn Bores <[email protected]>
@bjalbor bjalbor force-pushed the feat/1047/user-provisioning-privacy-scopes branch from c1dd620 to 9aabd12 Compare February 7, 2025 13:43
@bjalbor
Copy link
Author

bjalbor commented Feb 7, 2025

I had to force-push because I somehow missed to check if a default value for BIRTHDAY is already available for using in case of gender (which is - like PRONOUNS - not availible before NC v31). Sorry for that.

Copy link
Member

@julien-nc julien-nc left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this PR!

A few minor change requests and we're good to go.

@@ -227,7 +231,7 @@ public function provisionUser(string $tokenUserId, int $providerId, object $idTo
$this->eventDispatcher->dispatchTyped($event);
$this->logger->debug('Phone mapping event dispatched');
if ($event->hasValue()) {
$account->setProperty('phone', $event->getValue(), $scope, '1', '');
$account->setProperty('phone', $event->getValue(), $defaultScopes[\OCP\Accounts\IAccountManager::PROPERTY_PHONE] ?? $fallbackScope, '1', '');
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$account->setProperty('phone', $event->getValue(), $defaultScopes[\OCP\Accounts\IAccountManager::PROPERTY_PHONE] ?? $fallbackScope, '1', '');
$account->setProperty('phone', $event->getValue(), $defaultScopes[IAccountManager::PROPERTY_PHONE] ?? $fallbackScope, '1', '');

IAccountManager is imported, you don't need the full class path.

Comment on lines +156 to +157
$defaultScopes = array_merge(AccountManager::DEFAULT_SCOPES,
$this->config->getSystemValue('account_manager.default_property_scope', []));
Copy link
Member

@julien-nc julien-nc Feb 10, 2025

Choose a reason for hiding this comment

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

Suggested change
$defaultScopes = array_merge(AccountManager::DEFAULT_SCOPES,
$this->config->getSystemValue('account_manager.default_property_scope', []));
$defaultScopes = array_merge(
AccountManager::DEFAULT_SCOPES,
$this->config->getSystemValue('account_manager.default_property_scope', []) ?? [],
);

The ?? [] will fix the PhpUnit tests (I'm not sure why they fail).

@julien-nc
Copy link
Member

If you rebase on the main branch, you'll get rid of one Psalm issue (UndefinedConstant: Constant OCP\Accounts\IAccountManager::PROPERTY_FEDIVERSE is not defined).

The other one (UndefinedClass: Class, interface or enum named OC\Accounts\AccountManager does not exist) I can fix later.

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.

Provisioning of new users doesn't take default/configured privacy scopes into account
2 participants