{"action":"created","issue":{"url":"https://api.github.com/repos/biola/rack-cas/issues/49","labels_url":"https://api.github.com/repos/biola/rack-cas/issues/49/labels{/name}","comments_url":"https://api.github.com/repos/biola/rack-cas/issues/49/comments","events_url":"https://api.github.com/repos/biola/rack-cas/issues/49/events","html_url":"https://github.com/biola/rack-cas/issues/49","id":119615325,"number":49,"title":"401 status not getting intercepted","user":{"login":"nozpheratu","id":2205286,"avatar_url":"https://avatars.githubusercontent.com/u/2205286?v=3","gravatar_id":"","url":"https://api.github.com/users/nozpheratu","html_url":"https://github.com/nozpheratu","followers_url":"https://api.github.com/users/nozpheratu/followers","following_url":"https://api.github.com/users/nozpheratu/following{/other_user}","gists_url":"https://api.github.com/users/nozpheratu/gists{/gist_id}","starred_url":"https://api.github.com/users/nozpheratu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nozpheratu/subscriptions","organizations_url":"https://api.github.com/users/nozpheratu/orgs","repos_url":"https://api.github.com/users/nozpheratu/repos","events_url":"https://api.github.com/users/nozpheratu/events{/privacy}","received_events_url":"https://api.github.com/users/nozpheratu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-01T00:46:13Z","updated_at":"2015-12-01T02:35:44Z","closed_at":null,"body":"According to the docs\r\n> Your app should return a 401 status whenever a request is made that requires authentication. Rack-CAS will catch these responses and attempt to authenticate via your CAS server.\r\n\r\nUsing the following configuration on my development server: \r\n```ruby\r\n{\r\n  :server_url => \"http://localhost:3001/\",\r\n  :session_store => RackCAS::ActiveRecordStore,\r\n  :verify_ssl_cert => false,\r\n  :renew => true\r\n}\r\n```\r\n\r\nI have a [CASino](http://casino.rbcas.com/) server running on port 3001. Here's my log files when I hit a 401 status while trying to access an ActiveAdmin page require authorization: \r\n>\r\nStarted GET \"/admin/referrals/new\" for 127.0.0.1 at 2015-11-30 18:27:33 -0600\r\nProcessing by Admin::ReferralsController#new as HTML\r\nCompleted 401 Unauthorized in 2ms (ActiveRecord: 0.0ms)\r\n>\r\nStarted GET \"/admin/login\" for 127.0.0.1 at 2015-11-30 18:27:33 -0600\r\nProcessing by ActiveAdmin::Devise::SessionsController#new as HTML\r\n  Rendered /home/cyle/.rvm/gems/ruby-2.2.2/bundler/gems/activeadmin-5a2b7b5bc683/app/views/active_admin/devise/shared/_links.erb (0.3ms)\r\n  Rendered /home/cyle/.rvm/gems/ruby-2.2.2/bundler/gems/activeadmin-5a2b7b5bc683/app/views/active_admin/devise/sessions/new.html.erb within layouts/active_admin_logged_out (19.8ms)\r\nCompleted 200 OK in 41ms (Views: 37.9ms | ActiveRecord: 0.0ms)\r\n\r\nI'm not really seeing anything to indicate that rack-cas is indeed intercepting the 401 response. I noticed ActiveAdmin wasn't setting the status correctly in the response header, so to discern if this was an ActiveAdmin issue I also tried to manually return a 401 status in one of my controller actions with the correct header and met similar results. Is there some way I can go about debugging this further?"},"comment":{"url":"https://api.github.com/repos/biola/rack-cas/issues/comments/160829520","html_url":"https://github.com/biola/rack-cas/issues/49#issuecomment-160829520","issue_url":"https://api.github.com/repos/biola/rack-cas/issues/49","id":160829520,"user":{"login":"adamcrown","id":277306,"avatar_url":"https://avatars.githubusercontent.com/u/277306?v=3","gravatar_id":"","url":"https://api.github.com/users/adamcrown","html_url":"https://github.com/adamcrown","followers_url":"https://api.github.com/users/adamcrown/followers","following_url":"https://api.github.com/users/adamcrown/following{/other_user}","gists_url":"https://api.github.com/users/adamcrown/gists{/gist_id}","starred_url":"https://api.github.com/users/adamcrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamcrown/subscriptions","organizations_url":"https://api.github.com/users/adamcrown/orgs","repos_url":"https://api.github.com/users/adamcrown/repos","events_url":"https://api.github.com/users/adamcrown/events{/privacy}","received_events_url":"https://api.github.com/users/adamcrown/received_events","type":"User","site_admin":false},"created_at":"2015-12-01T02:35:43Z","updated_at":"2015-12-01T02:35:43Z","body":"I don't have much experience with ActiveAdmin. So there might be something there that's causing problems.\r\n\r\nFirst step would be to run `rake middleware` and make sure Rack::CAS is in the list.\r\n\r\nWhen you visit the page do you get a 200 or 401 status? If it's a 401 status then Rack::CAS isn't catching it. If it's a 200, either you're not returning a 401 or Rack::CAS is catching it and logging you in.\r\n\r\nYou can look at `session[:cas]` and see if there's anything there to tell if authentication is happening or not.\r\n\r\nAnother easy test would be to visit the site in a incognito window (so you're sure you're not already logged into CASino) and see if you get the login page or not."}}