openiddict / openiddict/openiddict-documentation
Add comment about Cors config
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 106
- Forks
- 85
- Avg merge
- 1m
- Merged PRs (30d)
- 2
Description
Confirm you've already contributed to this project or that you sponsor it
- I confirm I'm a sponsor or a contributor
Describe the solution you'd like
It was quite impossible to figure out how to set a specific cors policy for Openiddict rather than open all endpoints to a permissive default policy.
Can't figure out where it belongs in docs though.
Program.cs:
//BEFORE host.UseCors();
host.Use((context, next) => {
if (!context.Request.Path.StartsWithSegments("/.well-known/openid-configuration")) return next(context);
if (context.GetEndpoint() is not null) return next(context);
context.SetEndpoint(new(null, new(new EnableCorsAttribute("MyCorsPolicyForOpeniddict")), null));
return next(context);
});
host.UseCors();
host.UseAuthentication();
The other endpoints are map-able, so that can be done via normal procedure. E.g.
app.MapPost("/connect/token", [EnableCorsAttribute("MyCorsPolicyForOpeniddict)] [AllowAnonymous] async (HttpContext context, ...) => ...);
Additional context
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the Program.cs CORS examples in the issue, including host.UseCors(), the discovery endpoint, and app.MapPost("/connect/token"). Locate the relevant OpenIddict documentation section and add a concise explanation of the specific-policy configuration; done means readers can distinguish the discovery endpoint setup from the normally mapped endpoints.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- authentication, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100