From c16e726d0e2a8c607ce441eb5bf2419b16b41cab Mon Sep 17 00:00:00 2001 From: callum_linden Date: Tue, 20 Oct 2015 14:44:36 -0700 Subject: MAINT-5711 FIX2 auto login for profiles - final part retrieves the URL to set cookie for from the message sent over by login.cgi --- indra/newview/llviewermedia.cpp | 43 +++++++++++++++++++++++------------------ indra/newview/llviewermedia.h | 4 ++-- 2 files changed, 26 insertions(+), 21 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 3342fddade..1098b2a7e1 100755 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -285,13 +285,16 @@ public: const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) { + const std::string url = getURL(); + llinfos << "@@@ URL to set cookie on" << url << llendl; + // We don't care about the content of the response, only the Set-Cookie header. - LL_DEBUGS("MediaAuth") << dumpResponse() - << " [headers:" << getResponseHeaders() << "]" << LL_ENDL; + llinfos << dumpResponse() + << " [headers:" << getResponseHeaders() << "]" << llendl; const std::string& cookie = getResponseHeader(HTTP_IN_HEADER_SET_COOKIE); // *TODO: What about bad status codes? Does this destroy previous cookies? - LLViewerMedia::openIDCookieResponse(cookie); + LLViewerMedia::openIDCookieResponse(url, cookie); } }; @@ -1200,7 +1203,7 @@ void LLViewerMedia::clearAllCookies() } // If we have an OpenID cookie, re-add it to the cookie store. - setOpenIDCookie(); + setOpenIDCookie(std::string()); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -1303,7 +1306,7 @@ void LLViewerMedia::loadCookieFile() } // If we have an OpenID cookie, re-add it to the cookie store. - setOpenIDCookie(); + setOpenIDCookie(std::string()); } @@ -1413,7 +1416,7 @@ bool LLViewerMedia::parseRawCookie(const std::string raw_cookie, std::string& na ///////////////////////////////////////////////////////////////////////////////////////// // static -void LLViewerMedia::setOpenIDCookie() +void LLViewerMedia::setOpenIDCookie(const std::string& url) { if(!sOpenIDCookie.empty()) { @@ -1442,19 +1445,21 @@ void LLViewerMedia::setOpenIDCookie() getCookieStore()->setCookiesFromHost(sOpenIDCookie, authority.substr(host_start, host_end - host_start)); - LLMediaCtrl* media_instance = LLFloaterReg::getInstance("destinations")->getChild("destination_guide_contents"); - if (media_instance) - { - std::string cookie_host = authority.substr(host_start, host_end - host_start); - std::string cookie_name = ""; - std::string cookie_value = ""; - std::string cookie_path = ""; - if (parseRawCookie(sOpenIDCookie, cookie_name, cookie_value, cookie_path)) + if (url.length()) + { + LLMediaCtrl* media_instance = LLFloaterReg::getInstance("destinations")->getChild("destination_guide_contents"); + if (media_instance) { - std::string url = "http://id.secondlife.com/openid/webkit"; - media_instance->getMediaPlugin()->setCookie(url, cookie_name, cookie_value, cookie_host, cookie_path); + std::string cookie_host = authority.substr(host_start, host_end - host_start); + std::string cookie_name = ""; + std::string cookie_value = ""; + std::string cookie_path = ""; + if (parseRawCookie(sOpenIDCookie, cookie_name, cookie_value, cookie_path)) + { + media_instance->getMediaPlugin()->setCookie(url, cookie_name, cookie_value, cookie_host, cookie_path); + } } - }; + } // NOTE: this is the original OpenID cookie code, so of which is no longer needed now that we // are using CEF - it's very intertwined with other code so, for the moment, I'm going to @@ -1514,13 +1519,13 @@ void LLViewerMedia::openIDSetup(const std::string &openid_url, const std::string ///////////////////////////////////////////////////////////////////////////////////////// // static -void LLViewerMedia::openIDCookieResponse(const std::string &cookie) +void LLViewerMedia::openIDCookieResponse(const std::string& url, const std::string &cookie) { LL_DEBUGS("MediaAuth") << "Cookie received: \"" << cookie << "\"" << LL_ENDL; sOpenIDCookie += cookie; - setOpenIDCookie(); + setOpenIDCookie(url); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h index 0101c85e79..45d211f232 100755 --- a/indra/newview/llviewermedia.h +++ b/indra/newview/llviewermedia.h @@ -150,7 +150,7 @@ public: static void removeCookie(const std::string &name, const std::string &domain, const std::string &path = std::string("/") ); static void openIDSetup(const std::string &openid_url, const std::string &openid_token); - static void openIDCookieResponse(const std::string &cookie); + static void openIDCookieResponse(const std::string& url, const std::string &cookie); static void proxyWindowOpened(const std::string &target, const std::string &uuid); static void proxyWindowClosed(const std::string &uuid); @@ -164,7 +164,7 @@ public: private: static bool parseRawCookie(const std::string raw_cookie, std::string& name, std::string& value, std::string& path); - static void setOpenIDCookie(); + static void setOpenIDCookie(const std::string& url); static void onTeleportFinished(); static LLPluginCookieStore *sCookieStore; -- cgit v1.2.3