8000 [next]: Add Authentication POC by ahuseyn · Pull Request #2173 · wpengine/faustjs · GitHub
[go: up one dir, main page]

Skip to content

Conversation

ahuseyn
Copy link
Member
@ahuseyn ahuseyn commented Sep 12, 2025

Description

This PR implements authentication functionality to the Next.js kitchen-sink example and adds a new @faustjs/auth package. The major changes include implementing login, logout, and user session management hooks, integrating these features into the example app's UI, and updating dependencies and configuration to support authentication.

Authentication feature integration:

  • Added the new @faustjs/auth package, including its configuration defaults and peer dependencies (iron-session, jsonwebtoken).
  • Implemented authentication hooks (useLogin, useLogout, useUser) in packages/nextjs/pages/auth/hooks/, and exported them for use in Next.js apps.
  • Added proxy query root (/query) to do authenticated queries to the WordPress through Nextjs backend, without exposing credentials

Kitchen-sink example app updates:

  • Integrated login/logout UI and session management in the Header component, including a modal-based login form and user dropdown.
  • Added API route /api/session/[action].js for session actions using authRouter and the new session configuration.
    Supporting improvements:
  • resolveWpRoute.js added: New utility for resolving WordPress routes in a reusable way.
  • New, alternative preview approach added, using the user session.
  • Added a dedicated Login page for unauthenticated redirects

Enhanced the GraphQL client to allow passing additional request headers, supporting authenticated requests.

Related Issue(s):

@ahuseyn ahuseyn requested a review from a team as a code owner September 12, 2025 10:32
Copy link
changeset-bot bot commented Sep 12, 2025

⚠️ No Changeset found

Latest commit: b338d32

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

💥 An error occurred when fetching the changed packages and changesets in this PR
Some errors occurred when validating the changesets config:
The package or glob expression "@faustwp/core" specified in the `linked` option does not match any package in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.
The package or glob expression "@faustwp/cli" specified in the `linked` option does not match any package in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.
The package or glob expression "@faustwp/getting-started-example" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.

@ahuseyn ahuseyn linked an issue Sep 12, 2025 that may be closed by this pull request
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements authentication functionality for the Faust.js framework, introducing a new @faustjs/auth package and integrating authentication features into the Next.js kitchen-sink example. The implementation includes user login/logout, session management, and authenticated GraphQL requests.

  • Adds authentication hooks (useLogin, useLogout, useUser) for Next.js applications
  • Implements session-based authentication with token refresh capabilities
  • Integrates login UI and user session management into the example app

Reviewed Changes

Copilot reviewed 23 out of 25 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/auth/* New authentication package with handlers, configuration, and session management
packages/nextjs/pages/auth/* Authentication hooks for React components
packages/graphql/client.js Enhanced GraphQL client to support request headers for authenticated requests
examples/nextjs/kitchen-sink/src/components/* Login component and header with authentication UI
examples/nextjs/kitchen-sink/src/pages/* API routes for session management and alternative preview approach
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sorry, something went wrong.

ahuseyn and others added 3 commits September 23, 2025 11:26
@ahuseyn ahuseyn requested a review from Copilot September 23, 2025 13:45
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 23 out of 25 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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 3C43 .

[experimental]: PoC Authentication

1 participant

0