简体   繁体   English

具有Windows身份验证的NancyFX自托管

[英]NancyFX Self Hosting with Windows Authentication

I am setting up a website using a static front end of HTML/Javascript that uses angularjs to call into a NancyFx web service that is self hosted inside a Window service. 我正在使用HTML / Javascript的静态前端建立一个网站,该前端使用angularjs调用自托管在Window服务内部的NancyFx Web服务。 I have a reverse proxy between the front end the Window service for the service call. 我在服务调用的Window服务的前端之间有一个反向代理。 I have enabled IIS to use windows authentication. 我已启用IIS以使用Windows身份验证。 My question is, what is the correct way to get the windows authentication information to be passed into the web service? 我的问题是,使Windows身份验证信息传递到Web服务的正确方法是什么?

I have looked at other examples like the following: http://www.scriptscoop.com/t/7a0174e5fd64/self-hosted-owin-nancyfx-service-with-windows-authentication-example.html but when I access Thread.CurrentPrincipal the identity information is not filled out. 我看过其他类似如下的示例: http : //www.scriptscoop.com/t/7a0174e5fd64/self-hosted-owin-nancyfx-service-with-windows-authentication-example.html,但是当我访问Thread.CurrentPrincipal时身份信息未填写。

Based on this gist by damianh the property containing the user identity is different. 基于damianh的要旨 ,包含用户身份的属性是不同的。 In the gist they access the identity within a module using 根据要点,他们使用以下命令访问模块内的身份

var env = ((IDictionary<string, object>)Context.Items[Nancy.Owin.NancyOwinHost.RequestEnvironmentKey]);
var user = (IPrincipal)env["server.User"];

I have not tried it yet. 我还没有尝试过。 Let us know if it works for you. 让我们知道它是否适合您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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