Skip to content

Conversation

@brionmario
Copy link
Member

Purpose

This pull request introduces significant updates to the packages/nextjs library, focusing on enhancing middleware functionality, improving session management, and adding utility functions. The changes simplify authentication handling, introduce route matching capabilities, and provide reusable utilities for session validation.

Middleware Enhancements:

  • Refactored AsgardeoMiddlewareOptions and AsgardeoMiddlewareContext to streamline authentication logic, replacing the previous AsgardeoAuth interface. Added methods like protectRoute, isSignedIn, and getSessionId for more granular control over authentication. [1] [2]
  • Updated middleware examples to showcase advanced usage scenarios, including route protection and custom logic for authentication.

Route Matching:

  • Added a new createRouteMatcher utility to simplify route protection by matching request paths against glob-like patterns. This utility supports advanced matching scenarios. [1] [2]

Session Management Utilities:

  • Introduced hasValidSession and getSessionIdFromRequest functions to validate and retrieve session IDs from cookies. These utilities are designed for reuse across middleware and other components.

Integration Updates:

  • Updated the samples/teamspace-nextjs/middleware.ts file to demonstrate how to use createRouteMatcher for protecting specific routes and integrate with the new protectRoute method.

Export Changes:

  • Added exports for createRouteMatcher and asgardeoMiddleware to make them accessible from the main library entry point.

Related Issues

Related PRs

  • N/A

Checklist

  • e2e cypress tests locally verified.
  • Manual test round performed and verified.
  • UX/UI review done on the final implementation.
  • Documentation provided. (Add links if there are any)
  • Unit tests provided. (Add links if there are any)
  • Integration tests provided. (Add links if there are any)

Security checks

@brionmario brionmario merged commit 57eb93b into asgardeo:main Jul 11, 2025
2 of 4 checks passed
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