0

I need to do a GET request on a website that is protected by basic HTTP authentication on my local network. Is it possible to authenticate with the GET request?

If yes, how can I do that?

I'm using PHP.

munich
  • 500
  • 1
  • 6
  • 16
  • yes, use the curl library. Here's a duplicate question: http://stackoverflow.com/questions/2140419/how-do-i-make-a-request-using-http-basic-authentication-with-php-curl – Kevin Mar 18 '14 at 01:40
  • @Kevin that doesn't answer the question. Nowhere did the OP mention curl. – Mike Mar 18 '14 at 01:41
  • He didn't specifically say he was opposed to using libcurl. IT is built into php since 4.x. Perhaps I misunderstood the goal though.. – Kevin Mar 18 '14 at 01:52

1 Answers1

1

Yes, it is possible. You can provide the username and password directly in the URL in the following form:

<form method="get" action="http://username:password@yoursite.com/blah/script.php">

Whether it is a good idea to do this or not is another story. I would highly discourage it in a production environment.

Mike
  • 23,542
  • 14
  • 76
  • 87
  • Thanks, that works. What if I use https instead of plain http? – munich Mar 18 '14 at 02:02
  • SSL never makes anything more dangerous. Like I mentioned in the answer, I wouldn't recommend this for a production environment. This includes regular HTTP and also HTTPS. If you just want to do it on your own internal server, go ahead. But displaying the username and password in the URL basically defeats the purpose of securing it in the first place. – Mike Mar 18 '14 at 04:00