Search code examples
c#asp.net-coreactive-directoryidentityserver4windows-authentication

REST API using Windows authentication


I am implementing a REST Web API for a service that will be hosted on Windows now (and on Linux in the future).

We are going to support custom credentials + token/refresh token using OAuth 2.0 and OIDC (via Identity Server 4), but we want to support also Windows authentication to allow integration with Active Driectory.

For clients which use windows authentication, is it better to authenticate once and get token/refresh token mechanism (as we do for credentials authentication) or is it better to authenticate each single request?

The latter option might be less performant as it needs to go through the challange every time?


Solution

  • My personal feeling is that if you're having identityserver4 in play already and the fact you've stated you will host the API on Linux in future that you should handle the AD integration in your identity server and have your API only worry about access tokens issued by said service.

    I'd then recommend using ADFS (recent versions support OIDC out of the box) for the actual authentication of AD users and have your identity server act as an authentication gateway. If configured correctly you can achieve true SSO (i.e. the user is not required to re-enter their domain credentials) for any user already signed into the domain on their PC.

    This just covers authentication however - how will you be doing authorization within this API?