{"action":"created","issue":{"url":"https://api.github.com/repos/rbCAS/CASino/issues/146","labels_url":"https://api.github.com/repos/rbCAS/CASino/issues/146/labels{/name}","comments_url":"https://api.github.com/repos/rbCAS/CASino/issues/146/comments","events_url":"https://api.github.com/repos/rbCAS/CASino/issues/146/events","html_url":"https://github.com/rbCAS/CASino/issues/146","id":121793751,"number":146,"title":"Login occasionally redirects to the wrong path at random?","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":4,"created_at":"2015-12-11T21:20:31Z","updated_at":"2015-12-14T17:44:56Z","closed_at":null,"body":"I'm running into a strange bug that seems to appear seemingly at random. I have rack setup to pass requests on the '/authenticate' subdirectory to my Casino application:\r\n\r\n```ruby\r\nmap '/authenticate' do\r\n  run Rails.application\r\nend\r\n```\r\n\r\nI also inform rails that all routes need to include the '/authenticate' subpath:\r\n```ruby\r\nRails.application.config.relative_url_root = '/authenticate'\r\n```\r\n\r\nMore often than not, everything works great with this setup. However, if I try repeatedly logging out and logging back in, on the very rare occasion CASino will try to redirect to `login` without the subpath after it makes a request to `proxyValidate`, as seen with my server logs:\r\n\r\n```\r\n127.0.0.1 - - [11/Dec/2015:14:05:20 -0600] \"POST /authenticate/login HTTP/1.1\" 303 - 0.1860\r\n127.0.0.1 - - [11/Dec/2015:14:05:20 -0600] \"GET /authenticate/proxyValidate?service=http%3A%2F%2Flocalhost%3A3000%2Fadmin_users%2Fservice&ticket=ST-14498643207475-muyPjLOST2JRU8NkPbEWgeMH5Qm7oMwAFSXytJS4 HTTP/1.1\" 200 - 0.0139\r\n**27.0.0.1 - - [11/Dec/2015:14:05:20 -0600] \"GET /login?service=http%3A%2F%2Flocalhost%3A3000%2Fadmin_users%2Fservice HTTP/1.1\" 404 - 0.0009**\r\n```\r\n\r\n\r\nAnd on the remote rails app service using ActiveAdmin:\r\n```\r\nStarted GET \"/admin_users/service?ticket=ST-14498643207475-muyPjLOST2JRU8NkPbEWgeMH5Qm7oMwAFSXytJS4\" for 127.0.0.1 at 2015-12-11 14:05:20 -0600\r\nProcessing by CasSessionsController#service as HTML\r\n  Parameters: {\"ticket\"=>\"ST-14498643207475-muyPjLOST2JRU8NkPbEWgeMH5Qm7oMwAFSXytJS4\"}\r\nD, [2015-12-11T14:05:20.764793 #19427] DEBUG -- : [httplog] Connecting: localtoast:3001\r\nD, [2015-12-11T14:05:20.765043 #19427] DEBUG -- : [httplog] Sending: GET http://localtoast:3001/authenticate/proxyValidate?service=http%3A%2F%2Flocalhost%3A3000%2Fadmin_users%2Fservice&ticket=ST-14498643207475-muyPjLOST2JRU8NkPbEWgeMH5Qm7oMwAFSXytJS4\r\nD, [2015-12-11T14:05:20.765093 #19427] DEBUG -- : [httplog] Data: \r\nD, [2015-12-11T14:05:20.779228 #19427] DEBUG -- : [httplog] Status: 200\r\nD, [2015-12-11T14:05:20.779301 #19427] DEBUG -- : [httplog] Benchmark: 0.014076887999181054 seconds\r\nD, [2015-12-11T14:05:20.779352 #19427] DEBUG -- : [httplog] Response:\r\n<cas:serviceResponse xmlns:cas=\"http://www.yale.edu/tp/cas\">\r\n  <cas:authenticationSuccess>\r\n    <cas:user>user@example.com</cas:user>\r\n  </cas:authenticationSuccess>\r\n</cas:serviceResponse>\r\nUsing conditions {email => user@example.com} to find the User\r\n  AdminUser Load (0.4ms)  SELECT  \"admin_users\".* FROM \"admin_users\"  WHERE \"admin_users\".\"email\" = 'user@example.com'  ORDER BY \"admin_users\".\"id\" ASC LIMIT 1\r\n   (0.1ms)  BEGIN\r\n   (0.1ms)  COMMIT\r\n   (0.1ms)  BEGIN\r\n  SQL (0.2ms)  UPDATE \"admin_users\" SET \"current_sign_in_at\" = $1, \"sign_in_count\" = $2, \"updated_at\" = $3 WHERE \"admin_users\".\"id\" = 2  [[\"current_sign_in_at\", \"2015-12-11 20:05:20.786058\"], [\"sign_in_count\", 2], [\"updated_at\", \"2015-12-11 20:05:20.786633\"]]\r\n   (10.7ms)  COMMIT\r\nRedirected to http://localhost:3000/admin\r\nCompleted 302 Found in 35ms (ActiveRecord: 11.5ms)\r\n```\r\n\r\nI can't for the life of me figure out where that redirect to `/login` is coming from. Again, I see this completely at random after logging in and logging out consecutive times. `http://localhost:3000/admin` is the path where the browser should have been redirected to, but that seems to get overridden by CASino's redirect to `http://localtoast:3001/login` (and no, \"localtoast\" is not a typo :smile:).\r\n"},"comment":{"url":"https://api.github.com/repos/rbCAS/CASino/issues/comments/164507018","html_url":"https://github.com/rbCAS/CASino/issues/146#issuecomment-164507018","issue_url":"https://api.github.com/repos/rbCAS/CASino/issues/146","id":164507018,"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},"created_at":"2015-12-14T17:44:55Z","updated_at":"2015-12-14T17:44:55Z","body":"@bakku Yeah, that definietly sounds like the issue I was running into.\r\n\r\nI'm not entirely sure how bundler determines whether or not a gem is up-to-date, but I believe both the rubygems version of CASino and the Github version both resolve to v4.0.2. You might have to manually run `bundle update casino` to pull in the fix that worked for me. After updating I've yet to see that `/login` request crop up."}}