Skip to content

Commit

Permalink
API: Add LRO_USERNAME and LRO_PASSWORD options
Browse files Browse the repository at this point in the history
The original LRO_USERPWD option does not support a colon in the username.
Use LRO_USERNAME and LRO_PASSWORD instead.

The description of the LRO_USERPWD option has been expanded:
The user and password strings are not URL decoded, so there is no way
to send in a username containing a colon using this option. The option
is DEPRECATED!
Use LRO_USERNAME and LRO_PASSWORD.

The description of the LRO_PROXYUSERPWD option has been expanded:
Both the username and the password are URL decoded before use, so
if the username contains, for example, a colon, it should be encoded
as %3A.
  • Loading branch information
jrohel committed Jun 24, 2024
1 parent 138b71b commit 92d476e
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 5 deletions.
4 changes: 2 additions & 2 deletions VERSION.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SET(LIBREPO_MAJOR "1")
SET(LIBREPO_MINOR "17")
SET(LIBREPO_PATCH "2")
SET(LIBREPO_MINOR "18")
SET(LIBREPO_PATCH "0")
2 changes: 1 addition & 1 deletion librepo.spec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
%global dnf_conflict 2.8.8

Name: librepo
Version: 1.17.2
Version: 1.18.0
Release: 1%{?dist}
Summary: Repodata downloading library

Expand Down
8 changes: 8 additions & 0 deletions librepo/handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,14 @@ lr_handle_setopt(LrHandle *handle,
c_rc = curl_easy_setopt(c_h, CURLOPT_USERPWD, va_arg(arg, char *));
break;

case LRO_USERNAME:
c_rc = curl_easy_setopt(c_h, CURLOPT_USERNAME, va_arg(arg, char *));
break;

case LRO_PASSWORD:
c_rc = curl_easy_setopt(c_h, CURLOPT_PASSWORD, va_arg(arg, char *));
break;

case LRO_PROXY:
c_rc = curl_easy_setopt(c_h, CURLOPT_PROXY, va_arg(arg, char *));
break;
Expand Down
15 changes: 13 additions & 2 deletions librepo/handle.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ typedef enum {
Use LRO_HTTPAUTHMETHODS */

LRO_USERPWD, /*!< (char *)
User and password for http authetification in format user:password */
User and password for http authetification in format user:password.
The user and password strings are not URL decoded, so there is no way to send in
a username containing a colon using this option. The option is DEPRECATED!
Use LRO_USERNAME and LRO_PASSWORD */

LRO_PROXY, /*!< (char *)
Address of proxy server eg. "proxy-host.com:8080" */
Expand All @@ -170,7 +173,9 @@ typedef enum {
Use LRO_PROXYAUTHMETHODS */

LRO_PROXYUSERPWD, /*!< (char *)
User and password for proxy in format user:password */
User and password for proxy in format user:password
Both the username and the password are URL decoded before use, so if the username
contains, for example, a colon, it should be encoded as %3A.*/

LRO_PROGRESSCB, /*!< (LrProgressCb)
Progress callback */
Expand Down Expand Up @@ -429,6 +434,12 @@ typedef enum {
Path to a file containing the list of PEM format trusted CA
certificates. Used for proxy. */

LRO_USERNAME, /*!< (char *)
User for http authetification */

LRO_PASSWORD, /*!< (char *)
Password for http authetification */

LRO_SENTINEL, /*!< Sentinel */

} LrHandleOption; /*!< Handle config options */
Expand Down
21 changes: 21 additions & 0 deletions librepo/python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@
*String or None*. Set username and password for HTTP authentication.
Param must be in format 'username:password'.
The user and password strings are not URL decoded, so there is no way to send in
a username containing a colon using this option. The option is DEPRECATED!
Use LRO_USERNAME and LRO_PASSWORD.
.. data:: LRO_USERNAME
*String or None*. Set username for HTTP authentication.
.. data:: LRO_PASSWORD
*String or None*. Set password for HTTP authentication.
.. data:: LRO_PROXY
Expand All @@ -116,6 +127,8 @@
*String or None*. Set username and password for proxy
authentication in format 'username:password'.
Both the username and the password are URL decoded before use, so if the username
contains, for example, a colon, it should be encoded as %3A.
.. data:: LRO_PROGRESSCB
Expand Down Expand Up @@ -1259,6 +1272,14 @@ class Handle(_librepo.Handle):
See: :data:`.LRO_USERPWD`
.. attribute:: username:
See: :data:`.LRO_USERNAME`
.. attribute:: password:
See: :data:`.LRO_PASSWORD`
.. attribute:: proxy:
See: :data:`.LRO_PROXY`
Expand Down
2 changes: 2 additions & 0 deletions librepo/python/handle-py.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ py_setopt(_HandleObject *self, PyObject *args)
case LRO_MIRRORLISTURL:
case LRO_METALINKURL:
case LRO_USERPWD:
case LRO_USERNAME:
case LRO_PASSWORD:
case LRO_PROXY:
case LRO_PROXYUSERPWD:
case LRO_DESTDIR:
Expand Down
2 changes: 2 additions & 0 deletions librepo/python/librepomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ PyInit__librepo(void)
PYMODULE_ADDINTCONSTANT(LRO_LOCAL);
PYMODULE_ADDINTCONSTANT(LRO_HTTPAUTH);
PYMODULE_ADDINTCONSTANT(LRO_USERPWD);
PYMODULE_ADDINTCONSTANT(LRO_USERNAME);
PYMODULE_ADDINTCONSTANT(LRO_PASSWORD);
PYMODULE_ADDINTCONSTANT(LRO_PROXY);
PYMODULE_ADDINTCONSTANT(LRO_PROXYPORT);
PYMODULE_ADDINTCONSTANT(LRO_PROXYTYPE);
Expand Down

0 comments on commit 92d476e

Please sign in to comment.