Skip to content

feat(nextjs): move to a session cookie to give the ability to do route level scope based authorization#104

Merged
brionmario merged 4 commits intoasgardeo:mainfrom
brionmario:next-user-components
Jul 11, 2025
Merged

feat(nextjs): move to a session cookie to give the ability to do route level scope based authorization#104
brionmario merged 4 commits intoasgardeo:mainfrom
brionmario:next-user-components

Conversation

@brionmario
Copy link
Member

@brionmario brionmario commented Jul 11, 2025

Purpose

This pull request introduces a comprehensive logging utility and updates session management functionality across multiple packages. The most significant changes include adding a universal logger utility, enhancing session validation and management, and improving error handling in session-dependent methods.

Logging Utility Enhancements:

  • Documentation for Logger Utility: Added detailed documentation in docs/developer/LOGGER.md outlining features, usage examples, and real-world applications for the new logging utility.
  • Logger Exports: Introduced logger-related exports in packages/javascript/src/index.ts, including logger, createLogger, createComponentLogger, and LogLevel.
  • Logger Unit Tests: Added comprehensive unit tests for the logger utility in packages/javascript/src/utils/__tests__/logger.test.ts to verify logging behavior, log levels, and custom configurations.

Session Management Enhancements:

  • Improved Session Validation: Enhanced session validation in packages/nextjs/src/middleware/asgardeoMiddleware.ts to support JWT-based sessions alongside legacy session formats. Deprecated the legacy session validation function. [1] [2]
  • Session Payload Integration: Updated packages/nextjs/src/server/AsgardeoProvider.tsx to prioritize JWT-based session payloads for authentication and organization handling, with fallbacks for legacy session IDs. [1] [2]

Error Handling Improvements:

  • Access Token Retrieval: Added error handling in packages/nextjs/src/AsgardeoNextClient.ts to reject requests without a session ID and propagate errors during token retrieval.
  • Organization Fetching: Improved error handling in packages/nextjs/src/server/actions/getMyOrganizations.ts to validate session ID and access token availability before proceeding with organization data retrieval.

Dependency Updates:

  • Added jose Library: Included the jose library in packages/nextjs/package.json to support JWT operations.

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 changed the title fix(nextjs): move to a session cookie fix(nextjs): move to a session cookie to give the ability to do route level authorization Jul 11, 2025
@brionmario brionmario changed the title fix(nextjs): move to a session cookie to give the ability to do route level authorization fix(nextjs): move to a session cookie to give the ability to do route level scope based authorization Jul 11, 2025
@brionmario brionmario changed the title fix(nextjs): move to a session cookie to give the ability to do route level scope based authorization feat(nextjs): move to a session cookie to give the ability to do route level scope based authorization Jul 11, 2025
@brionmario brionmario merged commit 3b9d30b 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