After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 746382 - souphttpsrc: Use proxy username/password from http_proxy
souphttpsrc: Use proxy username/password from http_proxy
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-03-18 08:12 UTC by Rajat Verma
Modified: 2018-11-03 14:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patct to parse proxy username/password from http_proxy (2.91 KB, patch)
2015-03-18 08:37 UTC, Rajat Verma
rejected Details | Review
Proposed patct to parse proxy username/password from http_proxy (3.25 KB, patch)
2015-03-18 08:41 UTC, Rajat Verma
none Details | Review
souphttpsrc: use proxy username/password from http_proxy (3.22 KB, patch)
2015-04-15 10:12 UTC, Rajat Verma
none Details | Review

Description Rajat Verma 2015-03-18 08:12:08 UTC
http_proxy variable may also contain proxy username & password in below format:

<protocol>://<username>:<password>@<proxy ip>:<proxy port>

souphttpsrc only sets proxy url (<proxy ip> & <proxy port>) is http_proxy variable is defined in environment but not proxy-id and proxy-pw.

Problem I am facing is "proxy authentication required 407" while testing MPEG-DASH, which plays a .mpd located outside my company network.

dashdemux, for fetching a segment, uses gst_element_make_from_uri(). Now I have no way to set proxy-id/proxy-pw on this particular souphttpsrc instance, due to which segment fetching fails.

If souphttpsrc may start parsing proxy-id/proxy-pw using below functions from soup library:
soup_uri_get_user()
soup_uri_get_password()
then my issue would be resolved.
Comment 1 Rajat Verma 2015-03-18 08:37:09 UTC
Created attachment 299685 [details] [review]
Proposed patct to parse proxy username/password from http_proxy
Comment 2 Rajat Verma 2015-03-18 08:41:09 UTC
Created attachment 299686 [details] [review]
Proposed patct to parse proxy username/password from http_proxy
Comment 3 Nicolas Dufresne (ndufresne) 2015-03-18 09:14:24 UTC
I'd rather like to see an interactive callback then another custom implement of http_proxy (the lower case version is even worst to my eyes).
Comment 4 Nicolas Dufresne (ndufresne) 2015-03-18 09:16:35 UTC
Review of attachment 299685 [details] [review]:

This is no a good idea. Automatic proxying should come from system setting. If you system proxy configuration does not support http_proxy, you should request there. What is an acceptable solution would be to add callbacks, so you can have an interactive authentication. This is supported by libsoup.
Comment 5 Nicolas Dufresne (ndufresne) 2015-03-18 09:16:50 UTC
Review of attachment 299686 [details] [review]:

Same.
Comment 6 Rajat Verma 2015-03-18 09:21:18 UTC
Hello Nicolas,

I am testing this on custom platform. My point was, as we already use http_proxy variable for setting proxy url inside souphttpsrc, so why not just set proxy username/password also from there, if they are available?
Comment 7 Rajat Verma 2015-03-18 10:22:55 UTC
Little more detail about problem, pipeline I am trying to play is something like below:

gst-launch-1.0 playbin uri=http://www-itec.uni-klu.ac.at/ftp/datasets/mmsys13/redbull_4sec.mpd

Actually, we have our own application, which creates the pipeline, allowing us to set properties, play-plause etc.

In that, I tried to register this callback:
  g_signal_connect (player->elements.playbin, "source-setup",
      G_CALLBACK (player_cb_source_setup), player_p);

and inside it, set proxy-id,proxy-pw.

With this, manifest is downloaded correctly, however, when dashdemux tries to download the first segment, I see "407, proxy authentication required" error.

Inside, dashdemux, I see, when it goes to fetch a segment, it creates an instance of souphttpsrc using below api:
gst_element_make_from_uri()

Now, with http_proxy set in my environment, this newly created souphttpsrc instance correctly goes to proxy, but this instance does not has proxy-id, proxy-pw set, so segment fetching fails.

Note that dashdemux will do this for every segment it wants to fetch.

May you please guide me on how to correctly set up proxy-id/proxy-pw on these intermediate souphttpsrc instances, if parsing http_proxy is not a viable approach?
Comment 8 Nicolas Dufresne (ndufresne) 2015-03-18 10:47:02 UTC
I must say I didn't notice we had support for that. I think it is a bad idea in general. Proxy configuration is something that depends on the platform, and the http_proxy is very ill defined and implemented differently all over the place. Clearly souphttpsrc is no exception.

