Why apache need authorization for url with username and password?

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?
Почему мой URL http://111.111.111.111/remote.html?username=xxxx&password=xxxx не может предоставить информацию для авторизации на сервер Apache?

-1
задан 7 September 2018 в 06:43
3 ответа

URL-адрес для базовой аутентификации:

http://testpass:12345678@111.111.111.111/remote.html
1
ответ дан 5 December 2019 в 19:21

Учетные данные HTTP Basic Auth отправляются в определенном заголовке от клиента к серверу - они не добавляются к URL-адресу таким образом. Вы можете проверить это, заметив, что

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

Также не работает - флаг -u знает, что нужно отправлять его по-другому, и делает это ваш браузер , когда вы вводите кредиты в предоставленную форму .

1
ответ дан 5 December 2019 в 19:21

используйте следующее, а также проверьте другие ответы и Как ввести логин CLI

curl --user user:pass http://myweb.com/hello.html  
0
ответ дан 5 December 2019 в 19:21

Теги

Похожие вопросы