Skip to content

Implement Magic Link Auth#307

Merged
mbklein merged 1 commit intodeploy/stagingfrom
5512-magic-link-auth
Apr 30, 2025
Merged

Implement Magic Link Auth#307
mbklein merged 1 commit intodeploy/stagingfrom
5512-magic-link-auth

Conversation

@mbklein
Copy link
Copy Markdown
Member

@mbklein mbklein commented Apr 29, 2025

Steps to Test

  1. make deps
  2. Add the following to env.json:
    "MAGIC_LINK_EMAIL_TEMPLATE": "dev-environment-magic-link-template",
    
  3. make serve
  4. To make sure NUSSO auth still works:
  • /auth/login?goto=/auth/whoami
  • /auth/logout
  • /auth/login/nusso?goto=/auth/whoami
  1. To test Magic Link auth:
  • /auth/login/magic?email=YOUR_EMAIL&goto=/auth/whoami
  • Check your email for the login link

While logged in using either/both methods, try to access some institution-only works and file sets. You should be able to access them when logged in via NUSSO but not via Magic.

Authz for works, file sets, and chat have been updated such that chat can be accessed by any logged in user, but protected works and file sets require a NUSSO login.

Notes

  • The /auth/login and /auth/callback routes have been replaced by /auth/{stage}/{provider}, where stage can be either login or callback, and provider can be either nusso or magic. It defaults to nusso for backward compatibility. Routing to the correct handler happens by requiring handlers/auth/${provider}-${stage}.js.
  • In order to keep the magic link as compact as possible, it's not a full JWT – it's a cryptographically signed buffer consisting of "email|returnUrl" + [6-byte representation of expiration timestamp].

Copy link
Copy Markdown
Contributor

@bmquinn bmquinn left a comment

Choose a reason for hiding this comment

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

Works great, the email template is awesome! 👏

magic_link

nusso whoami:
SCR-20250429-lmgl

magic link whoami:
SCR-20250429-lnbo

@kdid
Copy link
Copy Markdown
Contributor

kdid commented Apr 29, 2025

Since this is going into staging will we need to do some safe checking on the Next app before merge here?

https://github.com/nulib/dc-nextjs/blob/e1d6751c7bf69e92d883d6cecf5650bdb02784bb/components/Header/Super.tsx#L88

@kdid
Copy link
Copy Markdown
Contributor

kdid commented Apr 29, 2025

Also, can we go ahead and the provider to the chat metrics like we talked about?

@mbklein
Copy link
Copy Markdown
Member Author

mbklein commented Apr 29, 2025

Since this is going into staging will we need to do some safe checking on the Next app before merge here?

I wondered about this. What if we add a display field to the user token that auth providers are required to populate so the front end has fewer decisions to make? No safe checking or ||-ing down a list of fields until it finds one it can display?

@mbklein mbklein force-pushed the 5512-magic-link-auth branch from bce49a7 to 3df6ac2 Compare April 29, 2025 19:02
@kdid
Copy link
Copy Markdown
Contributor

kdid commented Apr 29, 2025

I wondered about this. What if we add a display field to the user token that auth providers are required to populate so the front end has fewer decisions to make? No safe checking or ||-ing down a list of fields until it finds one it can display?

I'm fine with whatever

@mbklein mbklein force-pushed the 5512-magic-link-auth branch 2 times, most recently from 4a8afc8 to e5f735c Compare April 29, 2025 21:19
@mbklein
Copy link
Copy Markdown
Member Author

mbklein commented Apr 29, 2025

Works great, the email template is awesome! 👏

It's a direct ripoff of the av-download email template design. 😄

Implement magic link auth routes

Write tests for magic link auth

Update OpenAPI spec for new auth routes
@mbklein mbklein force-pushed the 5512-magic-link-auth branch from e5f735c to ed474df Compare April 30, 2025 15:31
@mbklein mbklein merged commit e27162a into deploy/staging Apr 30, 2025
2 checks passed
@mbklein mbklein deleted the 5512-magic-link-auth branch April 30, 2025 15:58
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.

3 participants