What I think would be useful, is to allow application to react interactively when authentication is needed. In this case, SoupSession has the "authenticate" signal. This can be called for normal HTTP authentication or for proxy (see soup_auth_is_for_proxy()). As there is no way to access SoupSession safely, I think that souphttpsrc element should provide a callback to relay. One could then properly interact with authentication and avoid using deprecated forms of user/passwd passing (http://user:pass@...).
Comment 9 Rajat Verma 2015-03-19 05:52:48 UTC
Just for sake of clarification, what I undertand is currently, souphttpsrc connects with "authenticate" signal provided by libsoup:
  g_signal_connect (src->session, "authenticate",
      G_CALLBACK (gst_soup_http_src_authenticate_cb), src);

Inside, this callback, souphttpsrc tried to authenticate using its proxy-id & proxy-pw using below code:
static void
gst_soup_http_src_authenticate_cb (SoupSession * session, SoupMessage * msg,
    SoupAuth * auth, gboolean retrying, GstSoupHTTPSrc * src)
{
....
      if (src->proxy_id && src->proxy_pw)
        soup_auth_authenticate (auth, src->proxy_id, src->proxy_pw);
....
}

So, what you are implying is to implement a signal in souphttpsrc itself, which application/client can connect to, right?

If this is the case, can you please provide some snippet about when that signal should be emitted by souphttpsrc as we would already be inside gst_soup_http_src_authenticate_cb() callback when we become aware that proxy credentials are required?
Comment 10 Nicolas Dufresne (ndufresne) 2015-03-19 11:27:39 UTC
Has to be sync message I think. And yes, has to be within the callback, unless soup as an async method to handle it.
Comment 11 Rajat Verma 2015-03-20 05:15:13 UTC
(In reply to Nicolas Dufresne (stormer) from comment #10)
> Has to be sync message I think. And yes, has to be within the callback,
> unless soup as an async method to handle it.

Hello Nicolas,

I am still not sure I get your point.
Can you please provide some code snippet about how sync message should be posted by souphttpsrc?
Comment 12 Rajat Verma 2015-03-20 11:54:12 UTC
Hello Nicolas,

One more update from my side:

Just checked code of 
- gst-plugins-bad/gst-libs/gst/adaptivedemux/gstadaptivedemux.c
- gst-plugins-bad/gst-libs/gst/uridownloader/uridownloader.c
- gstreamer/gst/gsturi.c

Here, we can see that for playing a MPEG-DASH stream, a new instance of souphttpsrc is created by dashdemux for each of the streams exposed in manifest file.

This souphttpsrc instance is created using api gst_element_make_from_uri().

Now the problem is we don't see any where this internal souphttpsrc instance being added to pipeline. This would pose a problem in way you are suggesting to fix it (adding sync-message...) as this message approach would only be valid for elements present in pipeline.

Please feel free if you got any suggestions.
Otherwise, I don't see a way to properly set proxy credentials on this internal souphttpsrc instance without using http_proxy.
Comment 13 Rajat Verma 2015-03-23 11:05:49 UTC
I don't know whether I have been able to present the problem in clear way, so here is another go at it (my last one):

Inside gstadaptivedemux.c, below code is present:

gst_adaptive_demux_stream_update_source (...)
...
stream->src = gst_element_make_from_uri (GST_URI_SRC, uri, NULL, NULL);
...
gst_bin_add (GST_BIN_CAST (demux), stream->src);


This implies, say when playing a dash stream using http, containing one audio and one video track, it will create one souphttpsrc instance for each of stream.
Now these internal souphttpsrc instances are not added to pipeline demux is part of, but rather added to internal pipeline of dashdemux, via below line:

gst_bin_add (GST_BIN_CAST (demux), stream->src);

Issue I have is how to set proxy credentials (proxy_id, proxy_pw) on these internal souphttpsrc instances?

For solving this issue, I have already suggested a patch, which uses already available soup APIs to parse username/password from http_proxy variable.

If this is not acceptable, kindly suggest approach which works. But kindly don't leave this in a limbo...
Comment 14 Nicolas Dufresne (ndufresne) 2015-03-23 12:31:55 UTC
The problem I see, is that you seem to assume that the proxy credential will always be the same for all URI found in the playlist. Like browsers, which should be able to handle multiple credential for multiple URI.

What I'm proprosing is to introduce a bus message for authentication. SoupSession will emit "authenticate" signal. This signal can be for normal authentication or proxy (this way we can add support for both). As we want this to happen asynchronously, we'll call soup_session_pause_message() and g_object_ref() the message). We will post a message, probably implement an Authetication inteface for GStreamer element. Application watching this message can then reply to it through the interface, and then streaming can continue.

This is not a limbo, this is what I think is the right way to solve this issue. The http_proxy environment approach is very hacky, and it's completly inconsistent between softwares. It also prevent from having certain URI go through proxy while keeping other direct.
Comment 15 Rajat Verma 2015-03-24 07:36:22 UTC
Thanks for your replay Nicolas, now I get your point.
I am bit slow, so now when you explained in bit more detail (comment 14 vs comment 10), it became clear to me :)
Comment 16 Rajat Verma 2015-04-13 07:55:30 UTC
Hello Nicolas,

One update, in comment 4, you mentioned
>>Automatic proxying should come from system setting.

by this, did you meant gsettings?

I tried setting http proxy username and password using gsettings but that didn't worked also, same 407 error.
Comment 17 Rajat Verma 2015-04-15 10:12:47 UTC
Created attachment 301612 [details] [review]
souphttpsrc: use proxy username/password from http_proxy
Comment 18 GStreamer system administrator 2018-11-03 14:58:56 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/170.