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

Replace a Role Validator #2080

Closed
mmillican opened this Issue Nov 21, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@mmillican

mmillican commented Nov 21, 2018

I am trying to create a custom role validator to support pseudo-multi-tenancy (which I know is not officially supported in Identity) and am running into some issues.

I've verified that my validator does work and is being called. However, the default validator appears to be called also.

Here's my Identity service registration

services.AddIdentity<User, Role>(setup =>
    {
        // Redacted settings
    })
    .AddRoleValidator<CustomRoleValidator<Role>>()
    .AddEntityFrameworkStores<ApplicationDbContext>()
    .AddDefaultTokenProviders();

How can I remove the default RoleValidator?

@HaoK

This comment has been minimized.

Member

HaoK commented Nov 21, 2018

If you add a IRoleValidator<Role> before calling AddIdentity, it should skip adding the default one. Alternatively i believe you can remove service registrations directly as well, but try adding yours first

@mmillican

This comment has been minimized.

mmillican commented Nov 21, 2018

Thanks @HaoK! That did the trick.

I also had to change the unique index on the Roles table as well.

@mmillican mmillican closed this Nov 21, 2018

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