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

Bearer tokens - add control-flow logic #1269

Open
4 tasks
dmfalke opened this issue Nov 5, 2024 · 0 comments
Open
4 tasks

Bearer tokens - add control-flow logic #1269

dmfalke opened this issue Nov 5, 2024 · 0 comments

Comments

@dmfalke
Copy link
Member

dmfalke commented Nov 5, 2024

We need to add a new client module to encapsulate handling interacting with user authorization. This module will be used by all client api modules. The design of this module, and how it will interact with other parts of the SPA, is still not finalized.

Bearer tokens are issued by the WDK Service in a cookie (named Authorization). This will change such that the web client will make a request to the WDK service to get an authorization token. There are two different mechanisms for requesting an authorization token for a logged-in user vs a logged-out user. The entry point for each mechanism depends on a user-flow:

User flow when the web client first loads:

  1. When the web client loads, check localstorage for an authorization token
  2. If one does not exist, or if one does exist and it is expired, request a guest authorization token from the new /guest-login endpoint
  3. If a 401 response is encountered with any service call, delete the existing Authorization token from localstorage and reload the page. Optionally, tell the user their session has been reset and they may need to log in again.

There will also be some changes to the login flow (the changes will be transparent to users):

  1. User clicks on the login link, which will use a new client route as the destination url. Note that the user will already have a guest token at this point, since they have to go through the website to click the login link.
  2. When the user successfully enters their credentials on oauth, they will be redirected to the new client route.
  3. The new client route will make a request to the /login endpoint, including the necessary query params that the oauth redirect included.
  4. The /login endpoint will respond with a bearer token as part of the response body.
  5. The client will replace the guest Authorization token with the new one.
  6. Finally, the client will redirect to the final destination.

Changes

  • Change redirect url for oauth to be a new client route.
  • New client route will make request to login endpoint to get bearer token.
  • Add new functions to call the /guest-login and /login enpoints.
  • Implement the user flows described above.

This depends on back end work. Issue to be linked.

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

No branches or pull requests

1 participant