Generate API Key per Project Instead of per organisation#215
Merged
AkhileshNegi merged 5 commits intomainfrom Jun 13, 2025
Merged
Generate API Key per Project Instead of per organisation#215AkhileshNegi merged 5 commits intomainfrom
AkhileshNegi merged 5 commits intomainfrom
Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
abe51fd to
8eb8b87
Compare
nishika26
requested changes
Jun 11, 2025
AkhileshNegi
requested changes
Jun 13, 2025
Comment on lines
+26
to
+44
|
|
||
| # 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 | ||
| ) | ||
| """ | ||
| ) | ||
| ) | ||
|
|
Collaborator
There was a problem hiding this comment.
as this will be one time thing we can run it manually in production server and remove from migration
Collaborator
Author
There was a problem hiding this comment.
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.
nishika26
approved these changes
Jun 13, 2025
AkhileshNegi
approved these changes
Jun 13, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.