mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-03 10:26:00 +00:00
feat: secrets expire either with time or views
This commit is contained in:
@@ -8,8 +8,7 @@ export async function up(knex: Knex): Promise<void> {
|
||||
|
||||
await knex.schema.alterTable(TableName.SecretSharing, (t) => {
|
||||
if (!hasExpiresAfterViewsColumn) {
|
||||
t.integer("expiresAfterViews").nullable();
|
||||
t.timestamp("expiresAt").nullable().alter();
|
||||
t.integer("expiresAfterViews");
|
||||
}
|
||||
|
||||
if (hasSecretNameColumn) {
|
||||
@@ -25,7 +24,6 @@ export async function down(knex: Knex): Promise<void> {
|
||||
await knex.schema.alterTable(TableName.SecretSharing, (t) => {
|
||||
if (hasExpiresAfterViewsColumn) {
|
||||
t.dropColumn("expiresAfterViews");
|
||||
t.timestamp("expiresAt").notNullable().alter();
|
||||
}
|
||||
|
||||
if (!hasSecretNameColumn) {
|
||||
|
||||
@@ -13,7 +13,7 @@ export const SecretSharingSchema = z.object({
|
||||
iv: z.string(),
|
||||
tag: z.string(),
|
||||
hashedHex: z.string(),
|
||||
expiresAt: z.date().nullable().optional(),
|
||||
expiresAt: z.date(),
|
||||
userId: z.string().uuid(),
|
||||
orgId: z.string().uuid(),
|
||||
createdAt: z.date(),
|
||||
|
||||
@@ -84,9 +84,8 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>
|
||||
hashedHex: z.string(),
|
||||
expiresAt: z
|
||||
.string()
|
||||
.optional()
|
||||
.refine((date) => date === undefined || new Date(date) > new Date(), "Expires at should be a future date"),
|
||||
expiresAfterViews: z.number().optional()
|
||||
expiresAfterViews: z.number()
|
||||
}),
|
||||
response: {
|
||||
200: z.object({
|
||||
@@ -107,7 +106,7 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>
|
||||
iv,
|
||||
tag,
|
||||
hashedHex,
|
||||
expiresAt: expiresAt ? new Date(expiresAt) : undefined,
|
||||
expiresAt: new Date(expiresAt),
|
||||
expiresAfterViews
|
||||
});
|
||||
return { id: sharedSecret.id };
|
||||
|
||||
@@ -13,8 +13,8 @@ export type TCreateSharedSecretDTO = {
|
||||
iv: string;
|
||||
tag: string;
|
||||
hashedHex: string;
|
||||
expiresAt?: Date;
|
||||
expiresAfterViews?: number;
|
||||
expiresAt: Date;
|
||||
expiresAfterViews: number;
|
||||
} & TSharedSecretPermission;
|
||||
|
||||
export type TDeleteSharedSecretDTO = {
|
||||
|
||||
Reference in New Issue
Block a user