authentication
Skill5 starsChanged 6 days agoMITView on GitHub
JWT bearer auth, ASP.NET Identity, OIDC, and policy-based authorization patterns for ASP.NET Core APIs.
20 other projects use a version of this.
Adopted by
Most recently taken up by
- codewithmukesh/dotnet-claude-kittheir own version, first seen Nov 8, 2026
- psubramanian/Claude-Skillstheir own version, first seen Oct 13, 2026
- thienqo/ios-skillstheir own version, first seen Oct 11, 2026
- Resgrid/Coretheir own version, first seen Oct 8, 2026
- latitude-dev/latitude-llmtheir own version, first seen Oct 8, 2026
- BuilderIO/agent-nativetheir own version, first seen Oct 8, 2026
Used with
Projects with it also use monitoring, openapi and 2 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
rogue-dev-studioSkillmonitoring
Claude monitoring and usage tracking tools (UV, claude-monitor, claude-usage-cli). Use when the project needs this capability or the user / team manifest asks for it. Use for specialized `monitoring` work when listed in TEAM.yaml or explicitly requested.
Also in 3 projects that use this
ffsshhttiikkSkillopenapi
OpenAPI/Swagger specification and documentation
Also in 3 projects that use this
VercelSkillmessaging
Use when turning settled positioning into the lines other people will reuse: the message hierarchy, value propositions per audience, objection handling, and the proof behind each claim.
Also in 3 projects that use this
JohnJBorenSkillci-cd
CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies
Also in 4 projects that use this
Other versions20 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 20
- BuilderIO/agent-native★ 7.6ksame name
- latitude-dev/latitude-llm★ 4.7ksame name
- codewithmukesh/dotnet-claude-kit★ 808same name
- Resgrid/Core★ 238same name
- microsoft/awesome-rayfin★ 108same name
- nahid-sparktales/agent-dispatcher★ 59same name
- autosendhq/email-skills★ 18same name
- CheehooLabs/SpureeSkills★ 18same name
- pluginagentmarketplace/custom-plugin-backend★ 4same name
- thienqo/ios-skills★ 4same name
10 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository15 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- aspnet-api-patternsSkill
- cachingSkill
- clean-architectureSkill
- convention-learnerSkill
- dddSkill
- dotnet-project-initSkill
- ef-core-patternsSkill
- error-handlingSkill
- loggingSkill
- modern-csharpSkill
- opentelemetrySkill
- resilienceSkill
- testing-dotnetSkill
- vertical-sliceSkill
The file
Files
Authentication & Authorization Patterns
Reference for securing ASP.NET Core APIs. Covers JWT bearer, ASP.NET Identity, OIDC, policy-based authorization, and resource-based authorization.
Quick Decision Guide
| Scenario | Approach |
| API consumed by SPAs or mobile apps with an external IdP | JWT Bearer |
| Server-rendered app with local user accounts + roles | ASP.NET Identity |
| Federated login (Google, Entra ID, Keycloak) | OIDC + AddOpenIdConnect |
| Fine-grained permissions beyond roles | Policy-based + IAuthorizationHandler |
| Resource ownership check (user can only edit their own order) | Resource-based authorization |
Required Pipeline Order
// Order matters — authentication must run before authorization
app.UseAuthentication(); // sets HttpContext.User
app.UseAuthorization(); // evaluates policiesReferences
Load only the file the task needs:
| File | Covers |
references/jwt-bearer.md | AddJwtBearer against an IdP; symmetric-key validation for internal services without one |
references/aspnet-identity.md | Database-backed users and roles with ASP.NET Identity |
references/oidc.md | AddOpenIdConnect with an external provider |
references/authorization.md | Registering and applying policies; resource-based IAuthorizationHandler (requirement, handler, endpoint usage) |
references/claims-and-schemes.md | Reading claims from HttpContext.User; multi-scheme authentication |
Do / Don't
| Do | Don't |
Set ClockSkew = TimeSpan.Zero | Allow the default 5-minute token expiry grace period in production |
Validate both iss and aud | Disable issuer or audience validation for convenience |
Use FallbackPolicy to require auth by default | Rely on [Authorize] placement — it's easy to forget |
| Use policy-based authorization for permissions | Hard-code role strings in [Authorize(Roles = "...")] throughout controllers |
| Use resource-based authorization for ownership checks | Put ownership logic inside domain services |
Pick one claim-name scheme: raw names (MapInboundClaims = false + NameClaimType/RoleClaimType) or ClaimTypes.* | Mix "sub" lookups with ClaimTypes.NameIdentifier lookups — one of them returns null |
| Store permissions as claims in the token | Re-query the DB for permissions on every request |
Use RequireAuthenticatedUser() as fallback policy | Open all endpoints and add [Authorize] selectively |
AllowAnonymous() on health check / public endpoints | Forget to exempt health endpoints from the fallback policy |
See Also
skills/error-handling/SKILL.md—TypedResults.Forbid()and mapping auth failures to ProblemDetailsskills/aspnet-api-patterns/SKILL.md— endpoint conventions for protected routes
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

