Skip to content

Conversation

@atainter
Copy link
Contributor

No description provided.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR introduces support for multiple roles per user by adding a roles array field alongside the existing single role field throughout the AuthKit React Router authentication system. The changes are comprehensive and systematic, touching all relevant interfaces, functions, and test files.

The implementation adds a roles?: string[] property to all authentication-related interfaces including AccessToken, UserInfo, AuthorizedData, and UnauthorizedData. In the session management (session.ts), the roles are extracted from JWT tokens in the getClaimsFromAccessToken function and propagated through the refreshSession and authkitLoader functions. The main authentication function in auth.ts has been updated to extract and return the roles claim from JWT access tokens following the same pattern as other array fields like permissions and entitlements.

The change maintains full backward compatibility by keeping the existing role field intact while adding the optional roles array. This allows applications to gradually migrate from single-role to multi-role authorization models. The implementation follows established patterns in the codebase where array fields are already supported for permissions, entitlements, and feature flags.

Additionally, the PR includes a minor improvement to the developer experience by adding .idea to the .gitignore file to exclude JetBrains IDE configuration files from version control.

All test files have been comprehensively updated to include the new roles field, ensuring proper test coverage for the multi-role functionality across different authentication scenarios including session creation, token refresh, and organization switching.

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it maintains full backward compatibility
  • Score reflects well-structured, comprehensive changes that follow existing patterns and include thorough test coverage
  • No files require special attention as all changes are consistent and follow established conventions

6 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

sessionId: string;
organizationId: string | null;
role: string | null;
roles: string[] | null;
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, broken record here, why not string[] like permissions, entitlements, and featureFlags?

Copy link
Contributor Author

@atainter atainter Sep 18, 2025

Choose a reason for hiding this comment

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

Same thing - consistency with role. If you have a strong opinion about consistency with the other array fields, I can change it.

@atainter atainter merged commit 540632f into main Sep 18, 2025
6 checks passed
@atainter atainter deleted the at-roles-jwt-payload branch September 18, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants