开发者

Implementing Security for Rss Feeds

开发者 https://www.devze.com 2022-12-22 06:16 出处:网络
A)I want to be able to support password protection of my RSS feeds through the following authentication methods:

A)I want to be able to support password protection of my RSS feeds through the following authentication methods:

HTTP Basic Integrated Windows (NTLM/Kerberos) Digest

1)How can i do that in asp.net mvc

B) Reading over the RSS 2.0 specification, I saw nothing related to security, so I assume that security implemented for the RSS feed is handled on one end by the web server handling the HTTP request for the RSS feed, and on the other end by the client requesting access to the RSS feed. The client should collect a user name and password, and put that information into the request to the server. I'm curious to know how (or if) sites like UserLand, or ASP.NET Weblogs offer password protected RSS feeds, and on the other side 开发者_运维百科of the fence, how are RSS aggregators like NewsGator, NewzCrawler, SharpReader, etc. handling password protected RSS feeds?


RSS does not have any security built in. You can harness ASP.NET MVC by creating a custom ActionResult, which can provide authentication, this is with forms authentication, but you can see the idea.

public class RssActionResult : ActionResult
{
    public SyndicationFeed Feed { get;set; }

    public override void ExecuteResult(ControllerContext context)
    {
        if (context.HttpContext.Current.User.Identity.IsAuthenticated)
        {
            context.HttpContext.Response.ContentType = "application/rss+xml";
            Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(Feed);
            using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output))
            {
                rssFormatter.WriteTo(writer);
            }
        }
        else
        {
            //Whatever, not authenticated
        }
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号