.agents/skills/aspnet-identity/SKILL.md
ASP.NET Core Identity for authentication, roles, claims, and external providers. Covers Identity setup, customization, and token-based auth. USE WHEN: user mentions "ASP.NET Identity", "user authentication", ".NET auth", "roles and claims", "Identity scaffolding", "external login providers" DO NOT USE FOR: JWT-only auth without Identity, Spring Security - use `spring-security`
npx skillsauth add d-subrahmanyam/deno-fresh-microservices aspnet-identityInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Deep Knowledge: Use
mcp__documentation__fetch_docswith technology:aspnet-corefor Identity documentation.
// Program.cs
builder.Services.AddIdentity<ApplicationUser, IdentityRole>(options =>
{
options.Password.RequireDigit = true;
options.Password.RequiredLength = 12;
options.Password.RequireNonAlphanumeric = true;
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(15);
options.Lockout.MaxFailedAccessAttempts = 5;
options.User.RequireUniqueEmail = true;
})
.AddEntityFrameworkStores<AppDbContext>()
.AddDefaultTokenProviders();
public class ApplicationUser : IdentityUser
{
public string FirstName { get; set; } = default!;
public string LastName { get; set; } = default!;
public DateTime CreatedAt { get; set; }
}
public class AuthService
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly SignInManager<ApplicationUser> _signInManager;
public async Task<IdentityResult> RegisterAsync(RegisterRequest request)
{
var user = new ApplicationUser
{
UserName = request.Email,
Email = request.Email,
FirstName = request.FirstName,
LastName = request.LastName,
};
return await _userManager.CreateAsync(user, request.Password);
}
public async Task<SignInResult> LoginAsync(LoginRequest request)
{
return await _signInManager.PasswordSignInAsync(
request.Email, request.Password, request.RememberMe, lockoutOnFailure: true);
}
}
// Seed roles
using var scope = app.Services.CreateScope();
var roleManager = scope.ServiceProvider.GetRequiredService<RoleManager<IdentityRole>>();
foreach (var role in new[] { "Admin", "User", "Manager" })
{
if (!await roleManager.RoleExistsAsync(role))
await roleManager.CreateAsync(new IdentityRole(role));
}
// Assign role
await _userManager.AddToRoleAsync(user, "Admin");
// Controller
[Authorize(Roles = "Admin")]
public IActionResult AdminPanel() => Ok();
// Policy-based
builder.Services.AddAuthorization(options =>
{
options.AddPolicy("RequireAdmin", policy => policy.RequireRole("Admin"));
options.AddPolicy("MinAge", policy =>
policy.RequireClaim("DateOfBirth")
.RequireAssertion(ctx =>
{
var dob = DateTime.Parse(ctx.User.FindFirst("DateOfBirth")!.Value);
return DateTime.Today.Year - dob.Year >= 18;
}));
});
builder.Services.AddAuthentication()
.AddGoogle(options =>
{
options.ClientId = builder.Configuration["Auth:Google:ClientId"]!;
options.ClientSecret = builder.Configuration["Auth:Google:ClientSecret"]!;
})
.AddMicrosoftAccount(options =>
{
options.ClientId = builder.Configuration["Auth:Microsoft:ClientId"]!;
options.ClientSecret = builder.Configuration["Auth:Microsoft:ClientSecret"]!;
});
| Anti-Pattern | Why It's Bad | Correct Approach |
|--------------|--------------|------------------|
| Custom password hashing | Insecure | Use Identity's PasswordHasher<T> |
| Storing plain-text passwords | Security risk | Identity hashes automatically |
| No account lockout | Brute-force vulnerable | Enable lockout options |
| Roles in JWT claims only | Not enforced server-side | Validate from store |
| Issue | Likely Cause | Solution |
|-------|--------------|----------|
| Login always fails | Wrong password config | Check PasswordOptions |
| User not found | Case sensitivity | Identity is case-insensitive by default |
| Token expired | Short token lifetime | Adjust TokenLifespan |
| External login redirect fails | Wrong callback URL | Check provider's redirect URIs |
development
Guidelines for building high-performance APIs with Fastify and TypeScript, covering validation, Prisma integration, and testing best practices
development
FastAPI modern Python web framework. Covers routing, Pydantic models, dependency injection, and async support. Use when building Python APIs. USE WHEN: user mentions "fastapi", "pydantic", "async python api", "python rest api", asks about "dependency injection python", "python openapi", "python swagger", "async endpoints", "python api validation", "fastapi middleware" DO NOT USE FOR: Django apps - use `django` instead, Flask apps - use `flask` instead, synchronous Python APIs without type hints, GraphQL-only APIs
tools
FastAPI integration testing specialist. Covers synchronous TestClient, async httpx AsyncClient, dependency injection overrides, auth testing (JWT, OAuth2, API keys), WebSocket testing, file uploads, background tasks, middleware testing, and HTTP mocking with respx, responses, and pytest-httpserver. USE WHEN: user mentions "FastAPI test", "TestClient", "httpx async test", "dependency override test", "respx mock", asks about testing FastAPI endpoints, authentication in tests, or HTTP client mocking. DO NOT USE FOR: Django - use `pytest-django`; pytest internals - use `pytest`; Container infrastructure - use `testcontainers-python`
development
Expert in FastAPI Python development with best practices for APIs and async operations