when opening a URL that requires authentication, web browser will open the redirect #2

Open
igalic opened this Issue Mar 30, 2016 · 8 comments

Comments

Projects
None yet
2 participants

igalic commented Mar 30, 2016

This seems to be primarily on linux
when trying to xdg-open a url that requires authentication before access, xdg-open will use whatever that URL redirects to. e.g.:

igalic@levix ~> curl -I  https://cloud.digitalocean.com/settings/api/tokens/new
HTTP/1.1 302 Found
Server: cloudflare-nginx
Date: Wed, 30 Mar 2016 19:57:13 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Set-Cookie: __cfduid=df9cfd98f8b2674008344407500bd15eb1459367833; expires=Thu, 30-Mar-17 19:57:13 GMT; path=/; domain=.digitalocean.com; HttpOnly
Status: 302 Found
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Location: https://cloud.digitalocean.com/login
Cache-Control: no-cache
Set-Cookie: _digitalocean2_session_v2=VlBrR01Rc2orZllDNGNrRVZYNCsxa21JZVRwbUNwbkxCdmFtV3RyT1RQRUxwTjhnNUZ6WER1WEc0cGNGcnBXbFVXZFJmVUxkUlVvQXpCb2F3aGViK2UrN0pFRWI1VU9FNFJMTExHTFhUcWZvdmE3emw3NDQ2OHFnS2ZoV29sTm5kYU9CUXg3NXpnUkUyK2l1Q2dndUdnN2w3WU4yaVJqTjhiUEFKTWZ2UUJNZkhtRmVYN09zVkw3TEdMa0Q2RFdUYU1nZGdrUk5EVGl1OFpQRnYxNElDTmFVTnRRbFRhUHVsWUtReWxMdUZUK3FxZFo3eEduUFlNUGV3Mmt5ZW5ac2lHdUFYRkIwVytDamkwa2RITUx4UFIzblF2c3V5Rzd6dmFpaDFzTWthRlNBVkJsRDFVK00xWlYrQTZaSEV5Q2RaYjh5VVM4VnQrZWpuMHpmVnpDQzRvcENkaURpYWE4bXlycE5jb1lqdG12OU0rdTRZQ1dpbllxakZpTkJsaUJkUFIyN1hJTDlac3FxVEJFcEk4NW9ZTGhScCtaS0RwMHM3SFpZWFkyakhET1FlNXVVZU5udVRMWWVJNlNGOHVVRzIxaVllRnBXbVl3RXVVQklpWTdWRTlKZHlBZDU2Y1dtT1VwM1c0WFkxd2x4MXpvRC92cXdwYnRwTzZpTnhNWGdoNUt0RkpFQ2l6eWFrdVJidmpvd1YyTE05emN6bjVNcXh5TjBBQXVXN1NrPS0tMWZOQUs1SHdNb1huWWRTRSthRlVBZz09--5d07ef57ed0e672cef20800db2dfc0e6a8a54a95; path=/; secure; HttpOnly
X-Request-Id: d27bbbfe-2067-4a2a-9e39-a59b805d265c
X-Runtime: 0.044310
Strict-Transport-Security: max-age=31536000
CF-RAY: 28be211e9ad00c89-AMS

igalic@levix ~> 

that means, that when trying to xdg-open https://cloud.digitalocean.com/settings/api/tokens/new - it will actually open https://cloud.digitalocean.com/login

@igalic igalic referenced this issue in digitalocean/doctl Mar 30, 2016

Closed

can't login on KDE #21

Owner

bryanl commented Mar 31, 2016

I'm going to be testing this out tomorrow. I'll make sure to post back here with my findings.

igalic commented Mar 31, 2016

i've traced this down to kde-open5, now let's see what that does


of course that only calls KRun::runService()

Owner

bryanl commented Apr 1, 2016

Would you mind describing your setup, so I can help you diagnose this a bit more. I've verified it works on a fresh Ubuntu 14.04.

igalic commented Apr 1, 2016

This is kubuntu 16.04
with its latest plasma desktop

igalic commented Apr 1, 2016

update: from https://quickgit.kde.org/?p=kio.git&a=blob&h=b9b232dc80e9fa9b47f65203aa72b52280124fc1&hb=19fd3c456037c9cd7f762b174172de085fd53673&f=src%2Fwidgets%2Fkrun.cpp (line 104++)

static QString schemeHandler(const QString &protocol)
{
    // We have up to two sources of data, for protocols not handled by kioslaves (so called "helper") :
    // 1) the exec line of the .protocol file, if there's one
    // 2) the application associated with x-scheme-handler/<protocol> if there's one

    // If both exist, then:
    //  A) if the .protocol file says "launch an application", then the new-style handler-app has priority
    //  B) but if the .protocol file is for a kioslave (e.g. kio_http) then this has priority over
    //     firefox or chromium saying x-scheme-handler/http. Gnome people want to send all HTTP urls
    //     to a webbrowser, but we want mimetype-determination-in-calling-application by default
    //     (the user can configure a BrowserApplication though)

    const KService::Ptr service = KMimeTypeTrader::self()->preferredService(QLatin1String("x-scheme-handler/") + protocol);
    if (service) {
        return service->exec(); // for helper protocols, the handler app has priority over the hardcoded one (see A above)
    }
    Q_ASSERT(KProtocolInfo::isHelperProtocol(protocol));
    return KProtocolInfo::exec(protocol);
}

so kde tries to figure out if the resulting url is an image, or a PDF, or whatever, before trying to open it in Gwenview, or Okular, or giving up and opening it in a browser. This is not so good in our case. It would be nice if we could override that.

Owner

bryanl commented Apr 9, 2016

@igalic I'm working out a solution to make this work with Kubuntu right now.

igalic commented May 7, 2016

oh, wow… i haven't had time in almost a month for github gardening ._.
thank you @bryanl 💜!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment