That sounds a little spiteful, bear with me. This is also not a specific Rails issue, although both sites use Rails. (I apologize in advance for both of these things)
Imagine two websites that use Ruby on Rails:
mysite.com, on which I am a developer and have full access in terms of changing the code, etc., and also has an administrator login, so I can manage user accounts.
theirsite.com, on which I have an administrator login, but do not have access to dev. I know the people who manage it, but I would not ask them for any benefits for political reasons. However, this is an option.
Using my administrator login on each site, I made a user account for the same person. When they logged in to mysite.com, I would like to provide a button that records them directly to my site. I have my username and password for their website stored in their user record in the mysite.com database to facilitate this. The button is a submit button for the form, which duplicates the form on the login page on yoursite.com, with hidden fields for the username and password.
A stumbling block is that theirsite.com handles CSRF with the variable authenticity_token , which does not check when the login is sent from mysite.com.
My first attempt to get past this was in the mysite.com controller, which loads a form page to clear the login page on yoursite.com to get an authentication token, and then connect it to my form. But that does not work.
If I load the login page on yoursite.com and the mysite.com page with a remote login button in two browser tabs and manually copy the token authenticity from yoursite.com form to mysite.com form, then it works, This is because (I think) , the_token authenticity is connected to my session with a cookie, and when I do all this in one browser, the session is the same, but when I get the authenticity token from yoursite.com via scrambling (using Nokogiri, but I could use curl instead) it not the same session.
Question A) So, I think I also need to set a cookie so that the session matches between the browser and the Nokogiri request that I make. But this may not be possible, and it is precisely that the anti-CSRF system was designed to defeat. Is that the case?
Question B) Let me say that, despite the policy, I need to ask the owner of yoursite.com to make small changes to allow me to register our users on yoursite.com when we know theirsite.com username and password . What would be the smallest, safest change I could ask to make to allow this?
Please do not hesitate to say: "Come off the fact that you are evil black", I think this is the right answer. The question is a bit dodgy.