-
-
Notifications
You must be signed in to change notification settings - Fork 994
Impersonation log #2896
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
Merged
Merged
Impersonation log #2896
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
edaf1fb
Add ImpersonationAuditLog schema
D-K-P 8d91211
Log impersonation start
D-K-P 3176935
Log impersonation stop
D-K-P eb2bdb5
Add impersonation audit log migration
D-K-P 175558c
Remove ‘v3’ from CONTRIBUTING.md
D-K-P acbc061
Merge branch 'main' into impersonation-log
matt-aitken d4a06ce
Extracted extractClientIp and used it login.magic and admin.server.ts
D-K-P 3994a67
Add index on createdAt field in schema.prisma
D-K-P 87c4fae
Merge branch 'main' into impersonation-log
D-K-P File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /** | ||
| * Extracts the client IP address from the X-Forwarded-For header. | ||
| * Takes the last item in the header since ALB appends the real client IP by default. | ||
| */ | ||
| export function extractClientIp(xff: string | null): string | null { | ||
| if (!xff) return null; | ||
|
|
||
| const parts = xff.split(",").map((p) => p.trim()); | ||
| return parts[parts.length - 1]; // take last item, ALB appends the real client IP by default | ||
| } |
29 changes: 29 additions & 0 deletions
29
...kages/database/prisma/migrations/20260108164613_add_impersonation_audit_log/migration.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| -- CreateEnum | ||
| CREATE TYPE "public"."ImpersonationAuditLogAction" AS ENUM ('START', 'STOP'); | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "public"."ImpersonationAuditLog" ( | ||
| "id" TEXT NOT NULL, | ||
| "action" "public"."ImpersonationAuditLogAction" NOT NULL, | ||
| "adminId" TEXT NOT NULL, | ||
| "targetId" TEXT NOT NULL, | ||
| "ipAddress" TEXT, | ||
| "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
|
||
| CONSTRAINT "ImpersonationAuditLog_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "ImpersonationAuditLog_adminId_idx" ON "public"."ImpersonationAuditLog"("adminId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "ImpersonationAuditLog_targetId_idx" ON "public"."ImpersonationAuditLog"("targetId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "ImpersonationAuditLog_createdAt_idx" ON "public"."ImpersonationAuditLog"("createdAt"); | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "public"."ImpersonationAuditLog" ADD CONSTRAINT "ImpersonationAuditLog_adminId_fkey" FOREIGN KEY ("adminId") REFERENCES "public"."User"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "public"."ImpersonationAuditLog" ADD CONSTRAINT "ImpersonationAuditLog_targetId_fkey" FOREIGN KEY ("targetId") REFERENCES "public"."User"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
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
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.
Uh oh!
There was an error while loading. Please reload this page.