Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we integrate identityserver4 and web api in the same project(port) instead of creating different projects for each?

Couldn't configure the identityserver 4 authorization and bearer token authentication middleware in the same project.

like image 451
Shibu Tamang Avatar asked Jun 16 '19 16:06

Shibu Tamang


People also ask

What is Identity Server in Web API?

In this article IdentityServer is an authentication server that implements OpenID Connect (OIDC) and OAuth 2.0 standards for ASP.NET Core. It's designed to provide a common way to authenticate requests to all of your applications, whether they're web, native, mobile, or API endpoints.

What is API scope in IdentityServer4?

This value is used for authentication with introspection and will be added to the audience of the outgoing access token. DisplayName. This value can be used e.g. on the consent screen. Description.

What is API resource IdentityServer4?

The two fundamental resource types in IdentityServer are: identity resources: represent claims about a user like user ID, display name, email address etc… API resources: represent functionality a client wants to access.


3 Answers

It is now a built-in feature of Identityserver. Added with this PR.

services.AddLocalApiAuthentication();

And here is an official example of a protected API.

like image 71
d_f Avatar answered Oct 28 '22 17:10

d_f


I suggest you make API and Identity Server in separate apps. This makes it a lot easier to maintain.

Identity server provides you the authentication against your clients/API's. The database operations , the business logic should be handled by your clients/APIs . So keep them in separate apps should be a better choice .

If you insist on making them in single project , you can click here and here for code samples.

like image 35
Nan Yu Avatar answered Oct 28 '22 17:10

Nan Yu


You shouldn't.

The thing is that your authentication and your application are totally different services, with different scopes, and you should make them different.

This goes with Separation of Concern : if you want to change your auth service later, you won't have to modify your whole application.

like image 21
DoctorPrisme Avatar answered Oct 28 '22 17:10

DoctorPrisme