Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create password protected RSS feed in rails

Creating RSS feed in rails is easy. I need a simple way to password protect the RSS feed. I am thinking http basic authentication.

I googled but could not find any article about creating password protected RSS.

like image 654
Roger Avatar asked Feb 28 '23 21:02

Roger


1 Answers

I have this in my ApplicationController

def xml_authorize
  if request.format == Mime::XML
    authenticate_or_request_with_http_basic do |username, password|
      username == 'foo' && password == 'bar'
    end
  end
end

Then I just apply a before_filter :xml_authorize to the actions that I want to password protect for XML requests only, but still want to serve normally with html.


Here's where I got the inspiration from.

like image 124
Blaine Lafreniere Avatar answered Mar 12 '23 08:03

Blaine Lafreniere