ServiceStack with Windows Auth

63 Views Asked by At

I'm trying to integrate Windows AuthProvider with ServiceStack into a web app, particularly using NetCoreIdentityAuthProvider. It works if the IdClaimTypes property is valued with a list that contains the 'name' claim instead of the 'nameidentifier' claim because otherwise I have the error that specifies that the 'nameidentifier' claim does not exist. What is the reason for this behavior?

1

There are 1 best solutions below

1
Fengzhi Zhou On

In my test and research , the NetCoreIdentityAuthProvider is designed mainly for asp.net core identity and ServiceStack doesn't have a built-in Windows Auth Provider for .NET Core. It allows for a high degree of customization and the code https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack/Auth/NetCoreIdentityAuthProvider.cs is commented too :

public List<string> IdClaimTypes { get; set; } = new() {
            ClaimTypes.NameIdentifier, //ASP.NET Identity default
            "sub",                     //JWT User
        };

Windows Authentication works differently , it relies on the Windows account system rather than an application-specific user database and needs custom mapping or configuration for nameidentifier in IdClaimTypes in your application .