Roundcube Community Forum

 

Howto passing string data to Roundcube tab?

Started by Loguithat1955, July 14, 2020, 07:55:03 AM

Previous topic - Next topic

Loguithat1955

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.

SKaero

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

Loguithat1955

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.

Loguithat1955

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:
let start = 'https://mydomain.com/roundcube/?_task=mail&_mbox=INBOX';window.open(start,'test','width=400,height=200',replace=false);[/size][/size]...the popup isn't logged in. Instead, i get the login page and im also logged out in all other roundcube tabs.

SKaero

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.

Loguithat1955

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.