Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookie handling #4227

Closed
4 tasks done
jesmrec opened this issue Nov 23, 2023 · 2 comments · Fixed by #4316
Closed
4 tasks done

Cookie handling #4227

jesmrec opened this issue Nov 23, 2023 · 2 comments · Fixed by #4316

Comments

@jesmrec
Copy link
Collaborator

jesmrec commented Nov 23, 2023

EPIC:

To do (basic auth):

  • How are cookies handled in the current code
  • Where are cookies stored
  • If cookies are persisted somehow, stop persisting them
  • Desired status: when app is closed/killed, cookies are vanished and app should ask for new ones once app is reopened

With this steps, will avoid that cookies will support session even though credentials changed or not valid anymore.

This is the preliminary step to implement:

so, key icon could be removed from there because new credentials will be automatically asked if needed.

@jesmrec jesmrec added this to the 4.2 - Current milestone Nov 23, 2023
@jesmrec jesmrec added p3-medium Normal priority p4-low Low priority and removed p3-medium Normal priority labels Nov 23, 2023
@JuancaG05 JuancaG05 added p3-medium Normal priority and removed p4-low Low priority labels Nov 24, 2023
@jesmrec jesmrec modified the milestones: 4.2 - Current, 4.3 - Future Jan 19, 2024
@Aitorbp Aitorbp self-assigned this Jan 29, 2024
@Aitorbp
Copy link
Contributor

Aitorbp commented Feb 2, 2024

Currently the application stores cookies in memory, during the execution of the application, but does not provide persistent cookie storage between application sessions. This means that when the app is closed and reopened new cookies are generated.

The contents of the cookies are stored in the cookieStore variable. This variable is passed as a parameter to the CookieJarlmpl. The CookieJarlmpl.kt class is where the methods in charge of cookie management are located, specifically, where getter and setter of the cookies are located.

This class in turn is assigned to the CookieJar interface in HttpClient.
final CookieJar cookieJar = new CookieJarImpl(mCookieStore);
To give more details of CookieJar, according to the documentation itself: This interface are responsible for selecting which cookies to accept and which to reject. A reasonable policy is to reject all cookies, though that may interfere with session-based authentication schemes that require cookies.

After this, CookieJar is sent in the httpClient request, which is called every time the app is closed and opened.
mOkHttpClient = buildNewOkHttpClient(sslSocketFactory, trustManager, cookieJar);

To check that the cookies are working correctly the following test has been done. From an OC10 account we opened and closed the app. We went to the website and changed the account password. We opened the app and as a result we received an "Authentication Fail" message with a 401 error.

@jesmrec
Copy link
Collaborator Author

jesmrec commented Feb 5, 2024

After checking the current status, these are the results:

  • When app is closed and reopened, an auth error is shown in snackbar if password changed as stated above ☝️

  • If app is not closed and password changes, there is a time slot in which requests are valid (probably supported by the cookie), but, finally discloses in a auth error that is displayed in the snackbar as previous test.

So, we are in the point to get rid of the key icon.

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

Successfully merging a pull request may close this issue.

3 participants