Skip to content

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

Open
@VasuInukollu

Description

@VasuInukollu

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

namespace Microsoft.AspNetCore.Routing;

public static class IdentityApiEndpointRouteBuilderExtensions
{

    public static IEndpointConventionBuilder MapIdentityApi<TUser>(this IEndpointRouteBuilder endpoints)

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

}

Usage Examples

We can add the required mapping for each endpoint.

app.MapIdentityLoginApi<IdentityUser>();
app.MapIdentityRefreshApi<IdentityUser>();

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-identityIncludes: Identity and providersenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-identity-apis

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions