-
Notifications
You must be signed in to change notification settings - Fork 7
Generate API Key per Project Instead of per organisation #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
abe51fd to
8eb8b87
Compare
|
|
||
| # 2. Bind engine to run raw SQL | ||
| conn = op.get_bind() | ||
|
|
||
| # 3. Populate project_id based on default logic (e.g., min project id per org) | ||
| conn.execute( | ||
| text( | ||
| """ | ||
| UPDATE apikey | ||
| SET project_id = ( | ||
| SELECT id FROM project | ||
| WHERE project.organization_id = apikey.organization_id | ||
| ORDER BY id ASC | ||
| LIMIT 1 | ||
| ) | ||
| """ | ||
| ) | ||
| ) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as this will be one time thing we can run it manually in production server and remove from migration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to set a NOT NULL constraint on the project_id column.
To do that, I first populated the column with appropriate values to avoid constraint violations.
Summary
Target issue is #203
Currently, API keys are generated based on a combination of organization_id and user_id. This PR updates the logic to generate API keys using organization_id, project_id, and user_id—with the primary association being to the project.
Key Changes:
Checklist
Before submitting a pull request, please ensure that you mark these task.
fastapi run --reload app/main.pyordocker compose upin the repository root and test.Notes
Please add here if any other information is required for the reviewer.