Open Closed

Replacing a dynamic claim contributor #7920


User avatar
0
aZee created
  • ABP Framework version: v8.2.3

Hello, can I replace IdentitySessionDynamicClaimsPrincipalContributor with my own implementation? If so, how can I do it?

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

2 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    Of course, you can replace it.

    for example:

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(IdentitySessionDynamicClaimsPrincipalContributor))]
    public class MyIdentitySessionDynamicClaimsPrincipalContributor : IdentitySessionDynamicClaimsPrincipalContributor
    {
        public override Task ContributeAsync(AbpClaimsPrincipalContributorContext context)
        {
            ....
            return base.ContributeAsync(context);
        }
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    aZee created

    Hello, thank you for your reply. However, I had to use the IServiceCollection.Replace method instead of Dependency attribute. Here's my working code : MyIdentitySessionDynamicClaimsPrincipalContributor.cs

    public class MyIdentitySessionDynamicClaimsPrincipalContributor : IdentitySessionDynamicClaimsPrincipalContributor
    {
        public override Task ContributeAsync(AbpClaimsPrincipalContributorContext context)
        {
            ...
        }
    }
    

    MyModule.cs

    public class MyModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            ...
            context.Services.Replace(
                ServiceDescriptor.Transient<
                	IdentitySessionDynamicClaimsPrincipalContributor,
                    MyIdentitySessionDynamicClaimsPrincipalContributor 
                >());
        }
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 21, 2026, 06:18
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.