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

Redirect from auth to a blank page #34

Merged
merged 3 commits into from
Oct 5, 2023
Merged

Redirect from auth to a blank page #34

merged 3 commits into from
Oct 5, 2023

Conversation

bcspragu
Copy link
Collaborator

@bcspragu bcspragu commented Oct 4, 2023

@bcspragu bcspragu requested a review from gbdubs October 4, 2023 20:19
@bcspragu bcspragu changed the title Create a new /blank page which does what it says on the tin...nothing Redirect from auth to a blank page Oct 4, 2023
@@ -5,4 +5,6 @@ MSAL_USER_FLOW_NAME=B2C_1_susi_dev
MSAL_USER_FLOW_AUTHORITY=https://rmiauthdev.b2clogin.com/rmiauthdev.onmicrosoft.com/B2C_1_susi_dev
MSAL_AUTHORITY_DOMAIN=rmiauthdev.b2clogin.com
MSAL_CLIENT_ID=218f47ee-11b1-459a-b914-b7fa6f107e7b
MSAL_REDIRECT_URI=https://pacta.dev.rmi.siliconally.dev
# See https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/initialization.md#redirecturi-considerations
MSAL_REDIRECT_URI=https://pacta.dev.rmi.siliconally.dev/blank
Copy link
Contributor

Choose a reason for hiding this comment

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

meganit - can we name this something clearer? blank has no context, and is more likely to be thought of as new tab etc. Very odd ms requires this - let's make the URL clear the purpose, since nothing else on the page will lol. azure-ad-redirect-destination ex

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a very reasonable and sensible comment, but I'm going to stick with /blank for a few reasons:

  1. Pure laziness - I already submitted the TF PR and don't want to deploy both frontends + TF again
  2. /blank is their recommendation, and I've seen similar things elsewhere. Not sure how strong of a convention it is, but getting a blank page at /blank seems reasonable.
  3. Only frontend developers associate new tab and blank (i.e. target=_blank)
  4. Nobody will ever actually see this, the only time it shows up is for 0.1seconds after signing in, in the Azure popup, just before it closes. The main site window will never show /blank

// https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/initialization.md#redirecturi-considerations

definePageMeta({
layout: 'empty'
Copy link
Contributor

Choose a reason for hiding this comment

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

another (maybe simpler) approach? Through an index.html in some folder in the public directory. That way nuxt could never mess this up?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did consider it, and that would also be a totally reasonable approach. I'm going to stick to this for a few reasons:

  • The redirectUri actually is important in the redirect flow (we currently use the popup flow). We've seen on other projects that there are scenarios (PWAs, some mobile browsers) where popup mode doesn't play nice and you want to fallback to redirect mode, so we're going to want to be able to add little niceties to this page over time, like taking query parameters and doing stuff with them.
  • I think there's utility in having the same <head> matter that the rest of the site has

I agree there's a minor risk that something like middleware causes problems with this page, but since the page is only ever shown for a fraction of a second, I think the risk is minimal.

@bcspragu bcspragu merged commit b146009 into main Oct 5, 2023
2 checks passed
@bcspragu bcspragu deleted the brandon/blank branch October 5, 2023 17:03
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