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(core): Refactor how permissions get serialized for sessions into using a new strategy #3222

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

DanielBiegler
Copy link
Contributor

@DanielBiegler DanielBiegler commented Nov 20, 2024

⚠️ PROOF OF CONCEPT ⚠️

This is a proof of concept for #3095

Description

Since this is WIP and theres no UI updates, you gotta update your DB manually to use the new ChannelRole Entity by inserting rows.

Breaking changes

Nothing should change with the default strategy but once you use the new strategy there is a breaking change. This makes this feature opt-in for people that are interested in multi-vendor setups.

Screenshots

You can add screenshots here if applicable.

ToDo

  • Can use UI for updating admins
  • See if we can insert the new entity only if the new strategy is enabled. Currently its hardcoded in the core entities.
  • New UI dropdown depending on the strategy, on admin creation and update page
  • Fix remaining TODO comments
  • Migration
  • Docs
  • Tests for new strategy

Checklist

📌 Always:

  • I have set a clear title
  • My PR is small and contains a single feature
  • I have checked my own PR

👍 Most of the time:

  • I have added or updated test cases
  • I have updated the README if needed

Copy link

vercel bot commented Nov 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview Dec 1, 2024 1:06pm

import { UserChannelPermissions } from '../../service/helpers/utils/get-user-channels-permissions';

/**
* @description TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

/**
 * @description
 * A RolePermissionResolverStrategy defines how role-based permissions for a user should be resolved.
 * This strategy is used to determine the permissions assigned to a user based on their roles per channel.
 *
 * By default {@link DefaultRolePermissionResolverStrategy} is used. However, for more complex environments using
 * multiple channels and roles {@link ChannelRolePermissionResolverStrategy} is recommended.
 * 
 * :::info
 *
 * This is configured via the `authOptions.rolePermissionResolverStrategy` properties of your VendureConfig.
 *
 * :::
 *
 * @docsCategory auth
 * @since 3.3.0
 */

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like it, thanks. 👍 Will add comments once we finalize the PR and everything is set.

…ResolverStrategy`

We need UI for the selection of channels but for the POC it will simply assign the default channel.
Also moved emitting of events to the end of admin-update function so
that a failure from updating custom field relations doesnt lead to wrong behavior of event handlers.
Copy link

sonarcloud bot commented Dec 1, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
9.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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.

2 participants