Authentication between Projects in .net core

Viewed 370

I am trying to build multi layered web app, users can access via google auth or ldap acc.

It has:

  • Core Layer (Library - All models)
  • Data Access Layer (Library)
  • Business Logic Layer (Library)
  • API Layer (.Net Core Web API)
  • Web Layer (.Net Core MVC Project)

When a user login into the web site, I have to use same authentication both MVC and API.

Should I use aspnet identity for login (with auto generated user db), how can pass the authentication to API project?

Or is there a way when google aut or ldap login is successful then I can create Bearer token (or something like that) and use it both MVC and API projects as authenticated login?

PS: I work on .net core 2.2

1 Answers

You need some way to share the session between to two. To prevent users from accessing your API on their own, consider making a single "user" that your MVC runs as, and only authenticate that user with your api.

Thus

User -> MVC -> API

Related