-1

I build basic authorization in apache.Only one line in /var/www/html/remote.html.

<p>it is a test </p>

Now to verify the username and password with curl.

curl -u xxxx:xxxx -v  http://111.111.111.111/remote.html
*   Trying 111.111.111.111...
* TCP_NODELAY set
* Connected to 111.111.111.111 (111.111.111.111) port 80 (#0)
* Server auth using Basic with user 'xxxx'
> GET /remote.html HTTP/1.1
> Host: 111.111.111.111
> Authorization: Basic dGVzdHBhc3M6MTIzNDU2Nzg=
> User-Agent: curl/7.52.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Fri, 07 Sep 2018 03:32:42 GMT
< Server: Apache/2.4.6 (CentOS)
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Headers: Authorization,DNT,User-Agent,Keep-Alive,Content-Type,accept,origin,X-Requested-With
< Last-Modified: Fri, 07 Sep 2018 03:22:41 GMT
< ETag: "b2-5753f8537e26c"
< Accept-Ranges: bytes
< Content-Length: 178
< Content-Type: text/html; charset=UTF-8
< 

<p>it is a test </p>
* Curl_http_done: called premature == 0
* Connection #0 to host 111.111.111.111 left intact

Input http://111.111.111.111/remote.html?username=xxxx&password=xxxx in browser,the authorization window pop up.

enter image description here

The url has contained right username and password verified by curl ,why remote.html can't be shown directly?
Why my url http://111.111.111.111/remote.html?username=xxxx&password=xxxx can't provide authorization info to apache server?

showkey
  • 85
  • 1
  • 1
  • 14

3 Answers3

1

HTTP Basic Auth credentials are sent in a specific header from the client to the server - they are not appended to the URL in that way. You can verify this by noting that

curl http://111.111.111.111/remote.html?username=xxxx&password=xxxx

Also doesn't work - the -u flag knows to send it differently, and do does your browser when you enter the creds into the form provided.

lvc
  • 111
  • 4
1

The URL for basic authentication is

http://testpass:12345678@111.111.111.111/remote.html
RalfFriedl
  • 3,008
  • 4
  • 12
  • 17
0

use following and also check other answers and How to enter login CLI

curl --user user:pass http://myweb.com/hello.html  
sanjayparmar
  • 623
  • 8
  • 18