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

Create system roles by default #17341

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Create system roles by default #17341

wants to merge 7 commits into from

Conversation

hishamco
Copy link
Member

@hishamco hishamco commented Jan 12, 2025

Fixes #17271

@hishamco hishamco marked this pull request as draft January 12, 2025 04:40
@MikeAlhayek
Copy link
Member

@hishamco I know this is a draft. But I think you are missing the ask. Not all these roles are system role. There are currently only 3 system roles. Administration (this name could be changed), Anonymous, and Authorized.

You should inject ISystemRolePrpvider to get a list of the system roles.

In the roles module, create a SystemRolesMigrations file that would read the system roles from the provider and create them using the RoleManager. Then you can remove only these 3 roles from the recipes.

@hishamco
Copy link
Member Author

Thanks it is still a draft, I added the system roles first, then added the rest accidentally

Using the provider is much better, I will react to your feedback

@hishamco
Copy link
Member Author

@MikeAlhayek I didn't see a description there, or shall we make ISystemRoleProvider instead of ISystemRoleNameProvider?

@hishamco hishamco marked this pull request as ready for review January 13, 2025 00:08
@hishamco hishamco requested a review from MikeAlhayek January 13, 2025 00:13
@hishamco
Copy link
Member Author

I tried the PR on a fresh installation and it works fine but I don't know why it fails in Linux


public async Task<int> CreateAsync()
{
var systemRoles = await _systemRoleNameProvider.GetSystemRolesAsync();
Copy link
Member

Choose a reason for hiding this comment

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

I am wondering if there is a raise condition somewhere.

Try implementing this logic using recipe step instead. You could do the same thing using IFeatureEventHandler

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean calling RoleStep inside the data migration? If yes the RecipeExecutionContext will be missing, we could find a way to pass it in but it will become more complicated

Copy link
Member Author

Choose a reason for hiding this comment

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

I figure out there're roles in the test recipe :)

@hishamco hishamco requested a review from MikeAlhayek January 13, 2025 05:29
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.

Create System roles by default
2 participants