Hagay Myr
Hagay Myr

Reputation: 409

Rocket.Chat automatic login

We picked Rocket.Chat as an off-the-shelve open-source product for our team to communicate.

All we want is to be able to do the login part behind the scenes, so when the user goes to the Rocket.Chat URL (or any shortcut/routing URL or whatever) he will be already logged in.

The usernames and passwords are pre-set and known for that logic (don't bother security concerns).

I read the documentation for iFrame integration, but couldn't figure out how to utilize it for the described need. I also tried to understand the iframe-auth-example, but no use.

Is the iFrame integration approach is right at all for this requirement we have?

Would appreciate your help regarding the options we have and how to accomplish them.

Thanks in advance!

Upvotes: 3

Views: 2633

Answers (1)

Alberto Perez
Alberto Perez

Reputation: 2922

We are going throw a similar issue wi RC, you could do the following:

  • Use iFrame integration of Rocket.Chat:

In this approach, you could embed an invisible iFrame and every time the user makes login you could run a function that communicates with the iFrame and set the session credentials (Only token really, but must be a valid token for RC) to make automatic login to the user, and when he/she goes to the Chat link, they'll have the session already open.

<script>
window.parent.postMessage({
  event: 'login-with-token',
  loginToken: 'your-token'
}, 'http://your.rocket.chat.url');
</script>

  • OAUTH:

Another approach could be to create an OAUTH service and configure it as a login service for Rocket.Chat in that way if you share URL with you RC client you could launch a little function that makes auto-login with the OAUTH credentials from your main side into RC (This is our solution for the issue as of right now, but is a little more complicated than the first option) but this a more complicated approach.

Upvotes: 0

Related Questions