Author Topic: Howto passing string data to Roundcube tab?  (Read 779 times)

Offline Loguithat1955

  • Full Member
  • ***
  • Posts: 53
Howto passing string data to Roundcube tab?
« on: July 14, 2020, 07:55:03 AM »
Hi together,


when i have a Roundcube window open and logged in some browser tab, how can i send a string from another open tab (not the same domain) to the Roundcube window/tab? Every time i try this i have either the problem, that i run into a cross-origin problem or when i open a popup-window, i will be logged out of Roundcube. But i will try to send the data to some specific task/action inside of the opened Roundcube tab.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,638
    • http://SKaero.com/
Re: Howto passing string data to Roundcube tab?
« Reply #1 on: July 14, 2020, 09:46:07 AM »
If you control both Roundcube and and other site/domain you could use window.postMessage() https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

Offline Loguithat1955

  • Full Member
  • ***
  • Posts: 53
Re: Howto passing string data to Roundcube tab?
« Reply #2 on: July 14, 2020, 10:24:04 AM »
The purpose is it to use a JavaScript bookmarklet, to send the current url location.href to roundcube. In this case, I control only the roundcube instance. Maybe I can make use of the http_authentication plugin. But I didn't want load the whole roundcube instance in an pop-up.

Offline Loguithat1955

  • Full Member
  • ***
  • Posts: 53
Re: Howto passing string data to Roundcube tab?
« Reply #3 on: July 14, 2020, 02:40:09 PM »
What i didnt understand is: When a logged in Roundcube tab is open and i open manually a second tab and enter the same url, as in the first roundcube tab, i will be logged in, also in the second tab. But when i use a bookmarklet saved in the bookmarbar of a browser with the following Javascript:
Code: [Select]
let start = 'https://mydomain.com/roundcube/?_task=mail&_mbox=INBOX';window.open(start,'test','width=400,height=200',replace=false);[/size][/color][/size]...the popup isn't logged in. Instead, i get the login page and im also logged out in all other roundcube tabs.
[/color]

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,638
    • http://SKaero.com/
Re: Howto passing string data to Roundcube tab?
« Reply #4 on: July 15, 2020, 05:04:09 PM »
I'm not sure why the popup would do that, you could still use window.postMessage if you wanted to pass information back to an open Roundcube tab.

Offline Loguithat1955

  • Full Member
  • ***
  • Posts: 53
Re: Howto passing string data to Roundcube tab?
« Reply #5 on: July 16, 2020, 03:28:09 PM »
Its not a popup from Roundcube, its one generated by a bookmarklet. After some researching, i found, that  using a bookmarklet, is not the same as opening a new tab. The bookmarklet seems to work in browser context itself and that's why it cant re-use the session. Since it's a bookmarklet, i cant use postMessage for nearby the same reason. postmessage can only send messages to windows from where it was opened or parent iframes. Currently, i have no solution, i can think of. The only thing what could work, would be some sort of autologin, like the one in the autologin plugin or http_authentication. In this case, it will be independent from the actual session.

Using autologin is at least my eyes a little bit risky. I will not open a security hole. I know, i can open a connection, login, do only my defined action and nothing else and logout. But this will be a lot of request and actions for such a simple thing. Additionally the credentials have to be saved in the bookmarklet. Not the best idea in my eyes. Using http_authentication will not save the credentials somewhere, but it has nearby the same actions and requests and additionally, i have to enter for every request the credentials (either manually or by a password manager).
I think, using a bookmarklet is it not worth this much trouble. So, i f no one will request such a feature. I will put this on hold. For now, i have fixed and stabilized the bookmark plugin and thats all for now.

But many thx for your hints.