Skip to content
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

feat(user): add user api keys schema + api #787

Merged
merged 36 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a6c0a9c
feat(user): add api key database schema
baktun14 Feb 4, 2025
7aba422
feat(user): add user api key route + controller + service + repo
baktun14 Feb 4, 2025
c6d4aed
feat(user): add functional tests
baktun14 Feb 4, 2025
2b5df95
feat(user): fix tests and data mapping
baktun14 Feb 5, 2025
f5ffa1c
feat(user): update api_key unique
baktun14 Feb 5, 2025
4a5b6cc
feat(deployment): move api keys to auth module + rename
baktun14 Feb 5, 2025
f44d805
feat(deployment): add new migration
baktun14 Feb 5, 2025
46bdeb9
fix(deployment): remove userId from query
baktun14 Feb 5, 2025
7785cd9
fix(user): remove isActive from api key
baktun14 Feb 5, 2025
19a754d
fix(user): remove http models from service layer
baktun14 Feb 5, 2025
aa59001
fix(user): fix api key tests
baktun14 Feb 5, 2025
428686b
feat(user): update schema to include formatted key
baktun14 Feb 6, 2025
76e617c
feat(user): add api key generation and validation
baktun14 Feb 6, 2025
49cb7ee
feat(user): add tests for key generator
baktun14 Feb 6, 2025
0aa662d
feat(user): added tests for api-key-auth.service
baktun14 Feb 6, 2025
d4981e6
fix(user): remove apikey from output other than create
baktun14 Feb 6, 2025
47cec23
feat(user): refactor api key check into auth interceptor
baktun14 Feb 6, 2025
ed222c0
fix(user): fix tests
baktun14 Feb 6, 2025
f46f519
feat(user): re-add migration
baktun14 Feb 7, 2025
5b3dbb0
fix(user): refactor tests for seeder
baktun14 Feb 7, 2025
80f0381
fix(user): add deployment_env as dependency to api key service
baktun14 Feb 7, 2025
f89f7d5
fix(user): throw when api key is wrong format + fix tests
baktun14 Feb 7, 2025
4ea4292
fix(user): added bcrypt to hash the api keys with salt
baktun14 Feb 7, 2025
8c7d703
fix(user): api key functional test fix
baktun14 Feb 8, 2025
9b61700
fix(user): replace bcrypt with bcryptjs
baktun14 Feb 8, 2025
bff4b30
fix(user): remove description from api key
baktun14 Feb 9, 2025
1855a19
fix(user): better error handling api key checks
baktun14 Feb 10, 2025
5b5a800
chore: move the upgrade indexer latest version at the top
baktun14 Feb 10, 2025
5959b1d
fix(user): add paying user ability
baktun14 Feb 10, 2025
08c81e4
fix(user): base repository type fix
baktun14 Feb 11, 2025
bb8bc84
fix(deployment): only show deployment top up for non-trial users
baktun14 Feb 11, 2025
80563cc
fix(user): mock auth to simulate auth0 userId
baktun14 Feb 11, 2025
d5dc0c3
fix(user): remove redundant env vars
baktun14 Feb 11, 2025
1e7318a
fix(user): remove unsused bcrypt types
baktun14 Feb 11, 2025
625793f
fix(user): user role definition fix
baktun14 Feb 11, 2025
8e8e164
fix(user): add back ability for deployment setting
baktun14 Feb 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/api/drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { defineConfig } from "drizzle-kit";
import { config } from "./src/core/config";

export default defineConfig({
schema: ["billing", "user", "deployment"].map(schema => `./src/${schema}/model-schemas`),
schema: ["billing", "user", "deployment", "auth"].map(schema => `./src/${schema}/model-schemas`),
out: "./drizzle",
dialect: "postgresql",
dbCredentials: {
Expand Down
18 changes: 18 additions & 0 deletions apps/api/drizzle/0012_blushing_brother_voodoo.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE IF NOT EXISTS "api_keys" (
"id" uuid PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
"user_id" uuid NOT NULL,
"hashed_key" varchar NOT NULL,
"key_format" varchar NOT NULL,
"name" varchar NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL,
"expires_at" timestamp,
CONSTRAINT "api_keys_hashed_key_unique" UNIQUE("hashed_key"),
CONSTRAINT "api_keys_key_format_unique" UNIQUE("key_format")
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "api_keys" ADD CONSTRAINT "api_keys_user_id_userSetting_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."userSetting"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
Loading
Loading