Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def check_feed_authorization
- if request.env.has_key? 'X-HTTP_AUTHORIZATION'
- # try to get it where mod_rewrite might have put it
- authdata = @request.env['X-HTTP_AUTHORIZATION'].to_s.split
- elsif request.env.has_key? 'HTTP_AUTHORIZATION'
- # this is the regular location
- authdata = @request.env['HTTP_AUTHORIZATION'].to_s.split
- end
- # at the moment we only support basic authentication
- @allowed_user=nil
- if authdata and authdata[0] == 'Basic'
- email,password=Base64.decode64(authdata[1]).split(':')[0..1]
- @allowed_user = User.authenticate(email,password)
- end
- if @allowed_user
- return @allowed_user
- else
- #deny_access
- return nil
- end
- end
- def deny_access
- @response.headers["WWW-Authenticate"] = "Basic realm=\"listasgems\""
- render :nothing=>true, :status=>401
- end
Add Comment
Please, Sign In to add comment