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

Staging login callback redirect #291

Merged
merged 6 commits into from
Jun 1, 2023
Merged

Staging login callback redirect #291

merged 6 commits into from
Jun 1, 2023

Conversation

js0mmer
Copy link
Member

@js0mmer js0mmer commented May 5, 2023

Description

This PR allows logging in on staging instances. Since for each redirect_uri/callback url must be registered with Google Cloud for security reasons, the callbacks for staging instances do not work. However, by default, our code sends the callback back to prod instead of the staging instance. This PR makes use of this by passing the correct host to redirect the callback to in the state parameter in the Google authentication URL and on callback to prod, prod will redirect callback requests that are meant for staging instances back to the staging instance.

The redirection couldn't be tested as is with prod without actually merging to master and testing on prod... so I tested it by changing the callback URL from the prod domain environment variable to http://localhost:5000/api/users/callback. Then I ran PeterPortal locally and tried logging in on the staging instance and it correctly sent the callback to localhost and my local server redirected it back to the staging instance, successfully signing me in on the staging instance. I think I'll leave that right now for the sake of testing during review and will change it back before I merge.

Steps to verify/test this change:

  • Checkout this branch and run the API locally
  • Verify changes work as expected on staging instance

Final Checks:

  • Verify successful deployment
  • Delete branch

(optional)

  • Write tests
  • Write documentation

api/src/config/passport.ts Outdated Show resolved Hide resolved
@js0mmer js0mmer marked this pull request as ready for review May 16, 2023 04:56
@js0mmer js0mmer self-assigned this May 27, 2023
Copy link
Member

@ethanwong16 ethanwong16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Great work @js0mmer :))
Feel free to change back the callbackURL prod env variable and merge whenever you'd like

@github-actions
Copy link

github-actions bot commented Jun 1, 2023

Deployed staging instance to https://staging-291.peterportal.org

@js0mmer js0mmer merged commit cedc558 into master Jun 1, 2023
@js0mmer js0mmer deleted the jacob/staging-login branch June 1, 2023 06:55
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.

2 participants