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

Nextauth ms2 #127

Merged
merged 17 commits into from
Nov 12, 2023
Merged

Nextauth ms2 #127

merged 17 commits into from
Nov 12, 2023

Conversation

FelipeTrost
Copy link
Contributor

Summary

Used nextauth for auth in ms2 and implemented a middleware in the old ms that reads the nextauth cookies to authenticate requests.

Details MS2

  • removed useAuthStore, auth status can be checked with useSession provided by nextauth
  • new abilityStore
  • MS2 fetches the ability from the old ms after login
  • Auth guard runs in the server with getServerSession
  • Adapted all page.tsx files to be rendered in the server

Details Old MS

  • stop using loginSession if API_ONLY = true
  • implemented getSessionFromCookie to read cookies set by nextauth and fill the req.session field when API_ONLY = true
  • don't validate request's csrfToken if API_ONLY = true

Comment on lines 41 to 46
if (error) return;
<Result
status="error"
title="Failed to fetch role"
subTitle="An error ocurred while fetching role, please try again."
/>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Empty return, probably typo?

Copy link
Contributor Author

@FelipeTrost FelipeTrost Nov 11, 2023

Choose a reason for hiding this comment

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

I fixed it in my last commit.

dataIndex: 'id',
key: 'tooltip',
title: '',
with: 100,
Copy link
Contributor

Choose a reason for hiding this comment

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

typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed it with in last commit.

@FelipeTrost
Copy link
Contributor Author

In my recent commits, I mainly made the following changes:

  • MS2 now uses the environments repo (if it exists) for auth0 credential
  • MS(old) and MS2 share the NextAuth secret through the environments repo, if it is not set in development, a default value is used
  • Used csrf token for MS(old)

@OhKai OhKai merged commit 5c3a8c0 into main Nov 12, 2023
10 checks passed
@OhKai OhKai deleted the nextauth-ms2 branch November 12, 2023 13:40
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