MarimerLLC / cslaforum

Discussion forum for CSLA .NET
https://cslanet.com
Other
31 stars 6 forks source link

Windows Authentication with CSLA #700

Open coding786 opened 5 years ago

coding786 commented 5 years ago

As per the books, if windows authentication is enabled on Dataportal Server side, custom code needs to be written(on the specific platform) to assign Csla.ApplicationContext.User with the running prinicpal as csla will not fill in any principal to Csla.ApplicationContext.User. Is it correct ?

If above is correct, it means in context of asp.net core, we will need to assign Httpcontext.User to Csla.ApplicationContext.User. As my portal is windows authentication enabled on IIS, i think below code will work here, pls confirm,

Startup.cs :

services.Configure(options => { options.AutomaticAuthentication = true; });

Csla.ApplicationContext.User = some code to get HTTPContext.User;

Version and Platform CSLA version: 4.9 OS: Windows Platform: WinForms, WPF, ASP.NET Core

coding786 commented 5 years ago

can you reply on this ?

rockfordlhotka commented 5 years ago

ApplicationContext relies on providers to work correctly in different runtime environments.

The default provider for legacy ASP.NET uses HttpContext.Current.User.

The ASP.NET Core default provider uses HttpContext?.User. So as long as there is an HttpContext object available the CSLA User property simply returns the value from HttpContext.

This does require that your web project has referenced the CSLA-ASPNETCORE package.