How to fork Cognito session

Viewed 194

Is it real to fork current user session?

For example:

We have domain.com with currently implemented authentication by AWS Cognito service with Amplify SDK on the client.

And now we have to move some big part of functional to subdomain sub.domain.com.

The main questions are:

  • can we have single signIn place at domain.com for both domains and just implement something like a session fork for sub.domain.com (cause if we will just share the same session between domain and subdomain there are some issues might be with refeshToken, cause it's disposable)
  • what is the best way to share sensitive data between domain and subdomain?

UPD: I'd try to explain more clear the logic that I have to implement

  1. there are two clients: domain.com (already exists) and sub.domain.com (the last one will be)
  2. authentication is handled by AWS Cognito at back and Amplify SDK at front
  3. domain.com and sub.domain.com have to share the same UserPool and UserPoolClient
  4. both clients have to communicate with the same endpoints which auth is required
  5. client at sub.domain.com mustn't have a signIn or signUp functioanlity
  6. but client at sub.domain.com still have to maintain and update the session (bacause of 4 step)
  7. so business wanna something like this behaviour:
    • if you go to sub.domain.com and you are already logged in at domain.com, everything is fine (user profile/some private data is shared between these two apps) and user can use app at sub.domain.com
    • if a user open sub.domain.com but he isn't authorized already at domain.com, app at sub.domain.com have to detect this and notify user that he have to authorize at domain.com at first. And after user did this, sub.domain.com will automaticaly get session from domain.com
  8. BUT, if we just share the same session/data from localstorage between two apps, we will have potential issues with refreshing/handling tokens

So, is there might be some various of implementation of this logic such as session fork, or something like that?

0 Answers
Related