Repository navigation
feat: api keys management (EE) - #1665
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughAdds API key support across client and server: client UI (components, pages, routes), queries, services, types, i18n keys, Mantine dates dependency and styles; server JWT/api-key payload, token generation and validation, CASL permissions, workspace API settings persistence, pagination admin flag, DB migration and types, and a workspace repo method. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant UI as Client UI
participant Hooks as React Query Hooks
participant Svc as API Key Service
participant Server as Server API
User->>UI: Open API Keys page
UI->>Hooks: useGetApiKeysQuery({ page, adminView? })
Hooks->>Svc: getApiKeys(params)
Svc->>Server: POST /api-keys { page, adminView? }
Server-->>Svc: Paginated keys
Svc-->>Hooks: Data
Hooks-->>UI: Render table
UI->>Hooks: create/update/revoke mutation
Hooks->>Svc: createApiKey/updateApiKey/revokeApiKey(...)
Svc->>Server: POST /api-keys/* (create/update/revoke)
Server-->>Svc: Result
Svc-->>Hooks: Mutation result
Hooks->>UI: Invalidate "api-key-list", show toast, refresh
sequenceDiagram
autonumber
participant Client as External Client
participant Server as Server
participant JWT as JwtStrategy
participant EE as EE ApiKeyService
Client->>Server: Request with Authorization: Bearer <JWT>
Server->>JWT: validate(req, payload)
alt payload.type == 'api_key'
JWT->>JWT: verify workspaceId and payload shape
JWT->>EE: dynamic require -> ApiKeyService.validateApiKey(payload)
EE-->>JWT: Valid / Invalid
JWT-->>Server: Auth result (user/context)
else
JWT->>JWT: validate regular access token (JwtType.ACCESS)
JWT-->>Server: Auth result
end
Server-->>Client: Response
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 11
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/client/src/features/group/queries/group-query.ts (1)
135-140: Internationalize the error message for consistency.The error message "Failed to add group members" is hardcoded in English, which is inconsistent with the i18n pattern applied to success messages throughout this file.
Apply this diff to internationalize the error message:
onError: () => { notifications.show({ - message: "Failed to add group members", + message: t("Failed to add group members"), color: "red", }); },
🧹 Nitpick comments (12)
apps/client/src/features/group/components/create-group-form.tsx (1)
4-9: LGTM! Migration to external resolver package is correct.The switch from Mantine's built-in
zodResolverto themantine-form-zod-resolverpackage is implemented correctly. The validation behavior remains unchanged since the external package provides the same API.Optional: Consider standardizing quote style across files.
This file uses single quotes for the
mantine-form-zod-resolverimport, whileedit-group-form.tsxuses double quotes. For consistency, consider aligning the quote style across both files.apps/client/src/features/group/queries/group-query.ts (1)
57-73: Consider completing i18n coverage for consistency.The
useCreateGroupMutationfunction at line 67 still uses a hardcoded English success message. For consistency with the internationalization changes applied to other mutations in this file, consider translating this message as well.To complete the i18n coverage, you could apply:
export function useCreateGroupMutation() { const queryClient = useQueryClient(); + const { t } = useTranslation(); return useMutation<IGroup, Error, Partial<IGroup>>({ mutationFn: (data) => createGroup(data), onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["groups"], }); - notifications.show({ message: "Group created successfully" }); + notifications.show({ message: t("Group created successfully") }); },apps/server/src/database/migrations/20250912T101500-api-keys.ts (1)
9-9: Consider making the name column NOT NULL.The
namecolumn is nullable, which allows creating API keys without descriptive names. This could make it difficult for users to identify and manage their API keys, especially when multiple keys exist.Apply this diff if a name should be required:
- .addColumn('name', 'text', (col) => col) + .addColumn('name', 'text', (col) => col.notNull())apps/server/src/core/workspace/services/workspace.service.ts (1)
306-313: Consider extracting the API settings key to a constant.The hardcoded string
'restrictToAdmins'passed toupdateApiSettingscould be extracted to a constant for better maintainability and to prevent typos.Consider defining a constant at the top of the file or in a shared constants file:
const API_SETTING_KEYS = { RESTRICT_TO_ADMINS: 'restrictToAdmins', } as const;Then use it:
- await this.workspaceRepo.updateApiSettings( - workspaceId, - 'restrictToAdmins', - updateWorkspaceDto.restrictApiToAdmins, - ); + await this.workspaceRepo.updateApiSettings( + workspaceId, + API_SETTING_KEYS.RESTRICT_TO_ADMINS, + updateWorkspaceDto.restrictApiToAdmins, + );apps/client/src/ee/api-key/components/update-api-key-modal.tsx (1)
42-50: Consider tightening the type signature.The
handleSubmitfunction parameter type{ name?: string }allowsnameto be optional, but the zod schema requires it to be a non-empty string. This mismatch is minor but could be more precise.Consider updating the type signature to match the schema:
- const handleSubmit = async (data: { name?: string }) => { + const handleSubmit = async (data: FormValues) => { const apiKeyData = { apiKeyId: apiKey.id, name: data.name, };apps/client/src/ee/api-key/pages/user-api-keys.tsx (1)
17-106: Consider extracting shared logic to reduce duplication.The user-api-keys and workspace-api-keys pages have significant code duplication. The only differences are the query parameters,
showUserColumnprop, and the admin check.Consider creating a shared component or hook that accepts configuration:
// Example shared component function ApiKeysPage({ title, description, showUserColumn, adminView, requireAdmin = false, }: { title: string; description?: string; showUserColumn: boolean; adminView?: boolean; requireAdmin?: boolean; }) { // ... shared logic } // Then use in both pages: // user-api-keys.tsx export default function UserApiKeys() { return ( <ApiKeysPage title="API keys" showUserColumn={false} adminView={false} /> ); } // workspace-api-keys.tsx export default function WorkspaceApiKeys() { return ( <ApiKeysPage title="API management" description="Manage API keys for all users in the workspace" showUserColumn={true} adminView={true} requireAdmin={true} /> ); }apps/server/src/core/auth/strategies/jwt.strategy.ts (1)
67-91: Consider using dynamic import() instead of require().The current implementation uses
require()for dynamic module loading, which is a CommonJS pattern. In modern ES modules and NestJS, consider using dynamicimport()or configuring the module as an optional dependency through NestJS's module system.Alternative approach using dynamic import:
private async validateApiKey(req: any, payload: JwtApiKeyPayload) { try { const ApiKeyModule = await import('./../../../ee/api-key/api-key.service'); const ApiKeyService = this.moduleRef.get(ApiKeyModule.ApiKeyService, { strict: false, }); return ApiKeyService.validateApiKey(payload); } catch (err) { this.logger.debug( 'API Key module requested but EE module not bundled in this build', ); throw new UnauthorizedException('Enterprise API Key module missing'); } }This approach is more compatible with ES modules and handles the async nature of module loading more explicitly.
apps/client/src/ee/api-key/queries/api-key-query.ts (5)
21-31: Consider relaxing cache invalidation settings.Setting
staleTime: 0andgcTime: 0means the data is always treated as stale and the cache is cleared immediately when the query unmounts. This can lead to unnecessary refetches and poor UX, especially when navigating back to the page.Consider using more reasonable cache times:
return useQuery({ queryKey: ["api-key-list", params], queryFn: () => getApiKeys(params), - staleTime: 0, - gcTime: 0, + staleTime: 30 * 1000, // 30 seconds + gcTime: 5 * 60 * 1000, // 5 minutes placeholderData: keepPreviousData, });This provides a better balance between data freshness and performance. Since mutations already invalidate the cache, users will see fresh data after create/update/revoke operations.
52-55: Improve type safety for error handling.Accessing
error["response"]?.data?.messageuses unsafe property access. The error object might not have this structure, especially for network errors.Add type guard or safer error handling:
onError: (error) => { - const errorMessage = error["response"]?.data?.message; + const errorMessage = error instanceof Error && 'response' in error + ? (error as any).response?.data?.message + : error.message || t("An error occurred"); notifications.show({ message: errorMessage, color: "red" }); },Or define a proper type for API errors in your error handling utilities.
72-75: Same type safety issue as useRevokeApiKeyMutation.The error handling here has the same unsafe property access issue.
Apply the same fix as suggested for
useRevokeApiKeyMutationat lines 52-55.
92-95: Same type safety issue in error handling.Apply the same type-safe error handling pattern as suggested for the other mutations.
47-50: Simplify query invalidation pattern.The current predicate-based invalidation is more complex than needed. React Query provides simpler methods for invalidating queries by key prefix.
Use the simpler exact or prefix matching:
- queryClient.invalidateQueries({ - predicate: (item) => - ["api-key-list"].includes(item.queryKey[0] as string), - }); + queryClient.invalidateQueries({ + queryKey: ["api-key-list"], + });This will invalidate all queries starting with
["api-key-list"], which is the same behavior but with clearer intent.Also applies to: 67-70, 87-90
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (35)
apps/client/package.json(1 hunks)apps/client/public/locales/en-US/translation.json(1 hunks)apps/client/src/App.tsx(2 hunks)apps/client/src/components/common/no-table-results.tsx(1 hunks)apps/client/src/components/settings/settings-queries.tsx(2 hunks)apps/client/src/components/settings/settings-sidebar.tsx(4 hunks)apps/client/src/ee/api-key/components/api-key-created-modal.tsx(1 hunks)apps/client/src/ee/api-key/components/api-key-table.tsx(1 hunks)apps/client/src/ee/api-key/components/create-api-key-modal.tsx(1 hunks)apps/client/src/ee/api-key/components/revoke-api-key-modal.tsx(1 hunks)apps/client/src/ee/api-key/components/update-api-key-modal.tsx(1 hunks)apps/client/src/ee/api-key/index.ts(1 hunks)apps/client/src/ee/api-key/pages/user-api-keys.tsx(1 hunks)apps/client/src/ee/api-key/pages/workspace-api-keys.tsx(1 hunks)apps/client/src/ee/api-key/queries/api-key-query.ts(1 hunks)apps/client/src/ee/api-key/services/api-key-service.ts(1 hunks)apps/client/src/ee/api-key/types/api-key.types.ts(1 hunks)apps/client/src/features/group/components/create-group-form.tsx(1 hunks)apps/client/src/features/group/components/edit-group-form.tsx(1 hunks)apps/client/src/features/group/queries/group-query.ts(6 hunks)apps/client/src/lib/types.ts(1 hunks)apps/client/src/main.tsx(1 hunks)apps/server/src/core/auth/dto/jwt-payload.ts(2 hunks)apps/server/src/core/auth/services/token.service.ts(3 hunks)apps/server/src/core/auth/strategies/jwt.strategy.ts(4 hunks)apps/server/src/core/casl/abilities/workspace-ability.factory.ts(3 hunks)apps/server/src/core/casl/interfaces/workspace-ability.type.ts(1 hunks)apps/server/src/core/workspace/dto/update-workspace.dto.ts(1 hunks)apps/server/src/core/workspace/services/workspace.service.ts(1 hunks)apps/server/src/database/migrations/20250912T101500-api-keys.ts(1 hunks)apps/server/src/database/pagination/pagination-options.ts(2 hunks)apps/server/src/database/repos/workspace/workspace.repo.ts(1 hunks)apps/server/src/database/types/db.d.ts(3 hunks)apps/server/src/database/types/entity.types.ts(2 hunks)apps/server/src/ee(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (17)
apps/server/src/core/casl/interfaces/workspace-ability.type.ts (1)
apps/server/src/database/types/entity.types.ts (3)
Space(43-43)Group(55-55)Attachment(80-80)
apps/client/src/ee/api-key/queries/api-key-query.ts (4)
apps/client/src/lib/types.ts (2)
QueryParams(1-6)IPagination(36-39)apps/client/src/ee/api-key/types/api-key.types.ts (3)
IApiKey(3-13)ICreateApiKeyRequest(15-18)IUpdateApiKeyRequest(20-23)apps/client/src/ee/api-key/services/api-key-service.ts (4)
getApiKeys(9-14)revokeApiKey(30-32)createApiKey(16-21)updateApiKey(23-28)apps/client/src/main.tsx (1)
queryClient(25-34)
apps/client/src/components/settings/settings-queries.tsx (2)
apps/client/src/main.tsx (1)
queryClient(25-34)apps/client/src/ee/api-key/services/api-key-service.ts (1)
getApiKeys(9-14)
apps/client/src/ee/api-key/pages/user-api-keys.tsx (11)
apps/client/src/hooks/use-paginate-and-search.tsx (1)
usePaginateAndSearch(3-17)apps/client/src/ee/api-key/types/api-key.types.ts (1)
IApiKey(3-13)apps/client/src/ee/api-key/queries/api-key-query.ts (1)
useGetApiKeysQuery(21-31)apps/client/src/lib/config.ts (1)
getAppName(11-13)apps/client/src/components/settings/settings-title.tsx (1)
SettingsTitle(4-13)apps/client/src/ee/api-key/components/api-key-table.tsx (1)
ApiKeyTable(18-143)apps/client/src/components/common/paginate.tsx (1)
Paginate(11-44)apps/client/src/ee/api-key/components/create-api-key-modal.tsx (1)
CreateApiKeyModal(29-153)apps/client/src/ee/api-key/components/api-key-created-modal.tsx (1)
ApiKeyCreatedModal(21-72)apps/client/src/ee/api-key/components/update-api-key-modal.tsx (1)
UpdateApiKeyModal(21-80)apps/client/src/ee/api-key/components/revoke-api-key-modal.tsx (1)
RevokeApiKeyModal(13-62)
apps/server/src/core/auth/services/token.service.ts (2)
apps/server/src/database/types/entity.types.ts (1)
User(38-38)apps/server/src/core/auth/dto/jwt-payload.ts (1)
JwtApiKeyPayload(41-46)
apps/client/src/ee/api-key/components/api-key-created-modal.tsx (2)
apps/client/src/ee/api-key/types/api-key.types.ts (1)
IApiKey(3-13)apps/client/src/components/common/copy.tsx (1)
CopyTextButton(9-31)
apps/client/src/ee/api-key/types/api-key.types.ts (1)
apps/client/src/features/user/types/user.types.ts (1)
IUser(3-24)
apps/server/src/database/types/entity.types.ts (1)
apps/server/src/database/types/db.d.ts (1)
ApiKeys(33-43)
apps/client/src/components/settings/settings-sidebar.tsx (1)
apps/client/src/components/settings/settings-queries.tsx (2)
prefetchApiKeys(70-75)prefetchApiKeyManagement(77-82)
apps/client/src/App.tsx (2)
apps/client/src/ee/api-key/pages/user-api-keys.tsx (1)
UserApiKeys(17-106)apps/client/src/ee/api-key/pages/workspace-api-keys.tsx (1)
WorkspaceApiKeys(18-117)
apps/server/src/core/auth/strategies/jwt.strategy.ts (2)
apps/server/src/database/types/kysely.types.ts (1)
KyselyDB(4-4)apps/server/src/core/auth/dto/jwt-payload.ts (2)
JwtPayload(9-14)JwtApiKeyPayload(41-46)
apps/client/src/ee/api-key/services/api-key-service.ts (2)
apps/client/src/lib/types.ts (2)
QueryParams(1-6)IPagination(36-39)apps/client/src/ee/api-key/types/api-key.types.ts (3)
IApiKey(3-13)ICreateApiKeyRequest(15-18)IUpdateApiKeyRequest(20-23)
apps/client/src/ee/api-key/components/create-api-key-modal.tsx (2)
apps/client/src/ee/api-key/types/api-key.types.ts (1)
IApiKey(3-13)apps/client/src/ee/api-key/queries/api-key-query.ts (1)
useCreateApiKeyMutation(59-77)
apps/client/src/ee/api-key/components/revoke-api-key-modal.tsx (2)
apps/client/src/ee/api-key/types/api-key.types.ts (1)
IApiKey(3-13)apps/client/src/ee/api-key/queries/api-key-query.ts (1)
useRevokeApiKeyMutation(33-57)
apps/client/src/ee/api-key/components/update-api-key-modal.tsx (2)
apps/client/src/ee/api-key/types/api-key.types.ts (1)
IApiKey(3-13)apps/client/src/ee/api-key/queries/api-key-query.ts (1)
useUpdateApiKeyMutation(79-97)
apps/client/src/ee/api-key/pages/workspace-api-keys.tsx (12)
apps/client/src/hooks/use-paginate-and-search.tsx (1)
usePaginateAndSearch(3-17)apps/client/src/ee/api-key/types/api-key.types.ts (1)
IApiKey(3-13)apps/client/src/ee/api-key/queries/api-key-query.ts (1)
useGetApiKeysQuery(21-31)apps/client/src/hooks/use-user-role.tsx (1)
useUserRole(5-17)apps/client/src/lib/config.ts (1)
getAppName(11-13)apps/client/src/components/settings/settings-title.tsx (1)
SettingsTitle(4-13)apps/client/src/ee/api-key/components/api-key-table.tsx (1)
ApiKeyTable(18-143)apps/client/src/components/common/paginate.tsx (1)
Paginate(11-44)apps/client/src/ee/api-key/components/create-api-key-modal.tsx (1)
CreateApiKeyModal(29-153)apps/client/src/ee/api-key/components/api-key-created-modal.tsx (1)
ApiKeyCreatedModal(21-72)apps/client/src/ee/api-key/components/update-api-key-modal.tsx (1)
UpdateApiKeyModal(21-80)apps/client/src/ee/api-key/components/revoke-api-key-modal.tsx (1)
RevokeApiKeyModal(13-62)
apps/client/src/ee/api-key/components/api-key-table.tsx (3)
apps/client/src/ee/api-key/types/api-key.types.ts (1)
IApiKey(3-13)apps/client/src/components/ui/custom-avatar.tsx (1)
CustomAvatar(19-35)apps/client/src/components/common/no-table-results.tsx (1)
NoTableResults(9-20)
🔇 Additional comments (27)
apps/client/src/features/group/components/edit-group-form.tsx (1)
7-11: LGTM! Consistent migration to external resolver package.The migration from Mantine's built-in
zodResolvertomantine-form-zod-resolvermirrors the change increate-group-form.tsx, ensuring consistent form validation across create and edit flows.apps/client/src/features/group/queries/group-query.ts (2)
25-25: LGTM!The import is correctly added to support internationalization throughout the file.
77-77: LGTM!The internationalization implementation is correct. The
useTranslationhook is properly placed within each custom hook, and success messages are consistently translated using thet()function.Also applies to: 82-82, 96-96, 101-101, 125-125, 130-130, 146-146, 158-158
apps/client/src/lib/types.ts (1)
5-5: LGTM!The addition of the optional
adminViewproperty toQueryParamsis straightforward and backward-compatible.apps/client/src/main.tsx (1)
4-4: LGTM!The Mantine dates styles import is appropriate and consistent with other Mantine style imports.
apps/server/src/database/pagination/pagination-options.ts (1)
28-30: LGTM!The
adminViewproperty is properly validated with@IsOptional()and@IsBoolean()decorators, consistent with the client-sideQueryParamsinterface.apps/client/src/components/common/no-table-results.tsx (1)
7-15: LGTM!The addition of the optional
textprop with a fallback to the translation key is a clean, backward-compatible enhancement.apps/server/src/database/types/entity.types.ts (1)
22-127: LGTM!The new API key type definitions follow the established patterns in the file, using Kysely's type helpers consistently with other entity types.
apps/server/src/core/auth/services/token.service.ts (1)
94-113: LGTM!The new
generateApiTokenmethod follows the established patterns for token generation, includes proper user validation, and correctly handles the optionalexpiresInparameter.apps/client/src/ee/api-key/components/revoke-api-key-modal.tsx (1)
1-62: LGTM!The component is well-structured with proper async mutation handling, loading states, and clear user communication about the irreversible action.
apps/server/src/database/types/db.d.ts (2)
33-43: LGTM!The ApiKeys interface definition follows the established patterns for table interfaces, with appropriate field types for API key management including audit fields, expiration tracking, and foreign key references.
364-364: LGTM!The apiKeys table is correctly integrated into the DB interface.
apps/client/src/components/settings/settings-sidebar.tsx (3)
65-72: LGTM!The "API keys" navigation item is correctly configured with appropriate access control flags for enterprise features.
103-111: LGTM!The "API management" navigation item is properly configured with admin-only access and enterprise flags.
217-222: LGTM!The prefetch handlers for the new API key navigation items are correctly wired into the switch statement.
apps/client/src/ee/api-key/components/api-key-created-modal.tsx (1)
1-72: LGTM!The component effectively communicates the importance of saving the API key with a clear alert and provides an easy copy mechanism. The structure follows Mantine patterns correctly.
apps/client/src/ee/api-key/components/create-api-key-modal.tsx (1)
130-139: LGTM!Good use of
minDateto prevent selecting past dates and Suspense for the lazy-loaded DateInput component.apps/client/src/ee/api-key/components/api-key-table.tsx (2)
61-74: LGTM!Proper use of conditional rendering and optional chaining for the user column.
82-98: LGTM!The expiration column correctly handles all three states: expired, valid expiration date, and no expiration.
apps/client/src/ee/api-key/types/api-key.types.ts (1)
3-23: LGTM!Type definitions are well-structured and appropriate for the API key management use case. Good use of
Partial<IUser>for the creator field and optionaltokenfield that's only present on creation.apps/client/src/ee/api-key/services/api-key-service.ts (2)
16-32: LGTM!CRUD operations are clearly defined with appropriate HTTP methods and endpoints. Error handling is appropriately delegated to the caller (React Query hooks).
9-14: No change required: POST is the established pattern for read endpoints
All existingget*functions use POST for read/list operations (e.g.,getWorkspace,getMfaStatus,getSsoProviders), sogetApiKeysaligns with the codebase convention.apps/client/src/ee/api-key/pages/workspace-api-keys.tsx (2)
86-114: LGTM!Modal state management is well-structured with appropriate cleanup in
onClosehandlers. The separation between create and created modals provides good UX for displaying the one-time token.
29-31: Ensure backend authorization is enforced. Verify that workspace API key endpoints in the server (e.g.ApiKeyResolver/ApiKeyController) are protected by@UseGuards(RolesGuard)and@Roles('admin').apps/client/src/ee/api-key/pages/user-api-keys.tsx (1)
57-62: LGTM!Good defensive programming with the
|| []fallback forapiKeys. This ensures the table always receives an array even if data is undefined.apps/server/src/core/auth/strategies/jwt.strategy.ts (2)
36-51: LGTM!Good separation of authentication flows between standard JWT (ACCESS) and API key (API_KEY) tokens. The explicit type checking ensures proper routing to the appropriate validation logic.
67-91: EnsureApiKeyService.validateApiKeyreturns Passport-compatible payload
Since the EE module isn’t bundled here, verify in its implementation thatvalidateApiKeyreturns at least{ user, workspace }(or whatever shape Passport expects) so the strategy receives the correct format.
| "@emoji-mart/react": "^1.1.1", | ||
| "@excalidraw/excalidraw": "0.18.0-864353b", | ||
| "@mantine/core": "^8.1.3", | ||
| "@mantine/dates": "^8.3.2", |
There was a problem hiding this comment.
Align @mantine/dates version with other Mantine packages.
The @mantine/dates package is at version ^8.3.2, while all other Mantine packages (@mantine/core, @mantine/form, @mantine/hooks, @mantine/modals, @mantine/notifications, @mantine/spotlight) are at ^8.1.3. Mantine packages should typically be kept in sync to avoid type mismatches, style inconsistencies, or runtime compatibility issues.
Apply this diff to align the version:
- "@mantine/dates": "^8.3.2",
+ "@mantine/dates": "^8.1.3",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "@mantine/dates": "^8.3.2", | |
| "@mantine/dates": "^8.1.3", |
🤖 Prompt for AI Agents
In apps/client/package.json around line 20, the @mantine/dates dependency is
^8.3.2 while all other Mantine packages are ^8.1.3; update the @mantine/dates
entry to ^8.1.3 to match the rest, then run your package manager (npm/yarn/pnpm)
install to update the lockfile and ensure all Mantine packages are aligned.
| "Expired": "Expired", | ||
| "Expires": "Expires", | ||
| "I've saved my API key": "I've saved my API key", | ||
| "Last use": "Last Used", |
There was a problem hiding this comment.
Fix translation key/value inconsistency.
The translation key is "Last use" but the value is "Last Used". This inconsistency could cause confusion. Typically, the key and value should match unless there's a specific reason for the difference.
Consider applying this diff for consistency:
- "Last use": "Last Used",
+ "Last Used": "Last Used",Alternatively, if the key is intentionally abbreviated, ensure it's used consistently throughout the codebase.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "Last use": "Last Used", | |
| "Last Used": "Last Used", |
🤖 Prompt for AI Agents
In apps/client/public/locales/en-US/translation.json around line 549, the
translation key "Last use" does not match its value "Last Used"; update the JSON
so the key and value are consistent (e.g., change the key to "Last Used" or
change the value to "Last use"), and if you change the key, update any code
references to use the new key and run the localization/i18n checks to ensure no
missing keys.
| export const prefetchApiKeys = () => { | ||
| queryClient.prefetchQuery({ | ||
| queryKey: ["api-key-list", { page: 1 }], | ||
| queryFn: () => getApiKeys({ page: 1 }), | ||
| }); | ||
| }; | ||
|
|
||
| export const prefetchApiKeyManagement = () => { | ||
| queryClient.prefetchQuery({ | ||
| queryKey: ["api-key-list", { page: 1 }], | ||
| queryFn: () => getApiKeys({ page: 1, adminView: true }), | ||
| }); | ||
| }; |
There was a problem hiding this comment.
Fix queryKey collision between user and admin API key queries.
Both prefetchApiKeys and prefetchApiKeyManagement use identical queryKeys ["api-key-list", { page: 1 }] but invoke different query functions (one with adminView: true). React Query will treat these as the same query, causing cache collisions where admin data might be shown to regular users or vice versa.
Include the adminView parameter in the queryKey to ensure proper cache separation:
export const prefetchApiKeyManagement = () => {
queryClient.prefetchQuery({
- queryKey: ["api-key-list", { page: 1 }],
+ queryKey: ["api-key-list", { page: 1, adminView: true }],
queryFn: () => getApiKeys({ page: 1, adminView: true }),
});
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export const prefetchApiKeys = () => { | |
| queryClient.prefetchQuery({ | |
| queryKey: ["api-key-list", { page: 1 }], | |
| queryFn: () => getApiKeys({ page: 1 }), | |
| }); | |
| }; | |
| export const prefetchApiKeyManagement = () => { | |
| queryClient.prefetchQuery({ | |
| queryKey: ["api-key-list", { page: 1 }], | |
| queryFn: () => getApiKeys({ page: 1, adminView: true }), | |
| }); | |
| }; | |
| export const prefetchApiKeys = () => { | |
| queryClient.prefetchQuery({ | |
| queryKey: ["api-key-list", { page: 1 }], | |
| queryFn: () => getApiKeys({ page: 1 }), | |
| }); | |
| }; | |
| export const prefetchApiKeyManagement = () => { | |
| queryClient.prefetchQuery({ | |
| queryKey: ["api-key-list", { page: 1, adminView: true }], | |
| queryFn: () => getApiKeys({ page: 1, adminView: true }), | |
| }); | |
| }; |
🤖 Prompt for AI Agents
In apps/client/src/components/settings/settings-queries.tsx around lines 70 to
82, both prefetchApiKeys and prefetchApiKeyManagement use the same queryKey
["api-key-list", { page: 1 }] which causes cache collisions; update the queryKey
for each to include the adminView parameter (e.g., { page: 1, adminView: true }
for the admin prefetch and { page: 1, adminView: false } or omit for the regular
prefetch) so React Query treats them as distinct cache entries and matches the
queryFn params.
| {apiKeys && apiKeys.length > 0 ? ( | ||
| apiKeys.map((apiKey: IApiKey, index: number) => ( | ||
| <Table.Tr key={index}> | ||
| <Table.Td> | ||
| <Text fz="sm" fw={500}> | ||
| {apiKey.name} | ||
| </Text> | ||
| </Table.Td> |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Use stable ID as key instead of array index.
Using array index as the React key can cause issues with component identity when items are reordered, added, or removed. This can lead to incorrect component state persistence and unnecessary re-renders.
Use the unique apiKey.id as the key:
- apiKeys.map((apiKey: IApiKey, index: number) => (
- <Table.Tr key={index}>
+ apiKeys.map((apiKey: IApiKey) => (
+ <Table.Tr key={apiKey.id}>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| {apiKeys && apiKeys.length > 0 ? ( | |
| apiKeys.map((apiKey: IApiKey, index: number) => ( | |
| <Table.Tr key={index}> | |
| <Table.Td> | |
| <Text fz="sm" fw={500}> | |
| {apiKey.name} | |
| </Text> | |
| </Table.Td> | |
| {apiKeys && apiKeys.length > 0 ? ( | |
| apiKeys.map((apiKey: IApiKey) => ( | |
| <Table.Tr key={apiKey.id}> | |
| <Table.Td> | |
| <Text fz="sm" fw={500}> | |
| {apiKey.name} | |
| </Text> | |
| </Table.Td> |
🤖 Prompt for AI Agents
In apps/client/src/ee/api-key/components/api-key-table.tsx around lines 52 to
59, the Table.Tr is using the array index as the React key which can break
component identity; change the key to use the stable unique identifier
(apiKey.id) instead (or another stable unique field) and ensure that id is
present for every apiKey or provide a deterministic fallback before using it as
the key.
| const getExpirationLabel = (days: number) => { | ||
| const date = new Date(); | ||
| date.setDate(date.getDate() + days); | ||
| const formatted = date.toLocaleDateString("en-US", { | ||
| month: "short", | ||
| day: "2-digit", | ||
| year: "numeric", | ||
| }); | ||
| return `${days} days (${formatted})`; | ||
| }; |
There was a problem hiding this comment.
Hard-coded locale in date formatting.
The toLocaleDateString call uses a hard-coded "en-US" locale, which won't respect the user's locale preferences.
Consider using the user's locale from the i18n context:
const getExpirationLabel = (days: number) => {
const date = new Date();
date.setDate(date.getDate() + days);
- const formatted = date.toLocaleDateString("en-US", {
+ const formatted = date.toLocaleDateString(undefined, {
month: "short",
day: "2-digit",
year: "numeric",
});
return `${days} days (${formatted})`;
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const getExpirationLabel = (days: number) => { | |
| const date = new Date(); | |
| date.setDate(date.getDate() + days); | |
| const formatted = date.toLocaleDateString("en-US", { | |
| month: "short", | |
| day: "2-digit", | |
| year: "numeric", | |
| }); | |
| return `${days} days (${formatted})`; | |
| }; | |
| const getExpirationLabel = (days: number) => { | |
| const date = new Date(); | |
| date.setDate(date.getDate() + days); | |
| const formatted = date.toLocaleDateString(undefined, { | |
| month: "short", | |
| day: "2-digit", | |
| year: "numeric", | |
| }); | |
| return `${days} days (${formatted})`; | |
| }; |
🤖 Prompt for AI Agents
In apps/client/src/ee/api-key/components/create-api-key-modal.tsx around lines
59 to 68, the date formatting uses a hard-coded "en-US" locale which ignores the
user's locale; update getExpirationLabel to pull the user's locale from the
app's i18n context (or router locale) and pass that locale value into
toLocaleDateString (falling back to undefined if not available) while keeping
the existing format options so the displayed date respects user locale
preferences.
| useEffect(() => { | ||
| if (opened && apiKey) { | ||
| form.setValues({ name: apiKey.name }); | ||
| } | ||
| }, [opened, apiKey]); |
There was a problem hiding this comment.
Add form to useEffect dependencies to prevent stale closure.
The form object is used inside the useEffect but not included in the dependency array. While this may work in practice because form is likely stable, it violates React's rules of hooks and could lead to stale closure bugs if form's reference changes.
Apply this diff:
useEffect(() => {
if (opened && apiKey) {
form.setValues({ name: apiKey.name });
}
- }, [opened, apiKey]);
+ }, [opened, apiKey, form]);🤖 Prompt for AI Agents
In apps/client/src/ee/api-key/components/update-api-key-modal.tsx around lines
36 to 40, the useEffect reads from the form variable but doesn't include it in
the dependency array, which can create a stale closure if form's reference
changes; update the effect's dependency array to include form (i.e., [opened,
apiKey, form]) so the effect re-runs when form changes and avoid violating React
hooks rules.
| {data?.items.length > 0 && ( | ||
| <Paginate | ||
| currentPage={page} | ||
| hasPrevPage={data?.meta.hasPrevPage} | ||
| hasNextPage={data?.meta.hasNextPage} | ||
| onPageChange={setPage} | ||
| /> | ||
| )} |
There was a problem hiding this comment.
Add null check for data before accessing length.
Same issue as in workspace-api-keys.tsx: the condition data?.items.length > 0 could throw an error if data is undefined.
Apply this fix:
- {data?.items.length > 0 && (
+ {data?.items && data.items.length > 0 && (📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| {data?.items.length > 0 && ( | |
| <Paginate | |
| currentPage={page} | |
| hasPrevPage={data?.meta.hasPrevPage} | |
| hasNextPage={data?.meta.hasNextPage} | |
| onPageChange={setPage} | |
| /> | |
| )} | |
| {data?.items && data.items.length > 0 && ( | |
| <Paginate | |
| currentPage={page} | |
| hasPrevPage={data?.meta.hasPrevPage} | |
| hasNextPage={data?.meta.hasNextPage} | |
| onPageChange={setPage} | |
| /> | |
| )} |
🤖 Prompt for AI Agents
In apps/client/src/ee/api-key/pages/user-api-keys.tsx around lines 66 to 73, the
render condition uses data?.items.length which can throw if data is undefined;
update the condition to guard data and items before accessing length (e.g. use
data?.items?.length > 0 or explicitly check data && data.items &&
data.items.length > 0) so Paginate is only rendered when data and items exist
and length > 0; keep the onPageChange and other props unchanged.
| {data?.items.length > 0 && ( | ||
| <Paginate | ||
| currentPage={page} | ||
| hasPrevPage={data?.meta.hasPrevPage} | ||
| hasNextPage={data?.meta.hasNextPage} | ||
| onPageChange={setPage} | ||
| /> | ||
| )} |
There was a problem hiding this comment.
Add null check for data before accessing length.
The condition data?.items.length > 0 will throw an error if data is undefined, as optional chaining only prevents the error if items is undefined, not if data is undefined.
Apply this fix:
- {data?.items.length > 0 && (
+ {data?.items && data.items.length > 0 && (📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| {data?.items.length > 0 && ( | |
| <Paginate | |
| currentPage={page} | |
| hasPrevPage={data?.meta.hasPrevPage} | |
| hasNextPage={data?.meta.hasNextPage} | |
| onPageChange={setPage} | |
| /> | |
| )} | |
| {data?.items && data.items.length > 0 && ( | |
| <Paginate | |
| currentPage={page} | |
| hasPrevPage={data?.meta.hasPrevPage} | |
| hasNextPage={data?.meta.hasNextPage} | |
| onPageChange={setPage} | |
| /> | |
| )} |
🤖 Prompt for AI Agents
In apps/client/src/ee/api-key/pages/workspace-api-keys.tsx around lines 77 to
84, the conditional uses data?.items.length and
data?.meta.hasPrevPage/hasNextPage which will throw if data is undefined; change
the checks to use safe optional chaining (e.g., data?.items?.length > 0) and
also guard meta access (e.g., data?.meta?.hasPrevPage and
data?.meta?.hasNextPage) or use a single data truthy check (e.g., data &&
data.items.length > 0 and data.meta && ...) so no property is accessed on
undefined.
| export async function up(db: Kysely<any>): Promise<void> { | ||
| await db.schema | ||
| .createTable('api_keys') | ||
| .addColumn('id', 'uuid', (col) => | ||
| col.primaryKey().defaultTo(sql`gen_uuid_v7()`), | ||
| ) | ||
| .addColumn('name', 'text', (col) => col) | ||
| .addColumn('expires_at', 'timestamptz') | ||
| .addColumn('creator_id', 'uuid', (col) => | ||
| col.notNull().references('users.id').onDelete('cascade'), | ||
| ) | ||
| .addColumn('workspace_id', 'uuid', (col) => | ||
| col.notNull().references('workspaces.id').onDelete('cascade'), | ||
| ) | ||
| .addColumn('last_used_at', 'timestamptz') | ||
| .addColumn('created_at', 'timestamptz', (col) => | ||
| col.notNull().defaultTo(sql`now()`), | ||
| ) | ||
| .addColumn('updated_at', 'timestamptz', (col) => | ||
| col.notNull().defaultTo(sql`now()`), | ||
| ) | ||
| .addColumn('deleted_at', 'timestamptz', (col) => col) | ||
| .execute(); | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Add indexes on frequently queried columns.
The migration lacks indexes on columns that will be queried frequently:
workspace_idandcreator_id(for listing API keys by workspace/user)deleted_at(for filtering soft-deleted keys)expires_at(for finding expired keys)
Without these indexes, queries could suffer performance degradation as the table grows.
Apply this diff to add the indexes:
.addColumn('deleted_at', 'timestamptz', (col) => col)
.execute();
+
+ await db.schema
+ .createIndex('api_keys_workspace_id_idx')
+ .on('api_keys')
+ .column('workspace_id')
+ .execute();
+
+ await db.schema
+ .createIndex('api_keys_creator_id_idx')
+ .on('api_keys')
+ .column('creator_id')
+ .execute();
+
+ await db.schema
+ .createIndex('api_keys_deleted_at_idx')
+ .on('api_keys')
+ .column('deleted_at')
+ .where('deleted_at', 'is not', null)
+ .execute();
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export async function up(db: Kysely<any>): Promise<void> { | |
| await db.schema | |
| .createTable('api_keys') | |
| .addColumn('id', 'uuid', (col) => | |
| col.primaryKey().defaultTo(sql`gen_uuid_v7()`), | |
| ) | |
| .addColumn('name', 'text', (col) => col) | |
| .addColumn('expires_at', 'timestamptz') | |
| .addColumn('creator_id', 'uuid', (col) => | |
| col.notNull().references('users.id').onDelete('cascade'), | |
| ) | |
| .addColumn('workspace_id', 'uuid', (col) => | |
| col.notNull().references('workspaces.id').onDelete('cascade'), | |
| ) | |
| .addColumn('last_used_at', 'timestamptz') | |
| .addColumn('created_at', 'timestamptz', (col) => | |
| col.notNull().defaultTo(sql`now()`), | |
| ) | |
| .addColumn('updated_at', 'timestamptz', (col) => | |
| col.notNull().defaultTo(sql`now()`), | |
| ) | |
| .addColumn('deleted_at', 'timestamptz', (col) => col) | |
| .execute(); | |
| } | |
| export async function up(db: Kysely<any>): Promise<void> { | |
| await db.schema | |
| .createTable('api_keys') | |
| .addColumn('id', 'uuid', (col) => | |
| col.primaryKey().defaultTo(sql`gen_uuid_v7()`), | |
| ) | |
| .addColumn('name', 'text', (col) => col) | |
| .addColumn('expires_at', 'timestamptz') | |
| .addColumn('creator_id', 'uuid', (col) => | |
| col.notNull().references('users.id').onDelete('cascade'), | |
| ) | |
| .addColumn('workspace_id', 'uuid', (col) => | |
| col.notNull().references('workspaces.id').onDelete('cascade'), | |
| ) | |
| .addColumn('last_used_at', 'timestamptz') | |
| .addColumn('created_at', 'timestamptz', (col) => | |
| col.notNull().defaultTo(sql`now()`), | |
| ) | |
| .addColumn('updated_at', 'timestamptz', (col) => | |
| col.notNull().defaultTo(sql`now()`), | |
| ) | |
| .addColumn('deleted_at', 'timestamptz', (col) => col) | |
| .execute(); | |
| await db.schema | |
| .createIndex('api_keys_workspace_id_idx') | |
| .on('api_keys') | |
| .column('workspace_id') | |
| .execute(); | |
| await db.schema | |
| .createIndex('api_keys_creator_id_idx') | |
| .on('api_keys') | |
| .column('creator_id') | |
| .execute(); | |
| await db.schema | |
| .createIndex('api_keys_deleted_at_idx') | |
| .on('api_keys') | |
| .column('deleted_at') | |
| .where('deleted_at', 'is not', null) | |
| .execute(); | |
| } |
🤖 Prompt for AI Agents
In apps/server/src/database/migrations/20250912T101500-api-keys.ts around lines
3 to 26, the migration creates the api_keys table but omits indexes on
frequently queried columns; add index creation statements for workspace_id,
creator_id, deleted_at, and expires_at (use descriptive index names like
idx_api_keys_workspace_id, idx_api_keys_creator_id, idx_api_keys_deleted_at,
idx_api_keys_expires_at) as part of the up migration (using
db.schema.createIndex or equivalent raw SQL) so lookups and filters are fast,
and mirror them in the down migration to drop those indexes when rolling back.
| async updateApiSettings( | ||
| workspaceId: string, | ||
| prefKey: string, | ||
| prefValue: string | boolean, | ||
| ) { | ||
| return this.db | ||
| .updateTable('workspaces') | ||
| .set({ | ||
| settings: sql`COALESCE(settings, '{}'::jsonb) | ||
| || jsonb_build_object('api', COALESCE(settings->'api', '{}'::jsonb) | ||
| || jsonb_build_object('${sql.raw(prefKey)}', ${sql.lit(prefValue)}))`, | ||
| updatedAt: new Date(), | ||
| }) | ||
| .where('id', '=', workspaceId) | ||
| .returning(this.baseFields) | ||
| .executeTakeFirst(); | ||
| } |
There was a problem hiding this comment.
Potential SQL injection risk with sql.raw(prefKey).
The method uses sql.raw(prefKey) to construct the JSONB key, which directly inserts the string into SQL without escaping. While currently safe (only called with the hardcoded string 'restrictToAdmins'), this creates a SQL injection vulnerability if the method is ever called with user-controlled input.
Consider one of these solutions:
Solution 1 (preferred): Whitelist allowed keys
async updateApiSettings(
workspaceId: string,
prefKey: string,
prefValue: string | boolean,
) {
+ const ALLOWED_KEYS = ['restrictToAdmins'] as const;
+ if (!ALLOWED_KEYS.includes(prefKey as any)) {
+ throw new Error(`Invalid API setting key: ${prefKey}`);
+ }
+
return this.dbSolution 2: Use parameterized approach
If Kysely supports it, use a parameterized key rather than sql.raw(). If not, at minimum add JSDoc warning:
/**
* Updates API settings in workspace JSONB.
* @param prefKey - Must be a trusted, non-user-controlled string (SQL injection risk)
* @param prefValue - The value to set
*/
async updateApiSettings(...)🤖 Prompt for AI Agents
In apps/server/src/database/repos/workspace/workspace.repo.ts around lines 161
to 177, the use of sql.raw(prefKey) introduces a SQL injection risk by injecting
the key string directly into the query; replace this by whitelisting allowed
preference keys (e.g., check prefKey against an explicit set of accepted keys
like 'restrictToAdmins' and throw on unknown keys) and only pass approved keys
into the SQL, or if whitelisting is infeasible, add a clear JSDoc and runtime
assertion that prefKey must be a trusted constant (non-user-controlled) before
using sql.raw; ensure prefValue continues to be passed as a parameterized value.
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/server/src/core/auth/strategies/jwt.strategy.ts(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/server/src/core/auth/strategies/jwt.strategy.ts (2)
apps/server/src/database/types/kysely.types.ts (1)
KyselyDB(4-4)apps/server/src/core/auth/dto/jwt-payload.ts (2)
JwtPayload(9-14)JwtApiKeyPayload(41-46)
🔇 Additional comments (2)
apps/server/src/core/auth/strategies/jwt.strategy.ts (2)
36-51: LGTM! Clean type-based routing for API keys.The payload type widening and conditional routing logic correctly handle both standard JWT and API key authentication flows. The workspaceId check applies appropriately to both types, and the type guards ensure only valid tokens proceed.
87-87: Unable to locateApiKeyService.validateApiKeyimplementation. Confirm this method returns an object with{ user, workspace }, as required by the JWT strategy.
| return ApiKeyService.validateApiKey(payload); | ||
| } | ||
|
|
||
| throw new UnauthorizedException('Enterprise API Key module missing'); |
There was a problem hiding this comment.
Avoid leaking internal architecture details in error messages.
The error message "Enterprise API Key module missing" reveals that the application has an enterprise edition and exposes internal module structure. API consumers (potentially attackers) should not receive these implementation details.
Use a generic message:
- throw new UnauthorizedException('Enterprise API Key module missing');
+ throw new UnauthorizedException();Or if you need to log details, do so server-side only:
- throw new UnauthorizedException('Enterprise API Key module missing');
+ this.logger.error('API Key validation failed: Enterprise module not available');
+ throw new UnauthorizedException();🤖 Prompt for AI Agents
In apps/server/src/core/auth/strategies/jwt.strategy.ts at line 90, the thrown
UnauthorizedException exposes internal implementation details ("Enterprise API
Key module missing"); change the exception message to a generic one such as
"Unauthorized" or "Authentication failed" and move any specific diagnostic
details into server-side logs (use the existing logger to log the detailed
error/stack) so API responses do not leak internal architecture.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
apps/server/src/core/auth/strategies/jwt.strategy.ts (1)
86-86: Remove internal implementation details from error message.The error message "Enterprise API Key module missing" exposes internal architecture (enterprise edition structure) to API consumers, including potential attackers. Previous review already flagged this issue.
Use a generic message:
- throw new UnauthorizedException('Enterprise API Key module missing'); + this.logger.error('API Key validation failed: Enterprise module not available'); + throw new UnauthorizedException();
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/server/src/core/auth/strategies/jwt.strategy.ts(4 hunks)apps/server/src/database/migrations/20250912T101500-api-keys.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/server/src/database/migrations/20250912T101500-api-keys.ts
🧰 Additional context used
🧬 Code graph analysis (1)
apps/server/src/core/auth/strategies/jwt.strategy.ts (1)
apps/server/src/core/auth/dto/jwt-payload.ts (2)
JwtPayload(9-14)JwtApiKeyPayload(41-46)
🔇 Additional comments (1)
apps/server/src/core/auth/strategies/jwt.strategy.ts (1)
32-47: LGTM! API key routing logic is sound.The validate method correctly handles both JWT and API key payloads:
- Guards against missing workspaceId for both payload types
- Routes API_KEY type to the dedicated validation method
- Maintains existing ACCESS token validation flow
* feat: api keys (EE) * improvements * fix table * fix route * remove token suffix * api settings * Fix * fix * fix * fix
* feat: api keys (EE) * improvements * fix table * fix route * remove token suffix * api settings * Fix * fix * fix * fix
4231ba9 Merge commit '042836cb6d7cc1f71af3ce44c7957f8abbbf8f25' into feat/aar_edition 042836c sync 4f1f0ba fix 3164b69 feat: api keys management (EE) (docmost#1665) 16c1e86 fix comment space c9b1cad sync bf8cf62 feat: Typesense search driver (EE) (docmost#1664) 5a2e16a Merge commit '31350303760163384113bf49d07127e886f94907' into feat/aar_edition 3bc710d Adds CLAUDE.md documentation 16914f1 Block search for non-indexed shares ca75e29 Set default page mode to Read 3135030 fix editor converter (docmost#1647) 3fae41a fix: editor performance improvements (docmost#1648) b50e256 sync 1f3b0c7 cloud fix 3c4cab0 v0.23.2 4de25a8 invalidate queries on space deletion cf5bbb1 fix import html processing ac17521 sync 9ac180f fix: enhance page import (docmost#1570) 46669fe (cloud) disable page sharing in trial mode fe6ecdf fix: update combobox props in SpaceSelect component (docmost#1564) 04ae1d7 Allow lastColumnResizable in table 1280f96 feat: implement space and workspace icons (docmost#1558) 61d1cf8 fix: reset file inputs after import f413720 - sync - reinstantiate S3 client to fix file upload errors during import - delete import zip file after use 8e16ad9 v0.23.1 7ada3cb fix: page import task (docmost#1551) 47c5417 sync dc06502 sync 091e790 fix attachment search in cloud ae24ea2 v0.23.0 9df6061 lock file 31053e2 update mermaid eb8e850 use debug c99bfb8 make print better 26ea04e sync 6cc58c5 sync 7d2ff34 UI fixes b08d37f fix d43ee77 remove debug log 5d91eb4 feat: queue imported attachments for indexing 3e9f6b1 Remove version from docker-compose.yml [deprecated] (docmost#1011) db55de9 feat: progressive web app (docmost#614) 1919eba New Crowdin updates (docmost#1522) 7951b2e New Crowdin updates (docmost#1509) 73b78f6 more translations cf7534d fix version display adec36d fix: adjust margins - use default browser highlight background f9e1080 sync 00e499b Fixing extra page bug on print (docmost#1478) 5ee6e46 checkbox aligned to text (docmost#1486) 1f797c3 fix: confluence drawio import (docmost#1518) f12866c feat(EE): full-text search in attachments (docmost#1502) dcbb65d feat(EE): LDAP integration (docmost#1515) 5968764 feat: emoji callout icon (docmost#1323) 242fb6b fix: set mermaid theme based on computed color scheme (docmost#1438) 74cd890 feat(EE): implement SSO group sync for SAML and OIDC (docmost#1452) 509622a ignore type error 937386e fix: hide table handles in readonly mode 60a373f fix: readonly editor table responsiveness 73ee6ee feat: subpages (child pages) list node (docmost#1462) 7d1e5bc feat: table row/column drag and drop (docmost#1467) aa58e27 fix: exclude deleted pages (docmost#1494) 08135a2 sync d92a942 sync 5012a68 sync 5a33777 feat: debug mode env variable (docmost#1450) 3b85f4b fix: enforce C collation for page position ordering to ensure consistent behavior in Postgres 17+ (docmost#1446) cb2a039 fix: invalidate trashed page from tree state 95b7be6 fix: hide trash from can view permission (docmost#1445) b0c5572 fix nested taskList in markdown export (docmost#1443) dddfd48 feat: add attachments support for single page exports (docmost#1440) aa6eec7 fix: exclude trashed pages from position generation 97a7701 fix local storage copy function (docmost#1442) b97eb85 sync git-subtree-dir: vendor/app git-subtree-split: 4231ba9
* feat: api keys (EE) * improvements * fix table * fix route * remove token suffix * api settings * Fix * fix * fix * fix
* feat: api keys (EE) * improvements * fix table * fix route * remove token suffix * api settings * Fix * fix * fix * fix
Summary by CodeRabbit