Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a mechanism to handle re-authentication for expired tokens #554

Merged
merged 75 commits into from
Jan 8, 2025

Conversation

elopezanaya
Copy link
Contributor

@elopezanaya elopezanaya commented Nov 21, 2024

Thank you for your contribution. Before submitting this PR, please include:

Id of the task, bug, story or other reference.

Description

Include a description of the problem to be solved

for authenticated chats, token is obtained and passed just once, this causes a problem for chats that sessions extends beyond the expiration time of the token.

This includes "abandoned" sessions, which then will fail to call close session endpoints or post surveys, we have cases for other endpoints under same circusntances.

Solution Proposed

Detail what is the solution proposed, include links to design document if required or any other document required to support the solution

image

The combination of Facade and decorator pattern blended into the FacadeChatSDK component, which will wraps the chatSDK calls and evaluates expiration token before continues,

in case the token is expired, it will call again the getAuthToken function to obtain a new token and continue with the execution, in this way it ensures that flow continues without authentication issues.

NOTE : IT IS RESPONSABILITY OF THE DEVELOPER TO IMPLEMENT THE getAuthToken FUNCTION THAT RETURNS A VALID TOKEN

Acceptance criteria

Define what are the conditions to consider the PR has achieved the intended goal

  • Authentication chats evaluates token expiration
    • if token is expired , get new token and continue with flow
    • if token is not expired, continue with flow
    • if token is the same , throw error
    • is new token is expired, throw error

No authenticated Widgets

  • Flow is not blocked.

Test cases and evidence

Include what tests cases were considered, any evidence of testing for future references, to identify any corner cases, etc

image

Storybooks

image

Core Scenarios validated

  • Disconnected chats after long time, when user returns and close the widget , the widget is able to load post survey and perform close session call without 401 error
  • When agent ends the chat, and token is expired, chat reloads token and close session, without 401 error.
  • Load new token when token is expired during normal transactions for any available operation before calling an endpoint
    - If during the conversation, the token is expired, and the new token is invalid or the function doesnt return a new token, the widget wont crash, so the end user doesnt lost the conversation, but any interaction with backend will fail
    image

Sanity Tests

  • You have tested all changes in Popout mode
  • You have tested all changes in cross browsers i.e Edge, Chrome, Firefox, Safari and mobile devices(iOS and Android)
  • Your changes are included in the CHANGELOG

A11y

Please provide justification if any of the validations has been skipped.

@elopezanaya elopezanaya merged commit b7b6783 into microsoft:main Jan 8, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants