self-host ASP.NET Web API 2 owin with custom OAuth2

59 Views Asked by At

is there good sample of securing self-hosted web api 2 (.NET FRamework 4.8)by using some external OAuth2 server (based on IdentityServer4)?
use case:

  1. user try to access a method on controller (for example: api/values/get)
    but this controller's method requires the authorization
  2. Th user automatically be redirected to a web page where he could enter his username/password (this page belongs to external OAuth2 server)
  3. The OAuth2 server redirects back user to this controller's method (api/values/get)
  4. this method extract the token, returned by the external OAuth2 server
  5. use this token to make calls to another server that returns actual data
0

There are 0 best solutions below