简体   繁体   中英

How to pass windows Identity from angular app to asp.net core 2.0 webapi hosted on Linux server

I have an asp.net core web api running on Linux server (using PCF cloud). I want to pass user credential from angular app to this web api. I tried with angular option withCredentials = true but it is not passing user windows login id.

on Asp.net Core web api, I tried multiple options like

Context.User.Identity.Name
Environment.Username
_httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value

but nothing seems to be working. I tried finding it out on google but no luck. followed this url to setup but it is also not working...

https://www.koskila.net/how-to-get-current-user-in-asp-net-core/

If I run services locally on windows machine then everything works fine and I can get userid in my web api. I also tried hosting this asp.net core web api on Windows server IIS and it is also working fine.

The only issue comes when I host my service on PCF Linux box. I can understand Linux will not support the concept of Windows identity but is there any way I can pass just username with domain to asp.net core on Linux, I don't need full windows identity, just username will do.

Yes, and no at the same time. To support Windows authentication you need to be in the same domain and your OS can be able to pass creds to the web server (it should support this auth type).

There is nothing related to the UI. If you will try it locally you will find a lot of requests behind the scene that a really authenticate you.

I know that most of the popular web servers can do this with a lot of configuration, like keys import and you can't do this without changes in AD.

I think you need something like this https://www.axians-infoma.de/techblog/windows-authentication-in-docker-containers-just-got-a-lot-easier/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM