-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(pam): PAM Platform V1 #4590
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
+10,032
−209
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a2c551f
merge from main
x032205 894823d
Merge branch 'main' into ENG-3723
x032205 270d823
Merge branch 'main' into ENG-3723
x032205 4b1664c
feat(pam): PAM Platform V1
x032205 1c83189
Merge branch 'main' into ENG-3723
x032205 ace83e4
lint and fix license
x032205 fc8baca
Update frontend/src/pages/pam/PamAccountsPage/components/PamAccountFo…
x032205 1678fba
misc: initial integration with local and pam proxy
sheensantoscapadngan e77c024
addressed reviews
x032205 6a7d84f
greptile review fixes + schema generate
x032205 5f47359
misc: fixed log clipping and added idempotency to session end
sheensantoscapadngan 7227d43
misc: security hardening for pam credential fetch
sheensantoscapadngan 4d6f8a6
misc: more security improvements
sheensantoscapadngan db6e30a
misc: reverted docker compose dev
sheensantoscapadngan 178a549
improve access account styling, add folder path badge to flat view,
x032205 1b9f2a6
temporarily disable pam project creation on frontend
x032205 965850b
misc: updated session log update validation
sheensantoscapadngan 5992af8
Merge branch 'ENG-3723' of https://github.com/Infisical/infisical int…
sheensantoscapadngan 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
Some comments aren't visible on the classic Files Changed page.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
import { Knex } from "knex"; | ||
|
||
import { TableName } from "../schemas"; | ||
import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils"; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
// PAM Folders | ||
if (!(await knex.schema.hasTable(TableName.PamFolder))) { | ||
await knex.schema.createTable(TableName.PamFolder, (t) => { | ||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid()); | ||
|
||
t.string("projectId").notNullable(); | ||
t.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE"); | ||
t.index("projectId"); | ||
|
||
t.uuid("parentId").nullable(); | ||
t.foreign("parentId").references("id").inTable(TableName.PamFolder).onDelete("CASCADE"); | ||
t.index("parentId"); | ||
|
||
t.string("name").notNullable(); | ||
t.index("name"); | ||
|
||
// Enforce uniqueness for sub-folders | ||
t.unique(["projectId", "parentId", "name"], { | ||
indexName: "uidx_pam_folder_children_name", | ||
predicate: knex.whereNotNull("parentId") | ||
}); | ||
|
||
// Enforce uniqueness for root-level folders | ||
t.unique(["projectId", "name"], { | ||
indexName: "uidx_pam_folder_root_name", | ||
predicate: knex.whereNull("parentId") | ||
}); | ||
|
||
t.text("description").nullable(); | ||
|
||
t.timestamps(true, true, true); | ||
}); | ||
} | ||
|
||
// PAM Resources | ||
if (!(await knex.schema.hasTable(TableName.PamResource))) { | ||
x032205 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await knex.schema.createTable(TableName.PamResource, (t) => { | ||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid()); | ||
|
||
t.string("projectId").notNullable(); | ||
t.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE"); | ||
t.index("projectId"); | ||
|
||
t.string("name").notNullable(); | ||
t.index("name"); | ||
|
||
t.uuid("gatewayId").notNullable(); | ||
t.foreign("gatewayId").references("id").inTable(TableName.GatewayV2); | ||
t.index("gatewayId"); | ||
|
||
t.string("resourceType").notNullable(); | ||
t.index("resourceType"); | ||
|
||
t.binary("encryptedConnectionDetails").notNullable(); | ||
|
||
t.timestamps(true, true, true); | ||
}); | ||
} | ||
|
||
// PAM Accounts | ||
if (!(await knex.schema.hasTable(TableName.PamAccount))) { | ||
x032205 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await knex.schema.createTable(TableName.PamAccount, (t) => { | ||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid()); | ||
|
||
t.string("projectId").notNullable(); | ||
t.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE"); | ||
t.index("projectId"); | ||
|
||
t.uuid("folderId").nullable(); | ||
t.foreign("folderId").references("id").inTable(TableName.PamFolder).onDelete("CASCADE"); | ||
t.index("folderId"); | ||
|
||
t.uuid("resourceId").notNullable(); | ||
t.foreign("resourceId").references("id").inTable(TableName.PamResource); | ||
t.index("resourceId"); | ||
|
||
t.string("name").notNullable(); | ||
x032205 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
t.index("name"); | ||
|
||
// Enforce uniqueness for folders | ||
t.unique(["projectId", "folderId", "name"], { | ||
indexName: "uidx_pam_account_children_name", | ||
predicate: knex.whereNotNull("folderId") | ||
}); | ||
|
||
// Enforce uniqueness for root-level | ||
t.unique(["projectId", "name"], { | ||
indexName: "uidx_pam_account_root_name", | ||
predicate: knex.whereNull("folderId") | ||
}); | ||
|
||
t.text("description").nullable(); | ||
t.binary("encryptedCredentials").notNullable(); | ||
|
||
t.timestamps(true, true, true); | ||
}); | ||
} | ||
|
||
// PAM Sessions | ||
if (!(await knex.schema.hasTable(TableName.PamSession))) { | ||
await knex.schema.createTable(TableName.PamSession, (t) => { | ||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid()); | ||
|
||
t.string("projectId").notNullable(); | ||
t.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE"); | ||
t.index("projectId"); | ||
|
||
t.uuid("accountId").nullable(); | ||
t.foreign("accountId").references("id").inTable(TableName.PamAccount).onDelete("SET NULL"); | ||
t.index("accountId"); | ||
|
||
// To be used in the event of an account deletion | ||
t.string("resourceType").notNullable(); | ||
t.string("resourceName").notNullable(); | ||
t.string("accountName").notNullable(); | ||
|
||
t.uuid("userId").nullable(); | ||
t.foreign("userId").references("id").inTable(TableName.Users).onDelete("SET NULL"); | ||
t.index("userId"); | ||
|
||
// To be used in the event of user deletion | ||
t.string("actorName").notNullable(); | ||
t.string("actorEmail").notNullable(); | ||
|
||
t.string("actorIp").notNullable(); | ||
t.string("actorUserAgent").notNullable(); | ||
|
||
t.string("status").notNullable(); | ||
t.index("status"); | ||
|
||
t.binary("encryptedLogsBlob").nullable(); | ||
|
||
t.datetime("expiresAt").notNullable(); | ||
|
||
t.datetime("startedAt").nullable(); // Not when the row is created, but when the end-to-end connection between user and resource is established | ||
t.datetime("endedAt").nullable(); | ||
t.index(["startedAt", "endedAt"]); | ||
|
||
t.timestamps(true, true, true); | ||
}); | ||
} | ||
|
||
await createOnUpdateTrigger(knex, TableName.PamFolder); | ||
await createOnUpdateTrigger(knex, TableName.PamResource); | ||
await createOnUpdateTrigger(knex, TableName.PamAccount); | ||
await createOnUpdateTrigger(knex, TableName.PamSession); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.schema.dropTableIfExists(TableName.PamSession); | ||
await knex.schema.dropTableIfExists(TableName.PamAccount); | ||
await knex.schema.dropTableIfExists(TableName.PamResource); | ||
await knex.schema.dropTableIfExists(TableName.PamFolder); | ||
|
||
await dropOnUpdateTrigger(knex, TableName.PamSession); | ||
await dropOnUpdateTrigger(knex, TableName.PamAccount); | ||
await dropOnUpdateTrigger(knex, TableName.PamResource); | ||
await dropOnUpdateTrigger(knex, TableName.PamFolder); | ||
} |
19 changes: 19 additions & 0 deletions
19
backend/src/db/migrations/20251002113756_add-gateway-pam-key.ts
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,19 @@ | ||
import { Knex } from "knex"; | ||
|
||
import { TableName } from "../schemas"; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
if (!(await knex.schema.hasColumn(TableName.GatewayV2, "encryptedPamSessionKey"))) { | ||
await knex.schema.alterTable(TableName.GatewayV2, (t) => { | ||
t.binary("encryptedPamSessionKey"); | ||
}); | ||
} | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
if (await knex.schema.hasColumn(TableName.GatewayV2, "encryptedPamSessionKey")) { | ||
await knex.schema.alterTable(TableName.GatewayV2, (t) => { | ||
t.dropColumn("encryptedPamSessionKey"); | ||
}); | ||
} | ||
} |
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,26 @@ | ||
// Code generated by automation script, DO NOT EDIT. | ||
// Automated by pulling database and generating zod schema | ||
// To update. Just run npm run generate:schema | ||
// Written by akhilmhdh. | ||
|
||
import { z } from "zod"; | ||
|
||
import { zodBuffer } from "@app/lib/zod"; | ||
|
||
import { TImmutableDBKeys } from "./models"; | ||
|
||
export const PamAccountsSchema = z.object({ | ||
id: z.string().uuid(), | ||
projectId: z.string(), | ||
folderId: z.string().uuid().nullable().optional(), | ||
resourceId: z.string().uuid(), | ||
name: z.string(), | ||
description: z.string().nullable().optional(), | ||
encryptedCredentials: zodBuffer, | ||
createdAt: z.date(), | ||
updatedAt: z.date() | ||
}); | ||
|
||
export type TPamAccounts = z.infer<typeof PamAccountsSchema>; | ||
export type TPamAccountsInsert = Omit<z.input<typeof PamAccountsSchema>, TImmutableDBKeys>; | ||
export type TPamAccountsUpdate = Partial<Omit<z.input<typeof PamAccountsSchema>, TImmutableDBKeys>>; |
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,22 @@ | ||
// Code generated by automation script, DO NOT EDIT. | ||
// Automated by pulling database and generating zod schema | ||
// To update. Just run npm run generate:schema | ||
// Written by akhilmhdh. | ||
|
||
import { z } from "zod"; | ||
|
||
import { TImmutableDBKeys } from "./models"; | ||
|
||
export const PamFoldersSchema = z.object({ | ||
id: z.string().uuid(), | ||
projectId: z.string(), | ||
parentId: z.string().uuid().nullable().optional(), | ||
name: z.string(), | ||
description: z.string().nullable().optional(), | ||
createdAt: z.date(), | ||
updatedAt: z.date() | ||
}); | ||
|
||
export type TPamFolders = z.infer<typeof PamFoldersSchema>; | ||
export type TPamFoldersInsert = Omit<z.input<typeof PamFoldersSchema>, TImmutableDBKeys>; | ||
export type TPamFoldersUpdate = Partial<Omit<z.input<typeof PamFoldersSchema>, TImmutableDBKeys>>; |
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,25 @@ | ||
// Code generated by automation script, DO NOT EDIT. | ||
// Automated by pulling database and generating zod schema | ||
// To update. Just run npm run generate:schema | ||
// Written by akhilmhdh. | ||
|
||
import { z } from "zod"; | ||
|
||
import { zodBuffer } from "@app/lib/zod"; | ||
|
||
import { TImmutableDBKeys } from "./models"; | ||
|
||
export const PamResourcesSchema = z.object({ | ||
id: z.string().uuid(), | ||
projectId: z.string(), | ||
name: z.string(), | ||
gatewayId: z.string().uuid(), | ||
resourceType: z.string(), | ||
encryptedConnectionDetails: zodBuffer, | ||
createdAt: z.date(), | ||
updatedAt: z.date() | ||
}); | ||
|
||
export type TPamResources = z.infer<typeof PamResourcesSchema>; | ||
export type TPamResourcesInsert = Omit<z.input<typeof PamResourcesSchema>, TImmutableDBKeys>; | ||
export type TPamResourcesUpdate = Partial<Omit<z.input<typeof PamResourcesSchema>, TImmutableDBKeys>>; |
Oops, something went wrong.
Oops, something went wrong.
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.