feat: add env vars to restrict API key creation and usage to org owners#1007
feat: add env vars to restrict API key creation and usage to org owners#1007brendan-kellam merged 4 commits intomainfrom
Conversation
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This comment has been minimized.
This comment has been minimized.
WalkthroughThis PR introduces two new environment variables to restrict API key creation and usage exclusively to organization owners. It updates environment configuration with backward compatibility for a deprecated flag, implements permission checks in authentication and API key creation flows, refactors the API keys settings page into server and client components, adds client-side UI for managing keys, and includes comprehensive test coverage for the new restrictions. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Summary
DISABLE_API_KEY_CREATION_FOR_NON_OWNER_USERSenv var — when enabled, only org owners can create API keysDISABLE_API_KEY_USAGE_FOR_NON_OWNER_USERSenv var — when enabled, only org owners can create or authenticate with API keys (superset of the creation flag)EXPERIMENT_DISABLE_API_KEY_CREATION_FOR_NON_ADMIN_USERSin favour ofDISABLE_API_KEY_CREATION_FOR_NON_OWNER_USERS(backwards-compatible via transform fallback)getAuthenticatedUserto return asourcefield ('session' | 'oauth' | 'api_key') sogetAuthContextcan enforce the usage flag at the auth layerDISABLE_API_KEY_USAGE_FOR_NON_OWNER_USERSis setenvironment-variables.mdxFixes SOU-698
Test plan
DISABLE_API_KEY_CREATION_FOR_NON_OWNER_USERS=true, non-owner members see the "Create API Key" button disabled with a tooltip; creation via the API returns 403DISABLE_API_KEY_USAGE_FOR_NON_OWNER_USERS=true, non-owner members are redirected to 404 on the API Keys settings page; creation and API key authentication both return 403; owners are unaffectedEXPERIMENT_DISABLE_API_KEY_CREATION_FOR_NON_ADMIN_USERS=truestill works as before (fallback to new var)🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Deprecations