RocketChat / EmbeddedChat

An easy to use full-stack component (ReactJS) embedding Rocket.Chat into your webapp
https://www.npmjs.com/package/@embeddedchat/react
107 stars 214 forks source link

feat: http-only-cookie-auth + refactor EC component #590

Closed Spiral-Memory closed 2 weeks ago

Spiral-Memory commented 2 weeks ago

Brief Title

HTTP-Only Cookie-Based Login, Refactoring EC Component

Acceptance Criteria Fulfillment

Fixes #587

Video/Screenshots

https://github.com/RocketChat/EmbeddedChat/assets/78961432/24fdf4bf-34b5-4e66-b045-802d6fc428dd

Spiral-Memory commented 2 weeks ago

Hey @sidmohanty11

This PR is now ready for review. It mainly includes HTTP-only cookie-based authentication with the help of the EmbeddedChat RC app. It can handle all three scenarios: saving the token, getting the token, and deleting the token. When saveToken is called, the RC app will set an HTTP-only cookie. In all other requests, this token will always be included in the request. While getToken is called, the RC app will extract the token from the cookie and return it to the client. When deleting the token, the RC app will set an empty cookie in the browser. All of the functionality works fine and is shown in the video.

Other changes include cleaning up the EmbeddedChat component a little by removing all unnecessary global states (which can already be handled by ECOptions that's passed as context to all components, so using global states here is redundant). Additionally, all the layout-related functions have been moved to ChatLayout, and some minor issues have been fixed.

Kindly review this PR.

sidmohanty11 commented 2 weeks ago

Awesome work!