简体   繁体   English

向WCF服务添加身份验证

[英]Adding authentication to a WCF service

I'm trying to create a simple, authenticated, NuGet Feed over http, so I followed the steps pointed out in http://docs.nuget.org/docs/creating-packages/hosting-your-own-nuget-feeds . 我正在尝试通过http创建一个简单的,经过身份验证的NuGet Feed,因此我按照http://docs.nuget.org/docs/creating-packages/hosting-your-own-nuget-feeds中指出的步骤进行操作。 It works well, but I want the feed to require authentication, which supposedly is supported by the client. 它工作正常,但我希望提要要求身份验证,该身份可能受客户端支持。

When I added the NuGet.Server package to my brand new Asp.net MVC project, it added this route: 当我将NuGet.Server软件包添加到全新的Asp.net MVC项目中时,它添加了以下路线:

var factory = new DataServiceHostFactory();
var serviceRoute = new ServiceRoute("nuget", factory, typeof(Packages));
serviceRoute.Defaults = new RouteValueDictionary { { "serviceType", "odata" } };
serviceRoute.Constraints = new RouteValueDictionary { { "serviceType", "odata" } };
routes.Add("nuget", serviceRoute);

No configuration was changed. 没有更改配置。

This makes the URL http://{host}/nuget/Packages actually contain the feed with all the packages, but it is completely unauthenticated. 这样一来,URL http:// {host} / nuget / Package实际上包含具有所有程序包的提要,但是它完全未经身份验证。 I want to in some way, preferrably without adding 2 tons of XML, be able to hook into the pipeline for the Packages service (which I do not control) and perfomr some kind of authentication then. 我希望以某种方式(最好不要添加2吨XML)能够挂接到Packages服务(我不控制)的管道中,然后进行某种身份验证。 What is the (simplest) way of doing this? (最简单的)方法是什么?

Phil Haack has a blog post on implementing an Authorization Attribute for WCF. 菲尔·海克(Phil Haack)在博客文章中介绍了如何为WCF实现授权属性。 Hopefully that will point you in the right direction. 希望这将为您指明正确的方向。

http://haacked.com/archive/2011/10/19/implementing-an-authorization-attribute-for-wcf-web-api.aspx http://haacked.com/archive/2011/10/19/implementing-an-authorization-attribute-for-wcf-web-api.aspx

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

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