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

ADR - Use NextAuth #102

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

ADR - Use NextAuth #102

wants to merge 7 commits into from

Conversation

brandon-lent
Copy link

@brandon-lent brandon-lent commented Dec 20, 2022

Ticket

#179

Changes

Created a new ADR that:

  1. Weighs the pros and cons of using NextAuth in platform projects
  2. Provides an example implementation and guidance
  3. Helps us align on if this is the right solution

Context for reviewers

Most projects at Nava eventually require integration with an authentication provider. Using NextAuth simplifies this for us as it allows us to easily integrate authentication into Next.js applications.

For more context, we have a thread about this in slack here.

@brandon-lent brandon-lent self-assigned this Aug 1, 2023
@brandon-lent brandon-lent added this to the Authentication milestone Aug 1, 2023



## Example Implementation
Copy link
Author

Choose a reason for hiding this comment

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

I left an example in here. It's not a true implementation, in that I didn't verify it works as I don't have access to Login.gov API's. Assuming you have the proper secrets and domains in the content below, I don't see why it wouldn't work though. A potential improvement is mapping all of the login.gov attributes to typescript values to use in the return function.

Copy link
Author

Choose a reason for hiding this comment

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

LMK if we should scrap it, keep it, or move it somewhere else.

Copy link
Contributor

Choose a reason for hiding this comment

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

on the fence / don't feel super strongly about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's a useful reference, but I think we should mention in here that it's pseudo-code/untested.


## Decision Outcome

In-progress
Copy link
Author

Choose a reason for hiding this comment

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

ℹ️ Will update based on feedback and decisions.

@brandon-lent brandon-lent changed the title ADR - Auth Wrapper ADR - Use NextAuth Aug 1, 2023
Copy link
Contributor

@lorenyu lorenyu left a comment

Choose a reason for hiding this comment

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

@brandon-lent sorry for the late review, and thanks for putting this together!

after reading through and thinking about it more, i feel like i can't really recommend a solution until we have some proof of concepts.

some possible paths forward, we could explicitly call out next steps in the ADR to implement some proof of concepts and merge the ADR as an in progress / proposed state.

and then we can update the ADR in the future once we have more info from the technical spikes.

or alternatively we can put this on the backburner for now and have somebacklog tickets to do some spikes.


## Context and Problem Statement

A common requirement for government projects is working with an identity provider (Such as login.gov or AWS Cognito). It isn't uncommon for authentication providers to be changed during the lifecycle of a project. We want to ease the concern of being "locked in" to one provider. [NextAuth](https://next-auth.js.org/) fills this need by allowing us to easily swap identity providers and providing helpful functions for retrieving user data.
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure i agree with the part about

It isn't uncommon for authentication providers to be changed during the lifecycle of a project.

i think the goal is less about making it easy to switch auth providers, and more about eliminating the dependency of the rest of the template on any particular auth provider, so that project teams can use the Next.js application template even if they use a non-default provider by simply implementing a new adapter rather than needing to refactor the parts of the application that rely on auth functionality.




## Example Implementation
Copy link
Contributor

Choose a reason for hiding this comment

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

on the fence / don't feel super strongly about it.

@lorenyu
Copy link
Contributor

lorenyu commented Aug 4, 2023

also curious for @sawyerh 's opinion on this too

Copy link
Contributor

@sawyerh sawyerh left a comment

Choose a reason for hiding this comment

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

I agree with Loren's comment on the problem statement. I think we should probably update that part before merging.

we could explicitly call out next steps in the ADR to implement some proof of concepts and merge the ADR as an in progress / proposed state.

I like this idea too. I feel pretty good about recommending NextAuth, so merging this ADR as "proposed" + (someone) doing a proof-of-concept in a follow-up PR feels like a good next step.

I think you could potentially repurpose your code example at the bottom as a "Next steps" section, mentioning that we'd like to explore a proof of concept and "here's a pseudo example of what we could try"

3. Seamless integration with Next.js: NextAuth is designed to work seamlessly with Next.js applications. It provides a simple way to handle authentication in server-rendered and client-side rendered pages, ensuring a smooth user experience.

Cons:
1. Dependency on Next.js: NextAuth is tightly coupled with Next.js framework. If you are not using Next.js, integrating NextAuth into your existing stack may require additional effort.
Copy link
Contributor

Choose a reason for hiding this comment

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

This used to be true but they've recently pivoted to "Auth.js" and made it framework-agnostic: https://authjs.dev/ — for this template though, we'd still use the next-auth package.




## Example Implementation
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's a useful reference, but I think we should mention in here that it's pseudo-code/untested.

@sawyerh
Copy link
Contributor

sawyerh commented Nov 18, 2023

Update: proof-of-concept created #243

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