feat(admission): add scheduled group access
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { sql } from "drizzle-orm";
|
||||
import {
|
||||
boolean,
|
||||
check,
|
||||
index,
|
||||
integer,
|
||||
inet,
|
||||
jsonb,
|
||||
pgEnum,
|
||||
@@ -80,6 +82,26 @@ export const groups = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
export const groupAccessWindows = pgTable(
|
||||
"group_access_windows",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
groupId: uuid("group_id")
|
||||
.notNull()
|
||||
.references(() => groups.id, { onDelete: "cascade" }),
|
||||
startMinuteOfWeek: integer("start_minute_of_week").notNull(),
|
||||
endMinuteOfWeek: integer("end_minute_of_week").notNull(),
|
||||
createdAt: createdAt(),
|
||||
},
|
||||
(table) => [
|
||||
index("group_access_windows_group_idx").on(table.groupId),
|
||||
check(
|
||||
"group_access_windows_minute_range_check",
|
||||
sql`${table.startMinuteOfWeek} >= 0 and ${table.startMinuteOfWeek} < 10080 and ${table.endMinuteOfWeek} >= 0 and ${table.endMinuteOfWeek} < 10080 and ${table.startMinuteOfWeek} <> ${table.endMinuteOfWeek}`,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
export const userGroupMemberships = pgTable(
|
||||
"user_group_memberships",
|
||||
{
|
||||
@@ -178,6 +200,9 @@ export const appSettings = pgTable("app_settings", {
|
||||
vpnDeniedMessage: text("vpn_denied_message")
|
||||
.notNull()
|
||||
.default("VPN, proxy, and Tor connections are not allowed. Contact a host to request an exception."),
|
||||
scheduledAccessDeniedMessage: text("scheduled_access_denied_message")
|
||||
.notNull()
|
||||
.default("Your group is only allowed access from {next_start} to {next_end}."),
|
||||
...timestamps(),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user