C#C
C#3w ago
Giuseppe

Setup of Mixed-Authentication WebApi

Hi all!
I was asked at work to start a new WebApi project, where authentication should work in "two layers":
  • 1° Software authentication [Done by cookie]: Where the client tell us which is the software trying to contact us
    • 2° User authentication [WindowsAuth / Negotiate]: Where the client tell us who's the user trying to contact us
(don't ask me why they made those decisions)

Authentication Flow:
  • Client authenticates itself (so our webapi checks if the credentials given match the ones in a specific table)
  • User authenticates itself by an authenticated client (so with the claim generated by negotiate we get the domain user and we check if the user is present/enabled in another table)
First question, can those two coexist in the same request? (Since its the mechanism i need)

I started the project by creating more authorization policies where each one applied a specific authentication scheme, but i had problems when setting the defaultScheme

Second question, what's the difference between Policies and Filters?

Third question, am i following the optimal path?
Was this page helpful?