dotnet / dotnet/aspnetcore

Split MapIdentityApi<TUser>() into multiple APIs and allow selective end points to be enabled

Open
#55,792 2 comments 13 reactions 0 assignees View on GitHub
api-suggestion area-identity enhancement feature-identity-apis
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

## Background and Motivation

The Identity API endpoints are a much need addition to Identity framework. The current API endpoint route implementation (IdentityApiEndpointRouteBuilderExtensions.cs) has a single API to add all/multiple endpoints to the pipeline.

It would great to have control on which endpoints will be available if we don't want to have some functionality in the application.

A way to allow individual API endpoints to be added will help in plenty of scenarios.

## Proposed API

```diff
namespace Microsoft.AspNetCore.Routing;

public static class IdentityApiEndpointRouteBuilderExtensions
{

public static IEndpointConventionBuilder MapIdentityApi(this IEndpointRouteBuilder endpoints)

+ public static IEndpointConventionBuilder MapIdentityRegisterApi(this IEndpointRouteBuilder endpoints)
+ public static IEndpointConventionBuilder MapIdentityLoginApi(this IEndpointRouteBuilder endpoints)
+ public static IEndpointConventionBuilder MapIdentityRefreshApi(this IEndpointRouteBuilder endpoints)

}
```

## Usage Examples

We can add the required mapping for each endpoint.

```csharp

app.MapIdentityLoginApi();
app.MapIdentityRefreshApi();

```

## Alternative Designs

We have the option of adding the full code from this URL into the project and remove the unwanted parts. But that's not a great experience.

https://github.com/dotnet/aspnetcore/blob/main/src/Identity/Core/src/IdentityApiEndpointRouteBuilderExtensions.cs

## Risks

Nothing that I can think of.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.