signalpoint / jDrupal

A JavaScript Library and API for Drupal Applications
http://jdrupal.tylerfrankenstein.com/
GNU General Public License v2.0
76 stars 38 forks source link

no session management being done #87

Open liquidcms opened 4 years ago

liquidcms commented 4 years ago

I had this same issue with jDrupal 7 and now jDrupal 8. I also see this common thread hidden in a few of the other issues posted here: there is no session management being done with jDrupal.

If i do a userLogin it works great and returns the uid as well as a csrf token. But this isn't used anywhere either at the client or the Drupal host. So any following command that requires the access rights of the user that was just logged in; will fail.

I am not entirely sure of how this ties together between client and host; but a lot of good work done here by Tyler it would be a shame to scrap it all. I know for D7 i had to write some hook_init() code to set the session when a login call was used. Not sure if this is the same thing missing in D8.

signalpoint commented 3 years ago

@liquidcms Thank you for reporting this, so long ago!

I am now experiencing this with cordova + jDrupal 7 + ios. It still works fine for web applications and within cordova + android.

I know for D7 i had to write some hook_init() code to set the session when a login call was used.

Do you have a sample of that code?

liquidcms commented 3 years ago

Hey Tyler, Been a while since I touched that project but did another last summer using jdrupal. Or I mean my very hacked up version and also tweaks in a custom module on the Drupal side. I'm reasonably sure of 2 things. 1. I'm likely doing a lot of things wrong. 2.it might have been better to just start from scratch and write my own interface layer. But I really wanted to leverage your REST code. I can send you the entire project if you like. It's an ionic project. Let me know if any interest.

Peter Lindstrom, LiquidCMS, sent from my mobile. Wednesday, 03 February 2021, 08:57p.m. -05:00 from Tyler Frankenstein notifications@github.com :

@liquidcms Thank you for reporting this, so long ago! I am now experiencing this with cordova + jDrupal 7 + ios. It still works fine for web applications and within cordova + android.

I know for D7 i had to write some hook_init() code to set the session when a login call was used. Do you have a sample of that code? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub , or unsubscribe .

signalpoint commented 3 years ago

Hi Peter ( @liquidcms ) !

Thank you for still having some belief in this project :) You were (maybe one of the last) power users over the years and I sure appreciated your feedback. With my youngest now 4 years old, I feel like I am finally coming up for some air.

I can send you the entire project if you like. It's an ionic project.

That would be great. I will send you an e-mail now and perhaps we can connect through there.

As for the problem itself, I've been researching it and there is a lot of noise out there about cordova + ios + cookies in general, and lots of people having problems with them persisting. I've found some potential leads (including some Drupal 7 specific ones in the Services issue queue that mention hook_init() and settings.php) and will report back if/when I find a solution!

signalpoint commented 3 years ago

Older versions of cordova + ios used UIWebView (cordova-ios 5), and now they use WKWebView (cordova-ios 6), which apparently has a bug with cookies. I learned about this while browsing cordova-ios issues related to cookies.

Luckily, there is a plugin and some slight server modification that appear to fix it:

  1. install cordova-plugin-wkwebview-file-xhr.
  2. set your server's Access-Control-Allow-Headers to allow Content-Type and X-CSRF-Token (I did this in .htaccess)

I am now able to use cordova + ios + jDrupal for a Drupal 7 site and sessions/cookies are properly handled and maintained!

@liquidcms In the hopes of closing this issue, were you having this problem with just your iOS apps, or was this also happening with Android apps and/or Web apps too?

I just published a cordova + jdrupal 7 app for both Android and iOS. Not until I began the iOS publication process did I encounter session/cookie problems. All other environments worked fine (web app + same domain as D7 site, android app).

liquidcms commented 3 years ago

I develop for Android first; so it would have been for that.

Peter Lindstrom

LiquidCMS - Content Solution Experts

Voice: +1 613.612.1419

Skype: liquidcms

Email: peter@LiquidCMS.ca

Web: http://www.liquidcms.ca/ www.LiquidCMS.ca

From: Tyler Frankenstein [mailto:notifications@github.com] Sent: February 8, 2021 4:54 PM To: signalpoint/jDrupal Cc: Peter Lindstrom; Mention Subject: Re: [signalpoint/jDrupal] no session management being done (#87)

Older versions of cordova + ios used UIWebView (cordova-ios 5), and now they use WKWebView (cordova-ios 6), which apparently has a bug with cookies https://bugs.webkit.org/show_bug.cgi?id=140205 . I learned about this while browsing cordova-ios issues related to cookies https://github.com/apache/cordova-ios/issues?q=is%3Aissue+cookies+ .

Luckily, there is a plugin and some slight server modification that appear to fix it:

  1. install cordova-plugin-wkwebview-file-xhr https://github.com/oracle/cordova-plugin-wkwebview-file-xhr .
  2. set your server's Access-Control-Allow-Headers to allow Content-Type and X-CSRF-Token (I did this in .htaccess)

I am now able to use cordova + ios + jDrupal for a Drupal 7 site and sessions/cookies are properly handled and maintained!

@liquidcms https://github.com/liquidcms In the hopes of closing this issue, were you having this problem with just your iOS apps, or was this also happening with Android apps and/or Web apps too?

I just published a cordova + jdrupal 7 app for both Android and iOS. Not until I began the iOS publication process did I encounter session/cookie problems. All other environments worked fine (web app + same domain as D7 site, android app).

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/signalpoint/jDrupal/issues/87#issuecomment-775488402 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AACW3Z3ET3JLVLEXPSIKQELS6 BMOVANCNFSM4IWYKMDQ . https://github.com/notifications/beacon/AACW3Z42UINAJVM2YUERC53S6BMOVA5CNFS M4IWYKMD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFY4QHEQ .gif

-- This email has been checked for viruses by AVG. https://www.avg.com

signalpoint commented 2 years ago

With the latest version of cordova and android, the dreaded cookies vs session management problems seem to be back. See my comment here for a potential solution.