Issue with cookie value not being encoded for cordova android app using Crosswalk

251 views Asked by At

SETUP

Currently, I have an cordova android application that uses crosswalk as the webview instead of the default chromium browser. The application itself access a AuthProvider during login and the cookies that are transmitted back from the AuthProvider are stored into the Android's CookieManager.

I have validated that I'm able to retrieve the Cookies specific to that authprovider by the domain.

Problem

For simple cases, when the cookie's value contains no "=" sign everything works perfectly. I'm able to update or even invalidate the cookie. However, I notice that when the Auth Provider returns a cookie that has a value with "=" in it (ex. Cookie string = "AuthCookie=a=b=c=d" where AuthCookie is the cookie Name and the value is "a=b=c=d". When this happens, "a=b=c=d" is an invalid cookie value when it's not encoded. As a result, the CookieManager's method (setCookie) does not work. There is no way to update or even invalidate that cookie.

The interesting part is that you the cookieManger will not even let you set a cookie with the value "a=b=c=d". The problem is that I believe that the cookie value is set by the browser which interprets the cookies from the response from the authprovider and updates the data store. However, I don't think it ever encodes the cookie value.

GOAL

The real goal is that I need to be able to invalidate specific cookies that are stored via AuthProvider Browser.

The function provided for the cookieManager

setCookie(< domain>, < cookiestring>);

The problem that the function itself takes a cookie string that contains the cookie name and the value. I only want the cookie value to be encoded. The only problem is that I'm not how the AuthProvider sets the cookies in the cookie store.

Do I need to override the cookieManager set method? Parse all the cookies based on ";" then parse all the cookie for the first "=" sign and then encode everything on the right side?

I also don't know if the cookieManager:setCookie() called by the browser where it's storing the auth providers response? I don't believe this is the case because setCookie(domain,"auth=a=b=c=d") will not work. At least with the XWalkCookieManager

or is there another way to update or invalidate a cookiestring that is "auth=a=b=c=d". When I try "setCookie(domain, "auth=super"), no exception is thrown. Then I will call getCookie(domain) and it will return null. Within the XWalkCookieManager a UnsupportedOperationException is thrown and as a result null is returned. I don't have the source for so I can't dig deeper on why the unsupportedOperationException is being thrown.

Any advice on how to resolve this issue or a workaround? Thanks, Derek

1

There are 1 answers

0
darewreck On

I figured out the issue. It has to deal with the cordova plugin crosswalk webview version I was using.

Broken Version: cordova-plugin-crosswalk-webview 1.8.0 "Crosswalk WebView Engine" Working version: cordova-plugin-crosswalk-webview 2.2.0 "Crosswalk WebView Engine"

Actually, this addresses only the issue with not being able to set nested values within the cookie value.

Sometimes with Auth provider's cookies, you still won't be able to accurately invalidate the cookies. Not sure what the solution for that is.