Scaffold Identity Api Endpoints in .NET 8

problem

The Identity implementation in .NET8 adds a new functionality called MapIdentityApi, which allows the developer to use a set of preconfigured endpoints for authorization management.

The problem is that we might want to customize the functionality of those endpoints, or even remove the ones which we are not planning to use.

solution

We can scaffold the implementation into our solution from the official AspNetCore repository on Github by simply copying the implementation into our own project, then renaming the class to something different from MapIdentityApi (eg. MapCustomizedIdentityApi) in order to avoid naming conflicts.

After that we call our extension method inbetween building the web application and running it:

var app = builder.Build();

app.MapCustomizedIdentityApi<IdentityUser>();

app.Run();

Now we have full control over the implementation of those endpoints.

Gravatar
Author: Cristi Jugaru
Last Edit: July 27, 2024
1 Thanks received
Last Edit July 27, 2024
Created July 27, 2024
Views 41
Tags
ASP.NET

Join us!

Do you like this website?

Bookmark it and come back here to write a post yourself when you run into something shareable.

Early collaborators will get to own a part of the project (5 to 20%)... >> read more

Your Comment

Feel free to post additional info or improvement suggestions.
preview
Optional, never shown, displays gravatar.

Formatting Tips

This editor uses Markdown to easily add code in your posts.

Triple backticks for full line(s) of code (or indent 4 spaces)

```
let foo = 'bar';
```

[link text](http://a.com)

*italic* **bold**

More Tips