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

feat(auth): implemented NextAuth with dummy provider #33

Merged
merged 13 commits into from
Oct 30, 2023

Conversation

connordoman
Copy link
Contributor

Signed-off-by: Connor Doman connor@connordoman.dev

The current configuration uses a dummy provider that checks a plaintext password against hardcoded values. NextAuth is modular so this can be changed later on with custom database and Cognito providers. NextAuth also recommends using a prefabbed provider like these to avoid opening security holes from babysitting passwords manually.

Currently, the example login UI at app/page.tsx redirects to NextAuth's template form for a custom provider. We will override this behavior in #30 by passing credentials into signIn().

The README also contains updated info for what's required in your .env.local (located inside front-end).

@connordoman connordoman added feat New feature or request area/front-end Front-end work area/back-end Back-end work labels Oct 23, 2023
@connordoman connordoman self-assigned this Oct 23, 2023
@connordoman
Copy link
Contributor Author

Resolves #29

@tthvo
Copy link
Contributor

tthvo commented Oct 23, 2023

Rebase on top of develop pls and resolve conflicts pls :))

@nganphan123
Copy link
Contributor

Screenshot 2023-10-22 221332

Seems like the user credential is not encrypted yet?

@connordoman
Copy link
Contributor Author

@nganphan123 No, it is currently only comparing plaintext to plaintext. Encryption probably deserves its own branch

@connordoman connordoman marked this pull request as ready for review October 23, 2023 06:53
app/front-end/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@tthvo tthvo left a comment

Choose a reason for hiding this comment

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

Hey @connordoman, thanks for the awesome research and work done here.

Editted: See #33 (comment) for updates.

Copy link
Contributor

@tthvo tthvo left a comment

Choose a reason for hiding this comment

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

@COSC-499-W2023/team-1 Hey team,

Have we considered exploring NextJS middleware with http://www.passportjs.org/? Then, we can break out of AuthNext requirements. Then, there can be 2 ways of authencation via HTTP Autho a rization Header

  • Basic: use users.properties file.
  • Beater: OAuth with Cognito. Supported only OpenShift (OCP).

This way, users on k8s can choose Basic Auth without having to find domain name. While on OCP, we can automatically grab that from Routes.

@connordoman
Copy link
Contributor Author

Looking into passport from the Next.js docs: https://nextjs.org/docs/pages/building-your-application/routing/authenticating#authentication-providers

Next.js also lists iron-session as a "stateless session utility" so I will check that out too.

Worst case scenario for Week 9 we use the system as-is and update it afterwards

Opened #39

@tthvo
Copy link
Contributor

tthvo commented Oct 25, 2023

Just editted my comment. I think when u set jwt in NextAuth configurations, that should use stateless session. However, it was not realyl clear tho haha.

@connordoman
Copy link
Contributor Author

I'll continue to look into it to see if there's a solution to our .env issue from today. My only concern up front is a more challenging integration with Cognito

@tthvo
Copy link
Contributor

tthvo commented Oct 25, 2023

@connordoman I think we can use this for cognito. https://www.npmjs.com/package/aws-jwt-verify. The web client can send a bearer token (taken from Cognito Auth) in all its request and the NextJS can just verify it on middleware.

@tthvo
Copy link
Contributor

tthvo commented Oct 25, 2023

Let's bring the suggestions above about setting up users.properties to middleware implementation and close this for now. And let's put AuthJS in backlog and come back this later on when we have time.

If passport works well, we can just use that and don't have to touch NextAuth anymore. Wdu think?

@tthvo
Copy link
Contributor

tthvo commented Oct 25, 2023

Close in favor of #39

@tthvo tthvo closed this Oct 25, 2023
@connordoman
Copy link
Contributor Author

@COSC-499-W2023/team-1 can we merge this

@connordoman connordoman removed the blocked Do not merge label Oct 30, 2023
@connordoman
Copy link
Contributor Author

@tthvo
Copy link
Contributor

tthvo commented Oct 30, 2023

Rebase on top of origin/develop first pls.

app/front-end/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@tthvo tthvo left a comment

Choose a reason for hiding this comment

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

Very nice indeed.

Copy link
Contributor

@MyStackOverflows MyStackOverflows left a comment

Choose a reason for hiding this comment

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

overall looks great, awesome work Connor!

@connordoman connordoman merged commit f693330 into develop Oct 30, 2023
4 checks passed
@tthvo tthvo deleted the gh-29-next-auth branch November 30, 2023 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/back-end Back-end work area/front-end Front-end work feat New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants