/abp-sensei:abp-authorizationfrom ABP Sensei
Covers ABP Framework v10.x (10.4–10.6) authorization: defining permissions in PermissionDefinitionProvider, using [Authorize], CheckPolicyAsync, IsGrantedAsync, IPermissionManager, CurrentUser, resource-based auth, and multi-tenancy permissions. Use when implementing role, permission, or access checks in ABP.
Ships in ABP Sensei. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
User asks about permissions, authorization, roles, policies, permission groups, resource-based authorization, or access control in ABP Framework.
ABP extends ASP.NET Core Authorization with a Permission System that auto-registers permissions as policies. Two permission types exist:
Create a class inheriting PermissionDefinitionProvider:
using Volo.Abp.Authorization.Permissions;
namespace Acme.BookStore.Permissions
{
public class BookStorePermissionDefinitionProvider : PermissionDefinitionProvider
{
public override void Define(IPermissionDefinitionContext context)
{
var myGroup = context.AddGroup(
"BookStore",
LocalizableString.Create<BookStoreResource>("BookStore")
);
myGroup.AddPermission(
"BookStore_Author_Create",
LocalizableString.Create<BookStoreResource>("Permission:BookStore_Author_Create")
);
}
}
}
Application.Contracts projectcontext.AddGroup("GroupName") creates a new groupLocalizableString.Create<TResource>("Key") for localized display namesmyGroup.AddPermission(
"BookStore_Books_Manage",
LocalizableString.Create<BookStoreResource>("Permission:ManageBooks"),
multiTenancySide: MultiTenancySides.Tenant // Host, Tenant, or Both (default)
);
Multi-tenancy side options:
MultiTenancySides.Host — Available only on host sideMultiTenancySides.Tenant — Available only on tenant sideMultiTenancySides.Both (default) — Available on bothPermissions can have parent-child relationships for hierarchical UI display:
var booksPermission = myGroup.AddPermission("BookStore_Books_Manage");
booksPermission.AddChild("BookStore_Books_Create");
booksPermission.AddChild("BookStore_Books_Edit");
booksPermission.AddChild("BookStore_Books_Delete");
myGroup.AddPermission("BookStore_Feature", isEnabled: false); // Disabled by default
// Depending on Features
myGroup.AddPermission("BookStore_Advanced")
.WithFeatureDependency("AdvancedFeature");
// Depending on Global Features
myGroup.AddPermission("BookStore_Preview")
.WithGlobalFeatureDependency("PreviewModule");
// Custom condition
myGroup.AddPermission("BookStore_Special")
.WithStateChecker(() => MyStaticChecker.IsSpecialEnabled);
myGroup.AddPermission("BookStore_Special")
.WithPolicyDependency(new MyCustomPolicyRequirement());
[DependsOn(typeof(AbpIdentityModule))]
public class MyModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<PermissionDefinitionContext>(options =>
{
// Modify identity module permissions before they're finalized
});
}
}
[Authorize("BookStore_Author_Create")]
public async Task<IActionResult> CreateAsync(CreateAuthorDto input)
{
// ...
}
public class AuthorAppService : ApplicationService, IAuthorAppService
{
public async Task<AuthorDto> CreateAsync(CreateAuthorDto input)
{
await AuthorizationService.CheckAsync("BookStore_Author_Create");
// or
if (!await AuthorizationService.IsGrantedAsync("BookStore_Author_Create"))
{
throw new AbpAuthorizationException("...");
}
// ...
}
}
public class MyService : ITransientDependency
{
private readonly IAuthorizationService _authorizationService;
public MyService(IAuthorizationService authorizationService)
{
_authorizationService = authorizationService;
}
public async Task DoWorkAsync()
{
await _authorizationService.CheckAsync("BookStore_Author_Create");
}
}
Shortcut methods in base classes:
await CheckPolicyAsync("...")(throws an exception if not granted) andawait IsGrantedAsync("...")(returns a bool, does not throw).
Authenticated user information is accessed via the CurrentUser property — it is available out of the box in base classes (ApplicationService, DomainService, AbpController) and requires no injection:
public class BookAppService : ApplicationService
{
public async Task DoSomethingAsync()
{
var userId = CurrentUser.Id; // Guid?
var userName = CurrentUser.UserName;
var email = CurrentUser.Email;
var isAuth = CurrentUser.IsAuthenticated;
var roles = CurrentUser.Roles;
var tenantId = CurrentUser.TenantId;
}
}
// Inject ICurrentUser in services that don't derive from a base class
public class MyService : ITransientDependency
{
private readonly ICurrentUser _currentUser;
public MyService(ICurrentUser currentUser) => _currentUser = currentUser;
}
public async Task UpdateMyBookAsync(Guid bookId, UpdateBookDto input)
{
var book = await _bookRepository.GetAsync(bookId);
if (book.CreatorId != CurrentUser.Id)
{
throw new AbpAuthorizationException();
}
// update...
}
Security: never trust client input for the user identity — always use
CurrentUserand verify ownership inside the application service.
For fine-grained, per-instance permissions:
// Define a resource permission
var booksGroup = context.AddGroup("BookStore_Books");
var bookPermission = booksGroup.AddResourcePermission(
"BookStore_Books_Edit",
typeof(Book),
LocalizableString.Create<BookStoreResource>("Permission:EditBook")
);
Resource-based permissions are managed through the Resource Permission Management Dialog on individual resource instances (not the global permissions dialog).
See: Resource-Based Authorization
ISettingManager or the Identity module UIModuleName_Entity_Action (e.g., BookStore_Books_Create)LocalizableString.Create<TResource>()var books = myGroup.AddPermission("BookStore_Books_Manage");
books.AddChild("BookStore_Books_Create");
books.AddChild("BookStore_Books_Edit");
books.AddChild("BookStore_Books_Delete");
books.AddChild("BookStore_Books_ViewList");
public abstract class BookStoreAppService : ApplicationService
{
protected BookStoreAppService()
{
LocalizationResource = typeof(BookStoreResource);
}
protected virtual async Task CheckPolicyAsync(string policyName)
{
await AuthorizationService.CheckAsync(policyName);
}
}
ABP replaces ASP.NET Core Identity's default DataProtectorTokenProvider with AbpDefaultTokenProvider, and LinkUserTokenProvider uses the same single-active infrastructure. Tokens are now single-active per user/purpose: generating a new token invalidates the previous one. Default lifetime is 10 minutes:
Configure<AbpDefaultTokenProviderOptions>(options =>
{
options.TokenLifespan = TimeSpan.FromMinutes(10);
});
Configure<AbpLinkUserTokenProviderOptions>(options =>
{
options.TokenLifespan = TimeSpan.FromMinutes(10);
});
After upgrading to 10.5, re-test login, two-factor, forced/periodic password change, and link-user flows. If a flow sends multiple tokens for the same purpose and expects older ones to stay valid, switch it to use only the latest token.
For client_credentials, password, and token-exchange grants, ABP can fall back to the client application's registered scopes when the request omits the scope parameter. Disabled by default:
Configure<AbpOpenIddictAspNetCoreOptions>(options =>
{
options.UseDefaultScopesForClientCredentials = true;
options.UseDefaultScopesForPassword = true;
options.UseDefaultScopesForTokenExchange = true;
});
After enabling, re-test token issuance for the affected grant types and confirm the resulting scopes/resources match authorization expectations.
ABP normalizes the user id claim issuer when generating and validating antiforgery tokens, and Razor Pages use ABP's antiforgery validation path. This fixes token mismatches when a token-authenticated SPA and cookie-authenticated MVC/Razor Pages share the same origin. Re-test mixed-auth flows after upgrading; opt out only if you intentionally rely on the issuer-specific identity:
Configure<AbpAntiForgeryOptions>(options =>
{
options.NormalizeUserIdClaimIssuer = false;
});
client_id after principal refresh (already-corrupted cookies self-heal) — fixes intermittent wrong ClientId values in audit logs.HttpContextAbpAccessTokenProvider forwards the incoming access token for any authenticated request, including client_credentials — re-test service-to-service calls that relied on the configured identity-client fallback.Claims in a token/cookie are frozen until re-authentication — a revoked role stays effective until re-login. The dynamic claims feature overrides the configured claim values with their latest values on each request. Disabled by default at the framework level, but enabled by default in startup templates since v8.0.
Enable it and add the middleware to every application that performs authentication (including the auth server):
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options =>
{
options.IsDynamicClaimsEnabled = true;
// Tiered solution (separate UI app): point to the auth server
options.RemoteRefreshUrl = configuration["AuthServerUrl"] + options.RemoteRefreshUrl;
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
//...
app.UseDynamicClaims(); // before UseAuthorization
app.UseAuthorization();
}
Contributors (IAbpDynamicClaimsPrincipalContributor, pre-built):
IdentityDynamicClaimsPrincipalContributor — Identity module; generates the actual dynamic claims and writes them to the distributed cache (auth server side)RemoteDynamicClaimsPrincipalContributor — tiered UI app; reads the distributed cache, falls back to an HTTP call to the auth server (RemoteRefreshUrl must be set)WebRemoteDynamicClaimsPrincipalContributor — same idea for microservice apps; opt-in via WebRemoteDynamicClaimsPrincipalContributorOptions.IsEnabledCustom contributor: implement IAbpDynamicClaimsPrincipalContributor and register it in DI — ContributeAsync runs on every HTTP request, so cache inside it.
Key options (AbpClaimsPrincipalFactoryOptions): IsDynamicClaimsEnabled, RemoteRefreshUrl (default /api/account/dynamic-claims/refresh), IsRemoteRefreshEnabled (the Identity module sets it to false, so remote contributors are not registered there), DynamicClaims (only listed claim types are overridden), ClaimsMap (auth-server↔client claim type mapping).
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub burakdmir/abp-skills --plugin abp-sensei26 skills in this plugin
/abp-aiABP Framework v10.x (10.4–10.6) AI integration: Microsoft.Extensions.AI (IChatClient), Semantic Kernel, Microsoft Agent Framework, AI Workspaces, AI Management module (Pro) with RAG, document indexing/chunking and MCP servers. Use when you need chat clients, AI agents, RAG or AI workspace management in ABP./abp-apiABP Framework v10.x (10.4–10.6) API development: Auto API Controllers, dynamic and static C#/JS client proxies, Swagger, API versioning, Integration Services. Use when you need a REST API, controller, dynamic proxy or client generation in ABP./abp-audit-loggingABP Framework v10.x (10.4–10.6) audit logging: AbpAuditingOptions, entity history, IAuditingStore, audit log storage and filtering. Use when configuring audit trails, audit logs, or entity history in ABP.Other plugins' skills for the same job