I am trying to replace an old PHP server with a Rails server. There are several clients that I do not control, that authenticate by providing a username and password in the url:
https://user:password@example.com/update
How can I extract the user and password from a url in a Rails 6 application?
When I look at the url or path via the request object the user and password are stripped. The request routes correctly, I just cannot extract the credentials in order to authenticate.
Additional detail added
I first started going down the basic auth path (even though I don't fully understand that term). I looked at some questions including this basic auth Rails question. Maybe I am missing something, but the sample code does not work. If I do the following:
curl "http://example.com/update?foo=bar" -u "user:pass"
I am able to access the user and password for basic auth. However
curl "http://user:pass@example.com/update?foo=bar"
Wait - that actually works! I was testing the requests from Safari and the basic auth attributes were ignored and not available in my controller, but when I run the request from curl it works. Crazy.
I am going to leave this question up in case someone else encounters this specific scenario. Maybe they will see this and solve the issue.