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: support server-side auth flows with Cognito managed login #14168

Merged
merged 24 commits into from
Feb 11, 2025

Conversation

HuiSF
Copy link
Member

@HuiSF HuiSF commented Jan 27, 2025

Description of changes

Merging the server-side auth feature branch.

Feature code change details see commits messages of this PR.

Squash and merge is required!

Issue #, if available

Description of how you validated changes

Checklist

  • PR description included
  • yarn test passes
  • Unit Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

Checklist for repo maintainers

  • Verify E2E tests for existing workflows are working as expected or add E2E tests for newly added workflows
  • New source file paths included in this PR have been added to CODEOWNERS, if appropriate

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

HuiSF added 17 commits January 27, 2025 14:59
#13788)

* feat(aws-amplify|adapter-nextjs): add runtimeOptions.cookies to createServerRunner

* chore: resolve comments

* chore(adapter-nextjs): adapt the latest impl. changes
…er (#13801)

* feat(aws-amplify|adapter-nextjs): add runtimeOptions.cookies to createServerRunner

* feat(adapter-nextjs): add createAuthRouteHandlers to createServerRunner

* chore(adapter-nextjs): resolve comments

* chore(adapter-nextjs): remove unnecessary check
…ed UI (#13827)

* chore(auth): export necessary utilities and types to support server-side auth

* chore(aws-amplify): export necessary utilities to support server-side auth

* feat(adapter-nextjs): server-side auth api route integrating cognito hosted ui

* chore(adapter-nextjs): resolve comments

* refactor(adapter-nextjs): remove redundant username fallback
…sign-in and sign-up (#13839)

* feat(adapter-nextjs): add user has signed in check before initiating sign-in and sign-up

* chore(adapter-nextjs): rename hasUserSignedIn to hasActiveUserSession
…13841)

* feat(adapter-nextjs): allow cookie secure: false with non-SSL domain

* fix(adapter-nextjs): wrong naming and impl. of isSSLOrigin

* chore(adapter-nextjs): resolve comment
refactor(adapter-nextjs): remove redundant clockDrift cookie ⤵️

Reasons:
  1. token exachange is happening on a server - and production server rarely has wrong system time
  2. when setting token cookies from server, it uses Max-Age header which is relative to the client system time. Clock drift became irrelevant
  3. surely we can argue sever system time can go wrong too, however, a Next.js app API route can be executed on different servers (load balancing), there is no source of truth to generate a clock drift value
#14116)

* feat(adapter-nextjs): surface redirect error and sign-in timeout error

* feat(adapter-nextjs): expose both error and errorDescription

* chore(adapter-nextjs): remove unnecessary undefined fallback
* fix(core): generateRandomString uses Math.random()

* chore(core): use better test to test actual logic
@HuiSF HuiSF requested review from sktimalsina, cshfang, pranavosu and a team as code owners January 27, 2025 23:02
@HuiSF HuiSF changed the title feat(adapter-nextjs): support server-side auth flows with Cognito managed login feat: support server-side auth flows with Cognito managed login Jan 27, 2025
Copy link

⚠️ This PR includes changes to the "aws-amplify" package.json file, which can have library-wide implications.

Please ensure that this PR:

  • Does not manually change "@aws-amplify/*" dependency versions, which may misalign core dependencies across the library
  • Remove any export paths without a major version bump

A repository administrator is required to review this change.

cshfang
cshfang previously approved these changes Jan 27, 2025
Copy link
Member

@cshfang cshfang left a comment

Choose a reason for hiding this comment

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

Assuming all the member commits have been independently reviewed when going into the feature branch

Comment on lines +34 to +39
"./api/internals": {
"types": "./dist/esm/api/internals.d.ts",
"import": "./dist/esm/api/internals.mjs",
"require": "./dist/cjs/api/internals.js",
"react-native": "./src/api/internals.ts"
},
Copy link
Member

Choose a reason for hiding this comment

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

Why are we exposing the /apii/internals export subpath from aws-amplify rather than @aws-amplify/core?

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean importing things from @aws-amplify/core? If so, this is due to @aws-amplify/adapter-nextjs has only aws-amplify as a peer dependency, and it cannot add @aws-amplify/core as a dependency.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure that is entirely correct. Let's discuss offline

cshfang
cshfang previously approved these changes Feb 3, 2025
Copy link
Member

@jjarvisp jjarvisp left a comment

Choose a reason for hiding this comment

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

Isolated commits and individual PRs reviewed independently.

Copy link
Member

@ashika112 ashika112 left a comment

Choose a reason for hiding this comment

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

Approving as admin for package.json changes

@HuiSF HuiSF merged commit 825d338 into main Feb 11, 2025
30 checks passed
@HuiSF HuiSF deleted the feat/server-auth/main branch February 11, 2025 17:43
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.

5 participants